Reputation: 23
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.
Upvotes: 0
Views: 904
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