We are working on a project with my friend, but we still haven't gotten through a big problem. We tried many things but could not fix the problem. the problem is related to "argparse.ArgumentParser().
error part :
usage: detect_drowsiness.py [-h] -p SHAPE_PREDICTOR [-a ALARM] [-w WEBCAM]
detect_drowsiness.py: error: the following arguments are required: -p/--shape-predictor
codes part:
ap = argparse.ArgumentParser()
ap.add_argument("-p", "--shape-predictor", required=True,
help="path to facial landmark predictor")
ap.add_argument("-a", "--alarm", type=str, default="",
help="path alarm .WAV file")
ap.add_argument("-w", "--webcam", type=int, default=0,
help="index of webcam on system")
args = vars(ap.parse_args())
detector = dlib.get_frontal_face_detector()
predictor = dlib.shape_predictor(args["shape_predictor"])
file content: shape_predictor_68_face_landmarks.dat and detect_drowsiness.py(file name)
Why does this problem exist?
If you notice,
ap.add_argument("-p", "--shape-predictor", required=True,
help="path to facial landmark predictor")
-p/--shape-predictor argument is required. So, you should do the following when you run the python file:
python detect_drowsiness.py -p shape_predictor_68_face_landmarks.dat
or
python detect_drowsiness.py --shape-predictor shape_predictor_68_face_landmarks.dat
Related
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", required=True,
help="path to input image")
ap.add_argument("-d", "--dataset", required=True,
help="path to dataset")
ap.add_argument("-m", "--model", required=True,
help="path to Caffe pre-trained model")
ap.add_argument("-l", "--labels", required=True,
help="path to ImageNet labels (i.e., syn-sets)")
args = vars(ap.parse_args())
and I'm getting the output as
usage: train.py [-h] -i IMAGE -d DATASET -m MODEL -l LABELS
ipykernel_launcher.py: error: the following arguments are required: -i/--image, -p/--prototxt, -m/--model, -l/--labels.
An exception has occurred, use %tb to see the full traceback.
System Exit: 2
You have this error because you are running your script without passing the required parameters you defined.
You will not have the error if you run the script like this:
script_name.py -i image_path -d data_path -m model_path -l label_path
I'm new to work with python and i want to run this code , but get this error.
code:
# construct the argument parse and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-p", "--shape-predictor", required=True, help="path to facial landmark predictor")
ap.add_argument("-v", "--video", type=str, default="", help="path to input video file")
args = vars(ap.parse_args())
enter image description here
usage:
detect_blinks.py [-h] -p SHAPE_PREDICTOR
Error I'm Getting is:
the following arguments are required: -p/--shape-predictor
As the usage says, You need pass the necessary parameter -p/--shape-predictor.
you can just run this scripts as follows:
python detect_blinks.py -p my/path/to/predictor
I am following this tutorial and trying to run the below part of the script. I am using python 3.7 and spyder 3.3.4.
ap = argparse.ArgumentParser()
ap.add_argument("-d", "--dataset", required=True,
help="path to input dataset (i.e., directory of images)")
ap.add_argument("-m", "--model", required=True,
help="path to output model")
ap.add_argument("-l", "--labelbin", required=True,
help="path to output label binarizer")
ap.add_argument("-p", "--plot", type=str, default="plot.png",
help="path to output accuracy/loss plot")
args = vars(ap.parse_args())
I have tried going to Run > Configuration per file and entering the arguments as advised by this post and and this post.
command line options: path1, path2, path3, path4
I filled out the appropriate paths for the arguments above and then ran the script, but go the error below.
usage: train.py [-h] -d DATASET -m MODEL -l LABELBIN [-p PLOT]
train.py: error: the following arguments are required: -d/--dataset,
-m/--model, -l/--labelbin An exception has occurred, use %tb to see the full traceback.
SystemExit: 2
How can I fix this error to run my script appropriately and pass the arguments in spyder?
You can parse arguments by doing a special run from the settings and putting in the order that the arguments are expected.
I'm Using Raspberry pi 3 in opencv python environment but getting this error. Is there an app to open .xml and .dat file in raspberry pi 3?
: error: the following arguments are required: -c/--cascade, -p/--shape-predictor
ap = argparse.ArgumentParser()
ap.add_argument("-c", "--cascade", required=True, help = "path to where the face cascade resides")
ap.add_argument("-p", "--shape-predictor", required=True, help="path to facial landmark predictor")
ap.add_argument("-a", "--alarm", type=int, default=0, help="boolean used to indicate if TrafficHat should be used")
args = vars(ap.parse_args())
I need to view the complete string in the Argparse object args.networkModel
Original code is from https://github.com/cmusatyalab/openface/blob/master/demos/classifier.py
I only have access to the pdb in the terminal.
When I try the print(args.networkModel) I get
/home/aanilil/ml/openface/demos/../models/openargs.networkModelface/nn4.small2.v1.t7
Is there a way to Print the complete string?
I have also tried the pprint(args.networkModel)
Where I get the output
*** TypeError: 'module' object is not callable
The original parser is constructed like so
parser = argparse.ArgumentParser()
parser.add_argument(
'--dlibFacePredictor',
type=str,
help="Path to dlib's face predictor.",
default=os.path.join(
dlibModelDir,
"shape_predictor_68_face_landmarks.dat"))
parser.add_argument(
'--networkModel',
type=str,
help="Path to Torch network model.",
default=os.path.join(
openfaceModelDir,
'nn4.small2.v1.t7'))
parser.add_argument('--imgDim', type=int,
help="Default image dimension.", default=96)
parser.add_argument('--cuda', action='store_true')
parser.add_argument('--verbose', action='store_true')
subparsers = parser.add_subparsers(dest='mode', help="Mode")
trainParser = subparsers.add_parser('train',
help="Train a new classifier.")
trainParser.add_argument('--ldaDim', type=int, default=-1)
trainParser.add_argument(
'--classifier',
type=str,
choices=[
'LinearSvm',
'GridSearchSvm',
'GMM',
'RadialSvm',
'DecisionTree',
'GaussianNB',
'DBN'],
help='The type of classifier to use.',
default='LinearSvm')
trainParser.add_argument(
'workDir',
type=str,
help="The input work directory containing 'reps.csv' and 'labels.csv'. Obtained from aligning a directory with 'align-dlib' and getting the representations with 'batch-represent'.")
inferParser = subparsers.add_parser(
'infer', help='Predict who an image contains from a trained classifier.')
inferParser.add_argument(
'classifierModel',
type=str,
help='The Python pickle representing the classifier. This is NOT the Torch network model, which can be set with --networkModel.')
inferParser.add_argument('imgs', type=str, nargs='+',
help="Input image.")
inferParser.add_argument('--multi', help="Infer multiple faces in image",
action="store_true")
args = parser.parse_args()