can anyone tell me how to make this code works in jupyter or any notebook
Code
import argparse
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", required=True, help="path to input image")
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")
ap.add_argument("-c", "--confidence", type=float, default=0.2, help="minimum probability to filter weak detections")
args = vars(ap.parse_args())
Error
An exception has occurred, use %tb to see the full traceback.
SystemExit: 2
I've tried some solutions but none work
You just need to change "required=True" to "required=False" and add default path in your code to works in jupyter or any notebook.
Also need to add "ap.add_argument("-f", required=False)" in the end of line.
In your case code will work like this:
import argparse
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", required=False, default="/content/your_image.jpg", help="path to input image")
ap.add_argument("-p", "--prototxt", required=False, default="/content/your_prototxt.txt", help="path to Caffe 'deploy' prototxt file")
ap.add_argument("-m", "--model", required=False, default="/content/your_model.caffemodel", help="path to Caffe pre-trained model")
ap.add_argument("-c", "--confidence", type=float, default=0.2, help="minimum probability to filter weak detections")
ap.add_argument("-f", required=False)
args = vars(ap.parse_args())
Be sure to change default path with your own file path.
Worked in Google Colab notebook.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With