PaddlePaddle / PaddleDetection

Object Detection toolkit based on PaddlePaddle. It supports object detection, instance segmentation, multiple object tracking and real-time multi-person keypoint detection.
Apache License 2.0
12.81k stars 2.89k forks source link

Issue while executing "python tools/infer.py" #9130

Closed Kannan665 closed 2 months ago

Kannan665 commented 2 months ago

问题确认 Search before asking

请提出你的问题 Please ask your question

I checked the repository, and I could see “similar” issues, but I could not see a “solution” to the “issue” I am facing currently....,

OS : Ubuntu 18.04 LTS Environment : Docker # The docker image, which I pulled from Docker hub “paddlecloud/paddledetection:2.4-gpu-cuda11.2-cudnn8-latest”

I have successfully trained a PP-YoloE model...,

Below is the “training” script, I had used....,

python tools/train.py -c /var/lib/kannan/PaddleDetection/configs/ppyoloe/voc/ppyoloe_plus_crn_s_30e_voc_v2.yml \ --eval \ --use_vdl=True \ --vdl_log_dir="/var/lib/kannan/PaddleDetection/output/ppyoloe_plus_crn_s_30e_voc_v2"

This is the last “evaluation_step” output which I had observed in my Docker_terminal...,

[09/04 12:30:03] ppdet.utils.checkpoint INFO: Save checkpoint: output [09/04 12:30:03] ppdet.engine INFO: Eval iter: 0 [09/04 12:30:10] ppdet.engine INFO: Eval iter: 100 [09/04 12:30:17] ppdet.engine INFO: Eval iter: 200 [09/04 12:30:24] ppdet.engine INFO: Eval iter: 300 [09/04 12:30:31] ppdet.engine INFO: Eval iter: 400 [09/04 12:30:38] ppdet.engine INFO: Eval iter: 500 [09/04 12:30:45] ppdet.engine INFO: Eval iter: 600 [09/04 12:30:48] ppdet.metrics.metrics INFO: Accumulating evaluatation results... [09/04 12:30:49] ppdet.metrics.metrics INFO: mAP(0.50, 11point) = 67.25% [09/04 12:30:49] ppdet.engine INFO: Total sample number: 2587, average FPS: 57.0754026837315 [09/04 12:30:49] ppdet.engine INFO: Best test bbox ap is 0.673. [09/04 12:30:49] ppdet.utils.checkpoint INFO: Save checkpoint: output

I was able to “observe” the training and evaluation metric, by using “visualdl” also.....

I was able to individually run the “evaluation” script also, and below is the script, I had used...,

python -u tools/eval.py -c /var/lib/kannan/PaddleDetection/configs/ppyoloe/voc/ppyoloe_plus_crn_s_30e_voc_v2.yml \ -o weights=/var/lib/kannan/PaddleDetection/output/model_final.pdparams

So far, so good.....But when I try to run “inference” script as below.,

python tools/infer.py -c /var/lib/kannan/PaddleDetection/configs/ppyoloe/voc/ppyoloe_plus_crn_s_30e_voc_v2.yml \ --infer_dir=/var/lib/kannan/n300_pp_yolo/objects_in_val \ --output_dir=/var/lib/kannan/PaddleDetection/output/infer_output/ \ --draw_threshold=0.5 \ -o weights=/var/lib/kannan/PaddleDetection/output/model_final.pdparams \ --use_vdl=True \ --save_results=True

I get to see the error as below.,

