-
Notifications
You must be signed in to change notification settings - Fork 0
/
count.py
53 lines (44 loc) · 1.15 KB
/
count.py
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import cv2
import sys
from darkflow.net.build import TFNet
import matplotlib.pyplot as plt
#%config InlineBackend.figure_format = 'svg'
'''program_name = sys.argv[0]
arguments = sys.argv[1:]
co = len(arguments)
'''
td=0.12
options = {
'model': 'cfg/yolo.cfg',
'load': 'bin/yolov2.weights',
'threshold': td ,
'gpu': 0.7
}
tfnet = TFNet(options)
'''cnt=0
img = cv2.imread('img/18.jpg', cv2.IMREAD_COLOR)
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
# use YOLO to predict the image
result = tfnet.return_predict(img)
for res in result:
if res['label']=='person':
print(res['confidence'])
cnt=cnt+1
print('Count in the image:',cnt)'''
# read the color image and covert to RGB
for itr in range(1,17):
src = str(itr)+'.jpg';
img = cv2.imread(src, cv2.IMREAD_COLOR)
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
# use YOLO to predict the image
result = tfnet.return_predict(img)
cnt=1
img.shape
for res in result:
if res['label']=='person':
print(res['confidence'])
cnt=cnt+1
print('Count in the image:', itr ,cnt)
'''if cv2.waitKey(0):
cv2.imshow('img',img)
exit(0)'''