Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

An exception has occurred, use %tb to see the full traceback. SystemExit: 2

can anyone tell me how to make this code works in jupyter or any notebook enter image description here 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

like image 206
Shady Emad Avatar asked Sep 02 '25 10:09

Shady Emad


1 Answers

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.

like image 135
CB Acnt Avatar answered Sep 04 '25 01:09

CB Acnt