Internship Report
Internship Report
Internship Report
Contents
Installing Miniconda .............................................................................................................................................. 3
Downloading and Installing: .............................................................................................................................. 3
Run the Miniconda installer .............................................................................................................................. 3
Jupyter Notebook: ............................................................................................................................................. 5
Learning python..................................................................................................................................................... 7
Using Simplilearn: .............................................................................................................................................. 7
Topics: ................................................................................................................................................................ 7
Python Tasks .......................................................................................................................................................... 8
Scientific calculator using Python: ..................................................................................................................... 8
Checking number in List: ................................................................................................................................. 12
Hangman Game: .............................................................................................................................................. 12
Searching in list: ............................................................................................................................................... 14
Shopping Cart: ................................................................................................................................................. 14
User Data base using python: .......................................................................................................................... 18
Installation Raspberry pi OS: ............................................................................................................................... 22
Raspberry pi 4 specifications: .......................................................................................................................... 22
Installation of Raspbian operating system: ..................................................................................................... 23
Connecting Raspberry pi to laptop: ................................................................................................................. 24
Putty: ............................................................................................................................................................... 25
VNC Viewer: ..................................................................................................................................................... 27
Final Project ......................................................................................................................................................... 28
Object Detection:............................................................................................................................................. 28
Introduction: .................................................................................................................................................... 28
Importance: ..................................................................................................................................................... 28
Components used in Project: .......................................................................................................................... 28
Working on Project: ......................................................................................................................................... 28
Setup Virtual Env ............................................................................................................................................. 30
Installing tensorflow lite in python 3: .............................................................................................................. 31
Use Cases of TensorFlow Mobile .................................................................................................................. 31
Running Project: .............................................................................................................................................. 32
Installing Miniconda
>Jupyter notebook
As soon as you hit the above command button, It will open a browser with jupyter notebook
Let's write hello world program in the Jupyter notebook. The browser will look like
➢ print('Hello world')
Learning python
Using Simplilearn:
04 – 11 July 2022 Learning Python Week 1
12 - 19 July 2022 Learning Python week 2
20- 27July, 2022 Learning python Week 3
Topics:
The topics covered are :
• Python IDEs
• Python Variables
• Python Numbers
• Python Strings
• Python Loops
• Python Arrays
• Python List
• Python Tuples
• Python Slicing
• Python Functions
Python Tasks
import math
if (operation==1):
# For Subtraction
elif (operation==2):
# For Multiplication
elif (operation==3):
# For Division
elif (operation==4):
elif(operation==5):
# For Cos0
elif(operation==6):
# For Sin0
elif(operation==7):
# For Tan0
elif(operation==8):
elif(operation==9):
# For Sin0
elif(operation==10):
num1=float(input("\n enter the number"))
# For Tan0
elif(operation==11):
else:
print("invalid Option")
Output:
Checking number in List:
Code:
list=[1,8,9,7,6,2,7,88,5,48,65,25,58,96]
if check in list:
else:
Output:
Hangman Game:
Code:
import random
play = True
while play:
print("good luck",Name)
list = ["Jamal","Kamal","Fawad","Haseeb","Hassan","Abdullah","Ahmad","Awab","Uzair","Shahzaib"
"Usama","Asim", "Umar","Saqib","Uzair","Ali","Usman","Suleiman",
"Furqan","Waqas","Samee","Annus","ateeq","arbab","waheed","usama","mohib","umair",
"haris","mubeen","ismail", "hamza","luqman","imran"]
words = random.sample(list,10)
word = random.choice(words)
print(word)
print("this is the list you have to guess any word from these words")
print(words)
life = 3
print(guess)
if word == guess:
break
life = life - 1
if life == 0:
again = str(input("if you dont want to play enter no or press any key and enter "))
if again == "no":
play = False
Output:
Searching in list:
code
list=[]
list.append(numbers)
print(list)
Output:
Shopping Cart:
Code:
def start():
while True:
print()
print('''
Select a number for the action that you would like to do:
5. Exit
''')
if selection == "1":
displayList()
addItem()
removeItem()
clearList()
sys.exit()
else:
print("You did not make a valid selection.")
shopping_list = []
def displayList():
print()
for i in shopping_list:
print("* " + i)
def addItem():
item = input("Enter the item you wish to add to the shopping list: ")
shopping_list.append(item)
def removeItem():
item = input("Enter the item you wish to remove from the shopping list: ")
shopping_list.remove(item)
def clearList():
shopping_list.clear()
Output:
User Data base using python:
import csv
def register():
# now if both the passwords are equal then store password and email in file and make registration
successful.
if password == password1:
csv_file = csv.writer(_file)
# csv_file.writerow(fields)
csv_file.writerow(reg)
print("Registration successful!!!")
csvFile = csv.reader(File)
print(lines)
else:
print("Password Mismatch!!")
def login():
_csvFile = csv.reader(_File)
# print(lines)
return True
# IsCreated = False
while True:
# ans = checklogin()
ans = login()
if ans == True:
print("2. Quit")
if option == '1':
break
else:
else:
while True:
print("1. login")
print("2. Registration")
print("3. Quit")
choice = input("As you are not logged in. So, choose one of the above functions: ")
if choice == '1':
login()
register()
break
else:
Output:
Installation Raspberry pi OS:
Raspberry pi 4 specifications:
• Broadcom BCM2711, Quad core Cortex-A72 (ARM v8) 64-bit SoC @ 1.5GHz
• 1GB, 2GB, 4GB or 8GB LPDDR4-3200 SDRAM (depending on model)
• 2.4 GHz and 5.0 GHz IEEE 802.11ac wireless, Bluetooth 5.0, BLE
• Gigabit Ethernet
• 2 USB 3.0 ports; 2 USB 2.0 ports.
• Raspberry Pi standard 40 pin GPIO header (fully backwards compatible with previous
boards)
• 2 × micro-HDMI ports (up to 4kp60 supported)
• 2-lane MIPI DSI display port
• 2-lane MIPI CSI camera port
• 4-pole stereo audio and composite video port
• H.265 (4kp60 decode), H264 (1080p60 decode, 1080p30 encode)
• OpenGL ES 3.1, Vulkan 1.0
• Micro-SD card slot for loading operating system and data storage
• 5V DC via USB-C connector (minimum 3A*)
• 5V DC via GPIO header (minimum 3A*)
• Power over Ethernet (PoE) enabled (requires separate PoE HAT)
• Operating temperature: 0 – 50 degrees C ambient
* A good quality 2.5A power supply can be used if downstream USB peripherals consume less
than 500mA in total.
Installation of Raspbian operating system:
⮚ Insert a microSD card in your laptop or desktop.
⮚ Download and install Raspberry Pi Imager.
⮚ Interface will be
⮚ Once installed, run the Raspberry Pi Imager program. Choose ‘Raspberry Pi OS (32 bit)’
from the OS menu.
⮚ We press ctrl+shift+X new menu will open to set the host name and enable SSH to
configure WIFI and then click save .
⮚ Click ‘Choose SD card’ and select your card from the menu.
⮚ Click Write. This process will take several minutes as Raspberry Pi Imager downloads
Raspberry Pi OS and load it to microSD card.
● By entering the hostname in the putty we will click on open to find our host device . click
open button to proceed.
● A login as: message will pop-up and asks you to enter your SSH username. However, for
shared hosting users, you will need to enter a predefined username. After entering your
username, press Enter.
● Type SSH password and press Enter again. For security reasons, the screen won’t show
the password but will register what you type.
VNC Viewer:
Then open VNC and connect to raspberrypi using ip address of raspberrypi we have found using previous
steps. The interface of vnc is shown below:
Final Project
Object Detection:
Introduction:
Object detection is a computer vision technique for locating instances of
objects in images or videos. Object detection algorithms typically leverage machine learning or
deep learning to produce meaningful results. When humans look at images or video, we can
recognize and locate objects of interest within a matter of moments. The goal of object detection
is to replicate this intelligence using a computer.
Importance:
Object detection is a key technology behind advanced driver assistance systems
(ADAS) that enable cars to detect driving lanes or perform pedestrian detection to improve road
safety. Object detection is also useful in applications such as video surveillance or image retrieval
systems.
Working on Project:
Connecting Camera:
Connect your camera module to the CSI port on your Raspberry Pi;
this is the long thin port adjacent to the HDMI socket. Gently lift the collar on top of the
CSI port Slide the ribbon cable of the camera module into the port with the blue side
facing the Ethernet.
Once the cable is seated in the port, press the collar back down to lock the cable in place.
If done properly you should be able to easily lift the Pi by the camera’s cable without it
falling out.
Turn the Raspberry Pi on and launch the Raspberry Pi Software Configuration tool by typing the
following command:
>sudo raspi-config
python --version
make directory
mkdir project
ls
cd project
source env/bin/activate
Install libraries:
python3
TensorFlow Lite is an open-source, product ready, cross-platform deep learning framework that converts a
pre-trained model in TensorFlow to a special format that can be optimized for speed or storage. The special
format model can be deployed on edge devices like mobiles using Android or iOS or Linux based embedded
devices like Raspberry Pi or Microcontrollers to make the inference at the Edge.
import tflite_runtime
tflite_runtime._version_
Then use our script to install a couple Python packages, and download the TFLite model:
cd examples/lite/examples/image_classification/raspberry_pi
Running Project:
Targeting directory:
cd project
source env/bin/activete
cd examples/lite/examples/image_classification/raspberry_pi/
ls
python3 classify.py
Code:
import argparse
import sys
import time
import cv2
# Visualization parameters
_ROW_SIZE = 20 # pixels
_LEFT_MARGIN = 24 # pixels
_TEXT_COLOR = (0, 0, 255) # red
_FONT_SIZE = 1
_FONT_THICKNESS = 1
_FPS_AVERAGE_FRAME_COUNT = 10
enable_edgetpu: bool, camera_id: int, width: int, height: int) -> None:
Args:
"""
base_options = core.BaseOptions(
classification_options = processor.ClassificationOptions(
max_results=max_results, score_threshold=score_threshold)
options = vision.ImageClassifierOptions(
base_options=base_options, classification_options=classification_options)
classifier = vision.ImageClassifier.create_from_options(options)
counter, fps = 0, 0
start_time = time.time()
cap = cv2.VideoCapture(camera_id)
cap.set(cv2.CAP_PROP_FRAME_WIDTH, width)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, height)
while cap.isOpened():
if not success:
sys.exit(
'ERROR: Unable to read from webcam. Please verify your webcam settings.'
counter += 1
image = cv2.flip(image, 1)
# Convert the image from BGR to RGB as required by the TFLite model.
tensor_image = vision.TensorImage.create_from_array(rgb_image)
categories = classifier.classify(tensor_image)
category_name = category.category_name
score = round(category.score, 2)
if counter % _FPS_AVERAGE_FRAME_COUNT == 0:
end_time = time.time()
start_time = time.time()
if cv2.waitKey(1) == 27:
break
cv2.imshow('image_classification', image)
cap.release()
cv2.destroyAllWindows()
def main():
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument(
'--model',
required=False,
default='efficientnet_lite0.tflite')
parser.add_argument(
'--maxResults',
required=False,
default=3)
parser.add_argument(
'--scoreThreshold',
required=False,
type=float,
default=0.0)
parser.add_argument(
'--numThreads',
help='Number of CPU threads to run the model.',
required=False,
default=4)
parser.add_argument(
'--enableEdgeTPU',
action='store_true',
required=False,
default=False)
parser.add_argument(
parser.add_argument(
'--frameWidth',
required=False,
default=640)
parser.add_argument(
'--frameHeight',
required=False,
default=480)
args = parser.parse_args()
run(args.model, int(args.maxResults),
main()
Laptop:
References:
https://github.com/tensorflow/examples/tree/a9265a997d0410c431a292e3553646b3b655ea1f/lite/example
s/image_classification/raspberry_pi
https://www.tensorflow.org/
Thanks