grep: warning: GREP_OPTIONS is deprecated; please use an alias or script /usr/local/lib/python3.7/dist-packages/pkg_resources/init.py:121: DeprecationWarning: pkg_resources is deprecated as an API warnings.warn("pkg_resources is deprecated as an API", DeprecationWarning) /usr/local/lib/python3.7/dist-packages/pkg_resources/init.py:2870: DeprecationWarning: Deprecated call to pkg_resources.declare_namespace('mpl_toolkits'). Implementing implicit namespace packages (as specified in PEP 420) is preferred to pkg_resources.declare_namespace. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages declare_namespace(pkg) /usr/local/lib/python3.7/dist-packages/pkg_resources/init.py:2870: DeprecationWarning: Deprecated call to pkg_resources.declare_namespace('google'). Implementing implicit namespace packages (as specified in PEP 420) is preferred to pkg_resources.declare_namespace. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages declare_namespace(pkg) /usr/local/lib/python3.7/dist-packages/pkg_resources/init.py:2870: DeprecationWarning: Deprecated call to pkg_resources.declare_namespace('zope'). Implementing implicit namespace packages (as specified in PEP 420) is preferred to pkg_resources.declare_namespace. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages declare_namespace(pkg) Warning: import ppdet from source directory without installing, run 'python setup.py install' to install ppdet firstly W0904 20:32:58.009069 277 gpu_context.cc:278] Please NOTE: device: 0, GPU Compute Capability: 8.6, Driver API Version: 12.3, Runtime API Version: 11.2 W0904 20:32:58.010911 277 gpu_context.cc:306] device: 0, cuDNN Version: 8.1. [09/04 20:33:00] ppdet.utils.checkpoint INFO: Finish loading model weights: /var/lib/kannan/PaddleDetection/output/model_final.pdparams [09/04 20:33:00] train INFO: Found 2589 inference images in total. 0%| | 0/2589 [00:00<?, ?it/s] Traceback (most recent call last): File "tools/infer.py", line 237, in main() File "tools/infer.py", line 233, in main run(FLAGS, cfg) File "tools/infer.py", line 188, in run visualize=FLAGS.visualize) File "/var/lib/kannan/PaddleDetection/ppdet/engine/trainer.py", line 1026, in predict outs = self.model(data) File "/usr/local/lib/python3.7/dist-packages/paddle/fluid/dygraph/layers.py", line 930, in call return self._dygraph_call_func(*inputs, kwargs) File "/usr/local/lib/python3.7/dist-packages/paddle/fluid/dygraph/layers.py", line 915, in _dygraph_call_func outputs = self.forward(*inputs, *kwargs) File "/var/lib/kannan/PaddleDetection/ppdet/modeling/architectures/meta_arch.py", line 76, in forward outs.append(self.get_pred()) File "/var/lib/kannan/PaddleDetection/ppdet/modeling/architectures/yolo.py", line 150, in get_pred return self._forward() File "/var/lib/kannan/PaddleDetection/ppdet/modeling/architectures/yolo.py", line 81, in _forward body_feats = self.backbone(self.inputs) File "/usr/local/lib/python3.7/dist-packages/paddle/fluid/dygraph/layers.py", line 930, in call return self._dygraph_call_func(inputs, kwargs) File "/usr/local/lib/python3.7/dist-packages/paddle/fluid/dygraph/layers.py", line 915, in _dygraph_call_func outputs = self.forward(*inputs, **kwargs) File "/var/lib/kannan/PaddleDetection/ppdet/modeling/backbones/cspresnet.py", line 301, in forward x = inputs['image'] KeyError: 'image'

And given below is my “voc.yml” file.....,

metric: VOC map_type: 11point num_classes: 1

TrainDataset: name: VOCDataSet dataset_dir: /var/lib/kannan/n300_pp_yolo/train anno_path: /var/lib/kannan/n300_pp_yolo/image_label_paths_train.txt label_list: /var/lib/kannan/n300_pp_yolo/label_list.txt data_fields: ['image', 'gt_bbox', 'gt_class', 'difficult']

EvalDataset: name: VOCDataSet dataset_dir: /var/lib/kannan/n300_pp_yolo/val anno_path: /var/lib/kannan/n300_pp_yolo/image_label_paths_val.txt label_list: /var/lib/kannan/n300_pp_yolo/label_list.txt data_fields: ['image', 'gt_bbox', 'gt_class', 'difficult']

TestDataset: name: ImageFolder dataset_dir: /var/lib/kannan/n300_pp_yolo/val anno_path: /var/lib/kannan/n300_pp_yolo/image_label_paths_val.txt label_list: /var/lib/kannan/n300_pp_yolo/label_list.txt data_fields: ['image', 'gt_bbox', 'gt_class', 'difficult']

My dataset is a custom dataset of a very large and diversified X-ray Radiography Images.....

I am not able to identify the “bug” in the above experiment and eagerly looking for insights/feedback from PaddlePaddle native developers.....

Thanks in Advance....

liu-jiaxuan commented 2 months ago

Hi, the error that occurs is that the image was not successfully load in, while the config file you are using appears to be correct. Please try again with a different dataset to check if the problem is with the dataset.

Kannan665 commented 2 months ago

Yes, as you said, it seems that "load_in" is the issue....I will follow this "PrepareDetDataSet_en.md" and in that "User Data" and "Convert User Data to VOC Data".....I will follow the process steps as per the instructions and try again.....I will use this "Example of User Data Conversion Take Kaggle Dataset competition data as an example to illustrate how to prepare custom data. The dataset of Kaggle road-sign-detection competition contains 877 images, four categories:crosswalk,speedlimit,stop,trafficlight. Available for download from kaggle, also available from link.

I will get back, if I still get the same issue.....

liu-jiaxuan commented 2 months ago

OK!