Search code examples
pythonargparse

error: the following arguments are required: -a/--az, -m/--model


So I'm following this tutorial https://www.pyimagesearch.com/2020/08/17/ocr-with-keras-tensorflow-and-deep-learning/ The problem is that when I run my code, the training file for the OCR that I'm creating this error appears. enter image description here

I don't know why this happen, this is the code that is showing the error

ap = argparse.ArgumentParser()
ap.add_argument("-a", "--az", required=True, help="path to A-Z dataset")
ap.add_argument("-m", "--model", type=str, required=True, help="path to output trained 
handwritten recognition model")
ap.add_argument("-p", "--plot", type=str, 
default="C:/Users/berna/Desktop/Programming/AI_ML_DL/Projects/OCRApp_phototext/plot.png", 
help="path to output training history file")
args = vars(ap.parse_args())

Any idea?


Solution

  • Since the program uses ArgumentParser you need to pass arguments when running it, simply typing python train_ocr_model.py won't do it, after tying the file name you need to add the missing parameters it is asking for like -a, here is an example:

    python train_ocr_model.py --az a_z_handwritten_data.csv --model handwriting.model
    

    The help parameter tells you what each argument needs as input.