1

I've been trying to parse arguments on the command line. In the code which I've been trying to run.

ap = argparse.ArgumentParser()
ap.add_argument("-p", "--prototxt ", required=True,
    help="path to Caffe 'deploy' prototxt file")
ap.add_argument("-m", "--model", required=True,
    help="path to Caffe pre-trained model")

So, I go to that directory using cd then, I've tried

python people_counter.py --prototxt C:\Users\mustafa\Downloads\people-counting-opencv\people-counting-opencv\mobilenet_ssd --model C:\Users\mustafa\Downloads\people-counting-opencv\people-counting-opencv\mobilenet_ssd

And here is the error message:

[INFO] loading model...
Traceback (most recent call last):
  File "people_counter.py", line 49, in <module>
    net = cv2.dnn.readNetFromCaffe(args["prototxt"], args["model"])
KeyError: 'prototxt'

I am sure that both paths are true. paths EDIT: I've seen that I had defined prototxt with space. So I removed it.

Mustafa
  • 117
  • 1
  • 9
  • 1
    It might be the extra space you have in `"--prototxt "`. – Daniel Geffen Apr 04 '20 at 13:21
  • Does this answer your question? [Parsing command line arguments in Python: getting a KeyError](https://stackoverflow.com/questions/7395488/parsing-command-line-arguments-in-python-getting-a-keyerror) – Joshua Varghese Apr 04 '20 at 13:22
  • 2
    I think you mean `args.prototxt` but you also should remove the space from `"--prototxt "`. – khelwood Apr 04 '20 at 13:25

0 Answers0