0

我需要查看 Argparse 对象中的完整字符串args.networkModel 原始代码来自https://github.com/cmusatyalab/openface/blob/master/demos/classifier.py

我只能访问终端中的 pdb。当我尝试时,print(args.networkModel)我得到

/home/aanilil/ml/openface/demos/../models/openargs.networkModelface/nn4.small2.v1.t7

有没有办法打印完整的字符串?

我也尝试过我在pprint(args.networkModel) 哪里得到输出

*** TypeError: 'module' object is not callable

原来的解析器是这样构造的

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()
4

0 回答 0