diff --git a/model_zoo/research/cv/ssd_resnet50/README.md b/model_zoo/research/cv/ssd_resnet50/README.md index 675b833517e..def4d8812bb 100644 --- a/model_zoo/research/cv/ssd_resnet50/README.md +++ b/model_zoo/research/cv/ssd_resnet50/README.md @@ -300,7 +300,7 @@ Current batch_ Size can only be set to 1. ```shell # Ascend310 inference -bash run_infer_310.sh [MINDIR_PATH] [DATA_PATH] [DVPP] [DEVICE_ID] +bash run_infer_310.sh [MINDIR_PATH] [DATA_PATH] [DVPP] [ANNO_FILE] [DEVICE_ID] ``` Inference result will be stored in the example path, you can find result like the followings in acc.log. diff --git a/model_zoo/research/cv/ssd_resnet50/README_CN.md b/model_zoo/research/cv/ssd_resnet50/README_CN.md index 6af9c59bfea..d4ae9f07fcf 100644 --- a/model_zoo/research/cv/ssd_resnet50/README_CN.md +++ b/model_zoo/research/cv/ssd_resnet50/README_CN.md @@ -256,6 +256,13 @@ python export.py --ckpt_file [CKPT_PATH] --device_target [DEVICE_TARGET] --file_ 在还行推理之前我们需要先导出模型。Air模型只能在昇腾910环境上导出,mindir可以在任意环境上导出。batch_size只支持1。 +```shell +# Ascend310 inference +bash run_infer_310.sh [MINDIR_PATH] [DATA_PATH] [DVPP] [ANNO_FILE] [DEVICE_ID] +``` + +推理结果被保存到了当前目录,可以在acc.log中获得类似下面的结果。 + ```shell Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.327 Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.475 diff --git a/model_zoo/research/cv/ssd_resnet50/postprocess.py b/model_zoo/research/cv/ssd_resnet50/postprocess.py index f64e7dfe5fe..3639e32504c 100644 --- a/model_zoo/research/cv/ssd_resnet50/postprocess.py +++ b/model_zoo/research/cv/ssd_resnet50/postprocess.py @@ -25,6 +25,7 @@ batch_size = 1 parser = argparse.ArgumentParser(description="ssd acc calculation") parser.add_argument("--result_path", type=str, required=True, help="result files path.") parser.add_argument("--img_path", type=str, required=True, help="image file path.") +parser.add_argument("--anno_file", type=str, required=True, help="annotation file.") parser.add_argument("--drop", action="store_true", help="drop iscrowd images or not.") args = parser.parse_args() @@ -34,15 +35,13 @@ def get_imgSize(file_name): def get_result(result_path, img_id_file_path): """print the mAP""" - anno_json = os.path.join(config.coco_root, config.instances_set.format(config.val_data_type)) - if args.drop: from pycocotools.coco import COCO train_cls = config.classes train_cls_dict = {} for i, cls in enumerate(train_cls): train_cls_dict[cls] = i - coco = COCO(anno_json) + coco = COCO(args.anno_file) classs_dict = {} cat_ids = coco.loadCats(coco.getCatIds()) for cat in cat_ids: @@ -83,7 +82,7 @@ def get_result(result_path, img_id_file_path): "img_id": img_id, "image_shape": image_shape }) - mAP = metrics(pred_data, anno_json) + mAP = metrics(pred_data, args.anno_file) print(f" mAP:{mAP}") if __name__ == '__main__': diff --git a/model_zoo/research/cv/ssd_resnet50/scripts/run_infer_310.sh b/model_zoo/research/cv/ssd_resnet50/scripts/run_infer_310.sh index 8ded49b627b..808468ad82d 100644 --- a/model_zoo/research/cv/ssd_resnet50/scripts/run_infer_310.sh +++ b/model_zoo/research/cv/ssd_resnet50/scripts/run_infer_310.sh @@ -14,9 +14,10 @@ # limitations under the License. # ============================================================================ -if [[ $# -lt 3 || $# -gt 4 ]]; then - echo "Usage: bash run_infer_310.sh [MINDIR_PATH] [DATA_PATH] [DVPP] [DEVICE_ID] +if [[ $# -lt 4 || $# -gt 5 ]]; then + echo "Usage: bash run_infer_310.sh [MINDIR_PATH] [DATA_PATH] [DVPP] [ANNO_FILE] [DEVICE_ID] DVPP is mandatory, and must choose from [DVPP|CPU], it's case-insensitive + ANNO_PATH is mandatory, and should specify annotation file path of your data including file name. DEVICE_ID is optional, it can be set by environment variable device_id, otherwise the value is zero" exit 1 fi @@ -31,15 +32,17 @@ get_real_path(){ model=$(get_real_path $1) data_path=$(get_real_path $2) DVPP=${3^^} +anno=$(get_real_path $4) device_id=0 -if [ $# == 4 ]; then - device_id=$4 +if [ $# == 5 ]; then + device_id=$5 fi echo "mindir name: "$model echo "dataset path: "$data_path echo "image process mode: "$DVPP +echo "anno file: "$anno echo "device id: "$device_id export ASCEND_HOME=/usr/local/Ascend/ @@ -85,7 +88,7 @@ function infer() function cal_acc() { - python3.7 ../postprocess.py --result_path=./result_Files --img_path=$data_path --drop &> acc.log & + python3.7 ../postprocess.py --result_path=./result_Files --img_path=$data_path --anno_file=$anno --drop &> acc.log & } compile_app