Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -147,7 +147,7 @@ def detect(img,model):
|
|
147 |
nms_time.update(t4-t3,img.size(0))
|
148 |
det=det_pred[0]
|
149 |
|
150 |
-
save_path = str(save_dir +'/'+ 'img.jpg')
|
151 |
|
152 |
_, _, height, width = img.shape
|
153 |
h,w,_=img_det.shape
|
@@ -179,24 +179,8 @@ def detect(img,model):
|
|
179 |
label_det_pred = f'{names[int(cls)]} {conf:.2f}'
|
180 |
plot_one_box(xyxy, img_det , label=label_det_pred, color=colors[int(cls)], line_thickness=2)
|
181 |
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
elif dataset.mode == 'video':
|
186 |
-
if vid_path != save_path: # new video
|
187 |
-
vid_path = save_path
|
188 |
-
if isinstance(vid_writer, cv2.VideoWriter):
|
189 |
-
vid_writer.release() # release previous video writer
|
190 |
-
|
191 |
-
fourcc = 'mp4v' # output video codec
|
192 |
-
fps = vid_cap.get(cv2.CAP_PROP_FPS)
|
193 |
-
h,w,_=img_det.shape
|
194 |
-
vid_writer = cv2.VideoWriter(save_path, cv2.VideoWriter_fourcc(*fourcc), fps, (w, h))
|
195 |
-
vid_writer.write(img_det)
|
196 |
-
|
197 |
-
else:
|
198 |
-
cv2.imshow('image', img_det)
|
199 |
-
cv2.waitKey(1) # 1 millisecond
|
200 |
im0 = img_det
|
201 |
print('Results saved to %s' % Path(opt.save_dir))
|
202 |
print('Done. (%.3fs)' % (time.time() - t0))
|
|
|
147 |
nms_time.update(t4-t3,img.size(0))
|
148 |
det=det_pred[0]
|
149 |
|
150 |
+
#save_path = str(save_dir +'/'+ 'img.jpg')
|
151 |
|
152 |
_, _, height, width = img.shape
|
153 |
h,w,_=img_det.shape
|
|
|
179 |
label_det_pred = f'{names[int(cls)]} {conf:.2f}'
|
180 |
plot_one_box(xyxy, img_det , label=label_det_pred, color=colors[int(cls)], line_thickness=2)
|
181 |
|
182 |
+
|
183 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
184 |
im0 = img_det
|
185 |
print('Results saved to %s' % Path(opt.save_dir))
|
186 |
print('Done. (%.3fs)' % (time.time() - t0))
|