ReDet icon indicating copy to clipboard operation
ReDet copied to clipboard

Training detector on specific categories

Open fadwaSAA opened this issue 4 years ago • 4 comments

Hello, Do you know how can i train a model on specific data categories from DOTA dataset? I want to train it on two categories only: large-vehicle and small-vehicle, i don't want the rest of categories. Thanks in advance..

fadwaSAA avatar Sep 20 '21 23:09 fadwaSAA

Assume you have downloaded DOTA dataset, you can remove annotations of these classes by writing a class-filtering script (i.e., remove lines containing these classes in dota/labelTxt/*.txt).

Then, you can use our script to prepare the dataset: https://github.com/csuhan/ReDet/blob/master/DOTA_devkit/prepare_dota1.py While, remember to change wordname: https://github.com/csuhan/ReDet/blob/0b9addf3c2734659fd6ffc7824f2e659fde4419c/DOTA_devkit/prepare_dota1.py#L10-L13

Then, change CLASSES in the dataset loader: https://github.com/csuhan/ReDet/blob/0b9addf3c2734659fd6ffc7824f2e659fde4419c/mmdet/datasets/DOTA.py#L4-L13

Finally, change the corresponding config file in configs/ReDet/*.py

csuhan avatar Sep 21 '21 16:09 csuhan

Thanks a lot! But after running the training file, i had the following error:

`Traceback (most recent call last): File "/home/fadwasa/anaconda3/envs/redet/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 724, in _try_get_data data = self._data_queue.get(timeout=timeout) File "/home/fadwasa/anaconda3/envs/redet/lib/python3.7/multiprocessing/queues.py", line 104, in get if not self._poll(timeout): File "/home/fadwasa/anaconda3/envs/redet/lib/python3.7/multiprocessing/connection.py", line 257, in poll return self._poll(timeout) File "/home/fadwasa/anaconda3/envs/redet/lib/python3.7/multiprocessing/connection.py", line 414, in _poll r = wait([self], timeout) File "/home/fadwasa/anaconda3/envs/redet/lib/python3.7/multiprocessing/connection.py", line 928, in wait return ready File "/home/fadwasa/anaconda3/envs/redet/lib/python3.7/selectors.py", line 203, in exit self.close() File "/home/fadwasa/anaconda3/envs/redet/lib/python3.7/site-packages/torch/utils/data/_utils/signal_handling.py", line 66, in handler _error_if_any_worker_fails() RuntimeError: DataLoader worker (pid 967102) is killed by signal: Killed.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "train.py", line 96, in main() File "train.py", line 92, in main logger=logger) File "/media/fadwasa/Untitled/ReDet/mmdet/apis/train.py", line 61, in train_detector _non_dist_train(model, dataset, cfg, validate=validate) File "/media/fadwasa/Untitled/ReDet/mmdet/apis/train.py", line 197, in _non_dist_train runner.run(data_loaders, cfg.workflow, cfg.total_epochs) File "/home/fadwasa/anaconda3/envs/redet/lib/python3.7/site-packages/mmcv-0.2.13-py3.7-linux-x86_64.egg/mmcv/runner/runner.py", line 358, in run epoch_runner(data_loaders[i], **kwargs) File "/home/fadwasa/anaconda3/envs/redet/lib/python3.7/site-packages/mmcv-0.2.13-py3.7-linux-x86_64.egg/mmcv/runner/runner.py", line 260, in train for i, data_batch in enumerate(data_loader): File "/home/fadwasa/anaconda3/envs/redet/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 804, in next idx, data = self._get_data() File "/home/fadwasa/anaconda3/envs/redet/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 771, in _get_data success, data = self._try_get_data() File "/home/fadwasa/anaconda3/envs/redet/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 737, in _try_get_data raise RuntimeError('DataLoader worker (pid(s) {}) exited unexpectedly'.format(pids_str)) ` It usually means that there is no enough memory but i have 1TB of free memory.

fadwaSAA avatar Sep 21 '21 23:09 fadwaSAA

Try to set workers_per_gpu=0

https://github.com/csuhan/ReDet/blob/0b9addf3c2734659fd6ffc7824f2e659fde4419c/configs/ReDet/ReDet_re50_refpn_1x_dota1.py#L143

csuhan avatar Sep 22 '21 01:09 csuhan

I tried this solution but with no luck. Shall the system be installed locally in my machine? it is installed in an external hard drive. I also work on the master branch.

fadwaSAA avatar Sep 22 '21 14:09 fadwaSAA