0

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()
Arsenal Fanatic
  • 3,663
  • 6
  • 38
  • 53
  • About your problem with pprint: You probably have ``import pprint`` in your py file. Either write ``from pprint import pprint`` or use ``pprint.pprint(...)`` - or correct me if I'm wrong about my ``import pprint`` assumption. – Mike Scotty May 11 '17 at 13:54
  • HI @mpf82 you were right about that. But I still can see the complete string. – Arsenal Fanatic May 11 '17 at 14:04
  • That looks like a complete file name. It has '..', meaning 'up-one-level', not an ellipsis. But you'll have to show us the code that generates the string, commandline and `add_argument` line if you want more help. – hpaulj May 11 '17 at 15:24
  • You can use `os.path.abspath` method to show absolute path of the file. If it's what you are asking for. `import os; print(os.path.abspath(args.networkModel))` – scriptmonster May 16 '17 at 13:49

0 Answers0