-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbounding_box.py
More file actions
37 lines (26 loc) · 1006 Bytes
/
Copy pathbounding_box.py
File metadata and controls
37 lines (26 loc) · 1006 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#Preprocessing Creating Bounding Box
import cv2
import os
from gluoncv import model_zoo, data, utils
from matplotlib import pyplot as plt
#Creating image list
Image=[]
Id=[]
x=os.listdir('data/')
for name in x:
fname='data/'+name
img=cv2.imread(fname)
Image.append(img)
n=name.split('_')
Id.append(n)
# now we have list of image and also list of ids
# Loading pretrained model of yolo
model = model_zoo.get_model('yolo3_darknet53_voc', pretrained=True)
# Using model on the image set
coYolo, imYolo = data.transforms.presets.yolo.load_test(Image, short=512)
#coYolo, imYolo are respectively storing is a n-Dimensional array with shape (batch_size,channels,Height ,width) and
#image stored in numpy array format
#Obtaining class number , confidence score and bounding box description
class_num, confidence,box = model(coYolo)
images = utils.viz.plot_bbox(imYolo, box[0], confidence[0],
class_num[0], class_names=model.classes)