Spaces:
No application file
No application file
Upload detection.py
Browse files- detection.py +19 -0
detection.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import subprocess
|
2 |
+
|
3 |
+
|
4 |
+
|
5 |
+
# Define the path to the YOLOv5 directory
|
6 |
+
yolov5_dir = r'D:\pythonProject1\yolov5'
|
7 |
+
# Define the path to the weights file
|
8 |
+
weights_path = r'D:\pythonProject1\yolov5\runs\train\exp4\weights\best.pt'
|
9 |
+
# Set the confidence threshold
|
10 |
+
confidence = '0.25'
|
11 |
+
# Set the source to your ESP32-CAM stream URL
|
12 |
+
source = 'http://192.168.43.156:81/stream' # Replace with your ESP32-CAM stream URL
|
13 |
+
|
14 |
+
# Build the command to run the detection
|
15 |
+
command = rf'python "{yolov5_dir}\detect.py" --weights "{weights_path}" --img 640 --conf {confidence} --source {source}'
|
16 |
+
|
17 |
+
|
18 |
+
# Execute the command
|
19 |
+
subprocess.run(command, shell=True, check=True)
|