John Tharian
John Tharian

Reputation: 23

Error while running subprocess to run yolov5 detect.py file

I need to run detect.py file to detect objects from images in a folder from a python script. When I try running the script I keep getting this pickle invalid load error.

import os
import subprocess


img_fdr="./img"
weights_fdr="/runs/train/exp7/weights/best.pt"

subprocess.run(["python3","detect.py","--weights",weights_fdr,"--source",img_fdr])

I tried several ways of passing the arguments , still I keep getting the same error.

error message

Upvotes: 0

Views: 904

Answers (1)

gerda die gandalfziege
gerda die gandalfziege

Reputation: 762

This line

subprocess.run(["python3","detect.py","--weights",weights_fdr,"--source",img_fdr])

should look like this:

subprocess.run(f"python3 detect.py --weights {weights_fdr} --source {img_fdr}")

Upvotes: 1

Related Questions