Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
|
2 |
import cv2
|
3 |
import gradio as gr
|
@@ -189,7 +206,7 @@ def process_video(confidence_threshold=0.5, selected_classes=None, stream_url=No
|
|
189 |
|
190 |
model = YOLO(model="yolo11n.pt")
|
191 |
crossed_objects = {}
|
192 |
-
max_tracked_objects =
|
193 |
|
194 |
logger.info("Starting to process the stream...")
|
195 |
while cap.isOpened():
|
@@ -199,7 +216,7 @@ def process_video(confidence_threshold=0.5, selected_classes=None, stream_url=No
|
|
199 |
break
|
200 |
|
201 |
# Perform object tracking with confidence threshold
|
202 |
-
results = model.track(frame, persist=True, conf=confidence_threshold)
|
203 |
|
204 |
if results[0].boxes.id is not None:
|
205 |
track_ids = results[0].boxes.id.int().cpu().tolist()
|
|
|
1 |
+
##############
|
2 |
+
|
3 |
+
#Maximize CPU usage
|
4 |
+
import multiprocessing
|
5 |
+
import cv2
|
6 |
+
|
7 |
+
# Get the number of CPU cores
|
8 |
+
cpu_cores = multiprocessing.cpu_count()
|
9 |
+
|
10 |
+
# Set OpenCV to use all available cores
|
11 |
+
cv2.setNumThreads(cpu_cores)
|
12 |
+
|
13 |
+
# Print the number of threads being used (optional)
|
14 |
+
print(f"OpenCV using {cv2.getNumThreads()} threads out of {cpu_cores} available cores")
|
15 |
+
|
16 |
+
##############
|
17 |
+
|
18 |
|
19 |
import cv2
|
20 |
import gradio as gr
|
|
|
206 |
|
207 |
model = YOLO(model="yolo11n.pt")
|
208 |
crossed_objects = {}
|
209 |
+
max_tracked_objects = 100 # Maximum number of objects to track before clearing
|
210 |
|
211 |
logger.info("Starting to process the stream...")
|
212 |
while cap.isOpened():
|
|
|
216 |
break
|
217 |
|
218 |
# Perform object tracking with confidence threshold
|
219 |
+
results = model.track(frame, persist=True, conf=confidence_threshold,iou=0.5,max_det=50,verbose=False)
|
220 |
|
221 |
if results[0].boxes.id is not None:
|
222 |
track_ids = results[0].boxes.id.int().cpu().tolist()
|