forked from WongKinYiu/yolov7
-
Notifications
You must be signed in to change notification settings - Fork 1
/
photo_detect.py
30 lines (29 loc) · 913 Bytes
/
photo_detect.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
import cv2
import detect_api
import time
if __name__ == '__main__':
import os, shutil
for file in os.scandir("./runs/detect"):
if file.name.startswith("test"):
shutil.rmtree(file.path)
print(f"removed {file.path}")
weight = "runs/train/210-416-48-1000-tiny/weights/best.pt"
conf_thres = 0.25
iou_thres = 0.45
classes = None
detect = detect_api.Detect(weight, conf_thres, iou_thres, classes)
size = 640
detect.init_size(size)
while True:
a = input()
path = "../test/images/" + a
start = time.time()
if os.path.exists(path):
# Read image
#print(path)
im0s = cv2.imread(path) # BGR
#print(im0s)
detect.detect_image(im0s, size)
else:
print("not find")
print(f"time :{time.time() - start}, fps: {1 / (time.time() - start)}")