0
votes

I'm trying to learn East Model for text recognition, I want to input different images to the code each time and trying argparse but is stuck.

How do we pass image path to (ap.add_argument("-i", '--image', type=str)

path is C:\Users\nishant\Desktop\Use_case\screenshot\hqdefault.png

import argparse

ap = argparse.ArgumentParser()

ap.add_argument("-i", '--image', type=str)

ap.add_argument("-east", "--east", type=str)

ap.add_argument("-c", "--min-confidence", type=float, default=0.5,)

ap.add_argument("-w", "--width", type=int, default=320)

ap.add_argument("-e", "--height", type=int, default=320)

ap.add_argument("-p", "--padding", type=float, default=0.0) args = vars(ap.parse_args())

usage: ipykernel_launcher.py [-h] [-i IMAGE] [-east EAST] [-c MIN_CONFIDENCE] [-w WIDTH] [-e HEIGHT] [-p PADDING] ipykernel_launcher.py: error: unrecognized arguments: -f C:\Users\777569\AppData\Roaming\jupyter\runtime\kernel-a0ced498-94e0-406e-9bf5-8f8c125ff96a.json

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

SystemExit: 2

1
How did you invoke this script. Looks like you are using a jupyter notebook (or console) The unrecocognized argument -f ... is meant for the laucher, not your code. You can't pass command line parameters to a script or notebook when run this way.hpaulj
yes, I'm using Jupyter notebook, so I need to do it using function definition or any other way is also there?Nishant

1 Answers

0
votes

I fixed mine by changing the last line, like this:

args = vars(ap.parse_args()) to  args = ap.parse_args(args=[])