使用 argparse 调试 python 脚本时,只需要把传入的参数写在 .vscode/launch.json 文件里:
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: 当前文件",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": true,
"args": [
// "-c","configs/cls/cls_mv3.yml",
// "Global.save_inference_dir=./inference/cls/",
// "Global.load_static_weights=False",
// "Global.infer_img=testdata/1-1.png"
// "--image_dir","testdata",
// "--cls_model_dir","inference/cls"
"--model_dir","inference/cls",
"--model_filename","inference.pdmodel",
"--params_filename","inference.pdiparams",
"--save_file","./inference/cls_onnx/model.onnx",
"--opset_version","11",
"--enable_onnx_checker","True",
]
}
]
}
例如下图,这个就等价于执行python脚本时的: --model_dir "inference/cls"