Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
ON
CAR’S BRAND DETECTION USING TENSOR FLOW.
SUBMITTED BY
It gives me great pleasure to present the project on” Car’s brand detection using
tensor flow” prepared sincerely, punctually and with utmost efforts.
The contents of this document are presented into many chapters, in order
to ease reading. The project has been illustrated with precise data elucidated
with neat Data flow Diagram, Entity relationship diagram and network diagram
that simplify the understanding of the project. The project includes the software
development tools like(python, anaconda prompt, tensorflow-gpu)
Meticulous care has been taken to make this project perfect and useful in
every aspect.
ORGANIZATIONAL OVERVIEW
1)Easy to use
It has user friendly GUI for using this product,no extra skill is required to
use it
2)Saves money
It is an open source project,so no need to waste money on other system.
3)Accuracy
Accuracy of this model is more than 80% while using webcam and while
picture uploading it reaches 99%
4)Speed
Detection speed for the car is only few seconds hardly a minute
6)Internet
No internet connectivity is required for using this product.
7)Features
It provides features such as mileage boot space and its name to the user
SYSTEM REQUIREMENT SPECIFICATION
HARDWARE REQUIREMENT
2)KEYBOARD
3)MOUSE
4)MONITOR
SOFTWARE REQUIREMENT
1)PYTHON 3.7
2)ANACONDA
3)TENSORFLOW-GPU V1.4
4)CUDA V.8.0
5)cuDNN V.6.0
IMAGE FILE:
UPLOADING IMAGE:
DETECTION PAGE:
RESULTS:
SYSTEM’S WEBCAM RESULT:
IPWEBCAM PAGE:
IPWEBCAM RESULT:
PROGRAM LISTING
PIPELINE FOR DETECTION:
model {
faster_rcnn {
num_classes: 4
image_resizer {
keep_aspect_ratio_resizer {
min_dimension: 600
max_dimension: 1024
}
}
feature_extractor {
type: "faster_rcnn_inception_v2"
first_stage_features_stride: 16
}
first_stage_anchor_generator {
grid_anchor_generator {
height_stride: 16
width_stride: 16
scales: 0.25
scales: 0.5
scales: 1.0
scales: 2.0
aspect_ratios: 0.5
aspect_ratios: 1.0
aspect_ratios: 2.0
}
}
first_stage_box_predictor_conv_hyperparams {
op: CONV
regularizer {
l2_regularizer {
weight: 0.0
}
}
initializer {
truncated_normal_initializer {
stddev: 0.009999999776482582
}
}
}
first_stage_nms_score_threshold: 0.0
first_stage_nms_iou_threshold: 0.699999988079071
first_stage_max_proposals: 300
first_stage_localization_loss_weight: 2.0
first_stage_objectness_loss_weight: 1.0
initial_crop_size: 14
maxpool_kernel_size: 2
maxpool_stride: 2
second_stage_box_predictor {
mask_rcnn_box_predictor {
fc_hyperparams {
op: FC
regularizer {
l2_regularizer {
weight: 0.0
}
}
initializer {
variance_scaling_initializer {
factor: 1.0
uniform: true
mode: FAN_AVG
}
}
}
use_dropout: false
dropout_keep_probability: 1.0
}
}
second_stage_post_processing {
batch_non_max_suppression {
score_threshold: 0.0
iou_threshold: 0.6000000238418579
max_detections_per_class: 100
max_total_detections: 300
}
score_converter: SOFTMAX
}
second_stage_localization_loss_weight: 2.0
second_stage_classification_loss_weight: 1.0
}
}
train_config {
batch_size: 1
data_augmentation_options {
random_horizontal_flip {
}
}
optimizer {
momentum_optimizer {
learning_rate {
manual_step_learning_rate {
initial_learning_rate: 0.00019999999494757503
schedule {
step: 900000
learning_rate: 1.9999999494757503e-05
}
schedule {
step: 1200000
learning_rate: 1.9999999949504854e-06
}
}
}
momentum_optimizer_value: 0.8999999761581421
}
use_moving_average: false
}
gradient_clipping_by_norm: 10.0
fine_tune_checkpoint:
"D:/tensorflow1/models/research/object_detection/faster_rcnn_inception
_v2_coco_2018_01_28/model.ckpt"
from_detection_checkpoint: true
num_steps: 200000
load_all_detection_checkpoint_vars: true
}
train_input_reader {
label_map_path:
"D:/tensorflow1/models/research/object_detection/training/labelmap.pbtx
t"
tf_record_input_reader {
input_path:
"D:/tensorflow1/models/research/object_detection/train.record"
}
}
eval_config {
num_examples: 47
metrics_set: "coco_detection_metrics"
use_moving_averages: false
}
eval_input_reader {
label_map_path:
"D:/tensorflow1/models/research/object_detection/training/labelmap.pbtx
t"
shuffle: false
num_readers: 1
tf_record_input_reader {
input_path:
"D:/tensorflow1/models/research/object_detection/test.record"
}}
LABELMAP:
item {
id: 1
name: 'BMW(mileage:16.13,bootspace:480L)'
item {
id: 2
name: 'NANO(mileage:33.0,bootspace:300L)'
item {
id: 3
name: 'SCORPIO(mileage:16.36,bootspace:460L)'
}
item {
id: 4
name: 'MINI COOPER(mileage:17.12,bootspace:420L)'
}
GUI:
import subprocess
from tkinter import *
from PIL import ImageTk, Image
from tkinter import filedialog
from tkinter.ttk import Combobox
def image():
subprocess.call(['python','proj.py'])
def webcam():
subprocess.call(['python','Object_detection_webcam.py'])
def droidcam():
subprocess.call(['python','proj1.py'])
class FullScreenApp(object):
def __init__(self, master, **kwargs):
self.master=master
pad=3
self._geom='200x200+0+0'
master.geometry("{0}x{1}+0+0".format(
master.winfo_screenwidth()-pad,
master.winfo_screenheight()-pad))
master.bind('<Escape>',self.toggle_geom)
def toggle_geom(self,event):
geom=self.master.winfo_geometry()
print(geom,self._geom)
self.master.geometry(self._geom)
self._geom=geom
root1=Tk()
background=PhotoImage(file='D:/tensorflow1 - Copy
(3)/models/research/object_detection/33.png')
a=PhotoImage(file='C:/tensorflow1 - Copy
(3)/models/research/object_detection/53.png')
tm = a.subsample(5, 5)
background_label=Label(root1,image=background)
background_label.place(x=0,y=0,relwidth=1,relheight=1)
button1=Button(root1,text="Image",height = 100, width =
100,image=tm,command=image,bd=10)
button1.place(x=130,y=52)
label1= Label(root1, width=8,text="Image File",bg="SpringGreen3",font =
"Helvetica 16 bold italic")
label1.place(x=130,y=175)
b=PhotoImage(file='C:/tensorflow1 - Copy
(3)/models/research/object_detection/56.png')
tm1 = b.subsample(5, 5)
button2=Button(root1,text="WebCam",height = 100, width =
100,image=tm1,command=webcam,bd=10)
button2.place(x=130,y=450)
label2= Label(root1, width=8,text="webcam",bg="SpringGreen3",font =
"Helvetica 16 bold italic")
label2.place(x=130,y=575)
c=PhotoImage(file='C:/tensorflow1 - Copy
(3)/models/research/object_detection/unnamed.png')
tm2 = c.subsample(5, 5)
button3=Button(root1,text="IPwebcam",height = 100, width =
100,image=tm2,command=droidcam,bd=10)
button3.place(x=130,y=250)
label3= Label(root1, width=8,text="IPwebcam",bg="SpringGreen3",font =
"Helvetica 16 bold italic")
label3.place(x=130,y=375)
app=FullScreenApp(root1)
root1.mainloop()
IMAGE UPLOAD:
cv2.destroyAllWindows()
file=filedialog.askopenfilename(initialdir="/",title="select
file",filetypes=[("jpeg files",".jpeg"),("jpg files",".jpg"),("png
files",".png"),("all files",".*")])
root=Tk()
button=Button(root,height = 2, width =
11,bg="SpringGreen3",bd=10,text="Detect image!",font = "Helvetica 16
bold italic",command=clickme1)
button.pack()
w = Label(root, width=25,text="Click to recognize
image!",bg="SpringGreen3",font = "Helvetica 16 bold italic").pack()
text1="It’s easy enough to make a computer recognize a specific
image, like a QR code, but they suck at recognizing things in states they
don’t expect — enter image recognition.The way image recognition
works, typically, involves the creation of a neural network that processes
the individual pixels of an image. Researchers feed these networks as
many pre-labelled images as they can, in order to “teach” them how to
recognize similar images."
description=Message(root,text=text1,bg="SpringGreen",font =
"Helvetica 20 bold italic",aspect=1000).place(x=0,y=250)
root.configure(bg="SpringGreen3")
app1=FullScreenApp(root)
root.mainloop()
class FullScreenApp(object):
def __init__(self, master, **kwargs):
self.master=master
pad=3
self._geom='200x200+0+0'
master.geometry("{0}x{1}+0+0".format(
master.winfo_screenwidth()-pad,
master.winfo_screenheight()-pad))
master.bind('<Escape>',self.toggle_geom)
def toggle_geom(self,event):
geom=self.master.winfo_geometry()
print(geom,self._geom)
self.master.geometry(self._geom)
self._geom=geom
root1=Tk()
root1.geometry("170x200+30+30")
background=PhotoImage(file='D:/tensorflow1 - Copy
(3)/models/research/object_detection/33.png')
background_label=Label(root1,image=background)
background_label.place(x=0,y=0,relwidth=1,relheight=1)
tmp = PhotoImage(file='D:/tensorflow1 - Copy
(3)/models/research/object_detection/88.png')
tm = tmp.subsample(2, 2)
button1=Button(root1,height = 100, width =
100,bg="red",command=clickme,image=tm,bd=10)
button1.place(x=150,y=50)
w = Label(root1, width=18,text="Select the cars
image!",bg="SpringGreen3",font = "Helvetica 16 bold italic")
w.place(x=110,y=180)
exitbtn=Button(root1,text="EXIT",height = 1, width = 4,bg="red",font =
"Helvetica 16 bold italic",bd=10,command=root1.destroy)
exitbtn.place(x=1380,y=0)
app=FullScreenApp(root1)
root1.mainloop()
cardetect()
IPWEBCAM:
video.release()
cv2.destroyAllWindows()
class FullScreenApp(object):
def __init__(self, master, **kwargs):
self.master=master
pad=3
self._geom='200x200+0+0'
master.geometry("{0}x{1}+0+0".format(
master.winfo_screenwidth()-pad,
master.winfo_screenheight()-pad))
master.bind('<Escape>',self.toggle_geom)
def toggle_geom(self,event):
geom=self.master.winfo_geometry()
print(geom,self._geom)
self.master.geometry(self._geom)
self._geom=geom
master = tk.Tk()
background=tk.PhotoImage(file='D:/tensorflow1 - Copy
(3)/models/research/object_detection/33.png')
background_label=Label(master,image=background)
background_label.place(x=0,y=0,relwidth=1,relheight=1)
label1=tk.Label(master, text="Enter IPWEBCAM wifi
ip",bg="SpringGreen3",height=1,bd=10,width=18,font = "Helvetica 16
bold italic")
label1.place(x=150,y=50)
e1 = tk.Entry(master,font = "Helvetica 16 bold italic",bd=10)
e1.place(x=400,y=50)
import requests
import os
import urllib.request
import cv2
import numpy as np
import tensorflow as tf
import sys
sys.path.append("..")
from utils import label_map_util
from utils import visualization_utils as vis_util
MODEL_NAME = 'inference_graph'
CWD_PATH = os.getcwd()
PATH_TO_CKPT =
os.path.join(CWD_PATH,MODEL_NAME,'frozen_inference_graph.pb')
PATH_TO_LABELS =
os.path.join(CWD_PATH,'training','labelmap.pbtxt')
NUM_CLASSES = 4
label_map = label_map_util.load_labelmap(PATH_TO_LABELS)
categories =
label_map_util.convert_label_map_to_categories(label_map,
max_num_classes=NUM_CLASSES, use_display_name=True)
category_index = label_map_util.create_category_index(categories)
detection_graph = tf.Graph()
with detection_graph.as_default():
od_graph_def = tf.GraphDef()
with tf.gfile.GFile(PATH_TO_CKPT, 'rb') as fid:
serialized_graph = fid.read()
od_graph_def.ParseFromString(serialized_graph)
tf.import_graph_def(od_graph_def, name='')
sess = tf.Session(graph=detection_graph)
image_tensor = detection_graph.get_tensor_by_name('image_tensor:0')
detection_boxes =
detection_graph.get_tensor_by_name('detection_boxes:0')
detection_scores =
detection_graph.get_tensor_by_name('detection_scores:0')
detection_classes =
detection_graph.get_tensor_by_name('detection_classes:0')
num_detections =
detection_graph.get_tensor_by_name('num_detections:0')
video = cv2.VideoCapture(0)
ret = video.set(3,1280)
ret = video.set(4,720)
while(True):
ret, frame = video.read()
frame_expanded = np.expand_dims(frame, axis=0)
(boxes, scores, classes, num) = sess.run(
[detection_boxes, detection_scores, detection_classes,
num_detections],
feed_dict={image_tensor: frame_expanded})
vis_util.visualize_boxes_and_labels_on_image_array(
frame,
np.squeeze(boxes),
np.squeeze(classes).astype(np.int32),
np.squeeze(scores),
category_index,
use_normalized_coordinates=True,
line_thickness=8,
min_score_thresh=0.60)
cv2.imshow('Object detector', frame)
if cv2.waitKey(1) == ord('q'):
breaK
video.release()
cv2.destroyAllWindows()
VALIDATIONS: