jbwang1997 / OBBDetection

OBBDetection is an oriented object detection library, which is based on MMdetection.
Apache License 2.0
537 stars 113 forks source link

How to improve FPS for OBB detection on customized dataset ? #50

Closed starlord93 closed 2 years ago

starlord93 commented 2 years ago

Hi Wang, I tried three different OBB models (gliding_vertex_r50_fpn_1x, faster_rcnn_orpn_r50_fpn_1x and retinanet_obb_r50_fpn_1x) on customized dataset adapted from PCB Dataset. In average, the mAP scores are ~90% for all 3 models.However, the FPS or tasks/seconds is only ~3. The test images are resized to 1024*1024 and the FPS data were obtained from tools/test.py (I believe is only single_gpu_testing).

One of the result obtained on test images: [>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] 75/75, 2.7 task/s, elapsed: 28s, ETA: 0s +-------+-----+------+--------+--------+ | class | gts | dets | recall | ap | +-------+-----+------+--------+--------+ | ic | 729 | 946 | 0.9767 | 0.8992 | +-------+-----+------+--------+--------+ | mAP | | | | 0.8992 | +-------+-----+------+--------+--------+

I did not split the images during train & test. Can splitting improve the FPS ? Or multi GPU can improve the FPS ?

I attached some files for more details of my pipelines and models. Looking forward to your reply. Thanks pcb.txt gliding_vertex_r50_fpn_1x_pcb.txt

jbwang1997 commented 2 years ago

The multi GPU testing can improve the FPS. Also, you can also resize images to a smaller size like 600 600. The 1024 1024 image may be a little big.

wkmwkm93 commented 2 years ago

I see. Is there any guide how to edit the tools/dist_test.sh file ? Does it mean that training images also need to be the same size as testing image sizes ?

jbwang1997 commented 2 years ago

dist_test.sh also runs the test.py. So you can edit the test.py for your task.

Yes, the training images and testing images should be the same size.

wkmwkm93 commented 2 years ago

I got this error when I executed: %run tools/test.py configs/obb/gliding_vertex/gliding_vertex_r50_fpn_1x_pcb.py gv_eval_output/epoch_11.pth --eval mAP --launcher pytorch

/usr/local/lib/python3.7/dist-packages/mmcv/runner/dist_utils.py in init_dist(launcher, backend, kwargs) 15 mp.set_start_method('spawn') 16 if launcher == 'pytorch': ---> 17 _init_dist_pytorch(backend, kwargs) 18 elif launcher == 'mpi': 19 _init_dist_mpi(backend, **kwargs)

/usr/local/lib/python3.7/dist-packages/mmcv/runner/dist_utils.py in _init_dist_pytorch(backend, kwargs) 26 def _init_dist_pytorch(backend, kwargs): 27 # TODO: use local_rank instead of rank % num_gpus ---> 28 rank = int(os.environ['RANK']) 29 num_gpus = torch.cuda.device_count() 30 torch.cuda.set_device(rank % num_gpus)

/usr/lib/python3.7/os.py in getitem(self, key) 679 except KeyError: 680 # raise KeyError with the original key value --> 681 raise KeyError(key) from None 682 return self.decodevalue(value) 683

KeyError: 'RANK'