Spaces:
Runtime error
Runtime error
fix error when no detection
Browse files
app.py
CHANGED
@@ -97,7 +97,7 @@ def processVideo(inputPath, model):
|
|
97 |
# 获取每一帧的目标检测推理结果
|
98 |
results = model(frame, stream=True)
|
99 |
|
100 |
-
detections =
|
101 |
confarray = [] # 存放每个检测结果的置信度
|
102 |
|
103 |
# 读取目标检测推理结果
|
@@ -110,11 +110,11 @@ def processVideo(inputPath, model):
|
|
110 |
cls = int(box.cls[0]) # 获取物体类别标签
|
111 |
|
112 |
if cls == detect_class:
|
113 |
-
detections.
|
114 |
confarray.append(conf)
|
115 |
|
116 |
# 使用deepsort进行跟踪
|
117 |
-
resultsTracker = tracker.update(
|
118 |
for x1, y1, x2, y2, Id in resultsTracker:
|
119 |
x1, y1, x2, y2 = map(int, [x1, y1, x2, y2])
|
120 |
|
@@ -162,4 +162,4 @@ if __name__ == "__main__":
|
|
162 |
processVideo, inputs=[input_video, model], outputs=[output, output_path]
|
163 |
)
|
164 |
|
165 |
-
demo.launch()
|
|
|
97 |
# 获取每一帧的目标检测推理结果
|
98 |
results = model(frame, stream=True)
|
99 |
|
100 |
+
detections = np.empty((0, 4)) # 存放bounding box结果
|
101 |
confarray = [] # 存放每个检测结果的置信度
|
102 |
|
103 |
# 读取目标检测推理结果
|
|
|
110 |
cls = int(box.cls[0]) # 获取物体类别标签
|
111 |
|
112 |
if cls == detect_class:
|
113 |
+
detections = np.vstack((detections,np.array([x1,y1,x2,y2])))
|
114 |
confarray.append(conf)
|
115 |
|
116 |
# 使用deepsort进行跟踪
|
117 |
+
resultsTracker = tracker.update(detections, confarray, frame)
|
118 |
for x1, y1, x2, y2, Id in resultsTracker:
|
119 |
x1, y1, x2, y2 = map(int, [x1, y1, x2, y2])
|
120 |
|
|
|
162 |
processVideo, inputs=[input_video, model], outputs=[output, output_path]
|
163 |
)
|
164 |
|
165 |
+
demo.launch(server_port=6006)
|
main.py
CHANGED
@@ -63,7 +63,7 @@ def processVideo(inputPath: str) -> Path:
|
|
63 |
# 获取每一帧的目标检测推理结果
|
64 |
results = model(frame, stream=True)
|
65 |
|
66 |
-
detections =
|
67 |
confarray = [] # 存放每个检测结果的置信度
|
68 |
|
69 |
# 读取目标检测推理结果
|
@@ -76,11 +76,11 @@ def processVideo(inputPath: str) -> Path:
|
|
76 |
cls = int(box.cls[0]) # 获取物体类别标签
|
77 |
|
78 |
if cls == detect_class:
|
79 |
-
detections.
|
80 |
confarray.append(conf)
|
81 |
|
82 |
# 使用deepsort进行跟踪
|
83 |
-
resultsTracker = tracker.update(
|
84 |
for x1, y1, x2, y2, Id in resultsTracker:
|
85 |
x1, y1, x2, y2 = map(int, [x1, y1, x2, y2])
|
86 |
|
|
|
63 |
# 获取每一帧的目标检测推理结果
|
64 |
results = model(frame, stream=True)
|
65 |
|
66 |
+
detections = np.empty((0, 4)) # 存放bounding box结果
|
67 |
confarray = [] # 存放每个检测结果的置信度
|
68 |
|
69 |
# 读取目标检测推理结果
|
|
|
76 |
cls = int(box.cls[0]) # 获取物体类别标签
|
77 |
|
78 |
if cls == detect_class:
|
79 |
+
detections = np.vstack((detections,np.array([x1,y1,x2,y2])))
|
80 |
confarray.append(conf)
|
81 |
|
82 |
# 使用deepsort进行跟踪
|
83 |
+
resultsTracker = tracker.update(detections, confarray, frame)
|
84 |
for x1, y1, x2, y2, Id in resultsTracker:
|
85 |
x1, y1, x2, y2 = map(int, [x1, y1, x2, y2])
|
86 |
|