import argparse
import numpy as np
import cv2
import os
import numpy.random as npr
from dface.core.utils import IoU
import dface.config as config def parse_args():
parser = argparse.ArgumentParser(description='Test mtcnn',
formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument('traindata_store', help='dface train data temporary folder,include 12,24,48/postive,negative,part,landmark',
default='../data/wider/', type=str)
parser.add_argument('traindata_store_plus', help='dface train data temporary folder,include 12,24,48/postive,negative,part,landmark',
default='../data/wider/', type=str)
parser.add_argument('--anno_file', dest='annotation_file', help='wider face original annotation file',
default=os.path.join(config.ANNO_STORE_DIR,"wider_origin_anno.txt"), type=str)
parser.add_argument('--prefix_path', dest='prefix_path', help='annotation file image prefix root path',
default='', type=str) args = parser.parse_args()
return args if __name__ == '__main__':
args = parse_args()
print(args)

  

命令行调用方式:

parser.add_argument('traindata_store',)这种形式前面没有--,就说明是必填项,在命令行中直接输入参数值即可

traindata_store_plus 与 traindata_store_plus 要按顺序填充。

(dface) MacBook-Pro:DFace sumeng$ python parse_test.py cc ff --a dd

Namespace(annotation_file='dd', prefix_path='', traindata_store='cc', traindata_store_plus='ff')

(dface) MacBook-Pro:DFace sumeng$ python parse_test.py ffv ccv --a dd

Namespace(annotation_file='dd', prefix_path='', traindata_store='ffv', traindata_store_plus='ccv')

  

对于参数前有--的,属于非必填项,填写的时候要  --anno_file 参数值   (中间有个空格)或者直接写 --a 参数值 或者 --ann 参数值 等

(dface) MacBook-Pro:DFace sumeng$ python parse_test.py cc --a dd

Namespace(annotation_file='dd', prefix_path='', traindata_store='cc')

  

Python-argparse-命令行与参数解析的更多相关文章

  1. python argparse命令行参数

    测试: 第一个没有任何输出和出错 第二个测试为打印帮助信息,argparse会自动生成帮助文档 第三个测试为未定义的-v参数,会出错 第四个测试为未定义的参数foo,出错 positional arg ...

  2. 【python】命令行解析工具argparse用法

    python的命令行参数 之前有用到optget, optparse, 现在这些都被弃用了. import argparse parser = argparse.ArgumentParser() ar ...

  3. Python的命令行参数(argparse)

    参考:https://www.cnblogs.com/lindaxin/p/7975697.html 参考:https://www.cnblogs.com/dengtou/p/8413609.html ...

  4. python 处理命令行参数--转载

    标题写了那么久,现在现在才有时间,整理下自己的思路.首先先总结下自己对sys模块的理解.手册上对sys的描述是系统参数和系统函数,这里的系统实际上是python解释器.这个模块提供了用户可以访问的解释 ...

  5. Python模块: 命令行解析optionparser

    Python 有两个内建的模块用于处理命令行参数:一个是 getopt,<Deep in python>一书中也有提到,只能简单处理 命令行参数:另一个是 optparse,它功能强大,而 ...

  6. python命令行获取参数

    python命令行获取参数 import sys # python获取参数 input_file = sys.argv[1] output_file = sys.argv[2] print(input ...

  7. python制作命令行工具——fire

    python制作命令行工具--fire 前言 本篇教程的目的是希望大家可以通读完此篇之后,可以使用python制作一款符合自己需求的linux工具. 本教程使用的是google开源的python第三方 ...

  8. 基于Python与命令行人脸识别项目(系列一)

    Face Recognition 人脸识别 摘要:本项目face_recognition是一个强大.简单.易上手的人脸识别开源项目,并且配备了完整的开发文档和应用案例,方便大家使用.对于本项目可以使用 ...

  9. 在VS中向命令行添加参数的方法

    在VS中向命令行添加参数的方法 在VS中向命令行添加参数,即向main()函数传递参数的方法: 右键单击要 添加参数的工程-->属性-->配置属性-->调试,在右侧“命令参数”栏输入 ...

  10. Shell Scipt 命令行带参数,输出log

    命令行带参数,以及字符串参数放到ssh命令里可以这么放: #!/bin/bash        这行保证运行bash可以这样: ./data.sh if [ $# != 4 ]; then echo ...

随机推荐

  1. 【cb2】安装终端

    虽然xterm轻量,但用起来不爽. sudo apt-get install terminator 其它安装 sudo apt-get install spyder sudo apt-get inst ...

  2. ConfigParser 读写配置文件

    一.ini: 1..ini 文件是Initialization File的缩写,即初始化文件,是windows的系统配置文件所采用的存储格式 2.ini文件创建方法: (1)先建立一个记事本文件.(2 ...

  3. Python3x 爬取妹子图

    思路:1.get_totalpages(url)  通过[性.感.美.女.图]获得该版块的总页数 [首页1234567891011下一页末页共 21页1034条] 2.get_sercoverurl( ...

  4. Hibernate_day01--课程安排_Hibernate概述_Hibernate入门

    Hibernate_day01 Hibernate课程安排 今天内容介绍 WEB内容回顾 JavaEE三层结构 MVC思想 Hibernate概述 什么是框架 什么是hibernate框架(重点) 什 ...

  5. 修改tomcat配置通过域名直接访问项目首页

    1.在自己项目的web.xml中配置欢迎页面 <welcome-file-list> <welcome-file>index.html</welcome-file> ...

  6. Linux命令之乐--read

    read 命令从标准输入中读取一行,并把输入行的每个字段的值指定给 shell 变量 -p:后接屏幕输出的提示语句 -n:设定输入的字符个数,当达到指定的个数则自动退出,并将输入赋予给变量 -t:当输 ...

  7. 160304-01、mysql数据库插入速度和读取速度的调整记录

    需求:由于项目变态,需要在一个比较短时间段急剧增加数据库记录(两三天内,由于0增加至5亿).在整个过程调优过程非常艰辛 思路: (1)提高数据库插入性能中心思想:尽量将数据一次性写入到Data Fil ...

  8. HDU 2665 Kth number(可持续化线段树)

    Kth number Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Tota ...

  9. HDU3342有向图判圈DFS&&拓扑排序法

    HDU3342 Legal or Not 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3342 题目意思:一群大牛互相问问题,大牛有不会的,会被更厉害 ...

  10. python3在centos6.6上的安装

    建议:在看这个文档操作前,最好先参考一下这个:https://www.cnblogs.com/bookwed/p/10251236.html,是解决pip安装模块时,提示ssl版本低的问题. #提前的 ...