import subprocess # Define the path to the YOLOv5 directory yolov5_dir = r'D:\pythonProject1\yolov5' # Define the path to the weights file weights_path = r'D:\pythonProject1\yolov5\runs\train\exp4\weights\best.pt' # Set the confidence threshold confidence = '0.25' # Set the source to your ESP32-CAM stream URL source = 'http://192.168.43.156:81/stream' # Replace with your ESP32-CAM stream URL # Build the command to run the detection command = rf'python "{yolov5_dir}\detect.py" --weights "{weights_path}" --img 640 --conf {confidence} --source {source}' # Execute the command subprocess.run(command, shell=True, check=True)