yingkunwu / R-YOLOv4

This is a PyTorch-based R-YOLOv4 implementation which combines YOLOv4 model and loss function from R3Det for arbitrary oriented object detection.
114 stars 20 forks source link

multiple values for argument 'img_size' ["bug"] #64

Closed PrefectSol closed 10 months ago

PrefectSol commented 10 months ago

I'm running a training script:

python train.py --data ../dataset/dataset.yaml --config /home/prefect/Work/PalmDetector/Model/OBB/R-YOLOv4/data/hyp.yaml --img_size 640 --epochs 300

And I get the following:

Namespace(batch_size=4, config='/home/prefect/Work/PalmDetector/Model/OBB/R-YOLOv4/data/hyp.yaml', data='../dataset/dataset.yaml', epochs=300, img_size=640, lr=0.01, mode='csl', model_name='trash', optimizer='SGD', ver='yolov5', weights_path='')
2023-12-13 00:56:13 WARNING  Model name exists, do you want to override the previous model?
>> [Y:N]y
Traceback (most recent call last):
  File "train.py", line 266, in <module>
    t.train()
  File "train.py", line 145, in train
    train_dataset, train_dataloader = load_data(
  File "/home/prefect/Work/PalmDetector/Model/OBB/R-YOLOv4/lib/load.py", line 15, in load_data
    dataset = CustomDataset(data_dir, class_names, hyp, img_size=640, augment=augment, csl=csl)
TypeError: __init__() got multiple values for argument 'img_size'

Debugging the sources, I found the following: lib/load.py:

        dataset = CustomDataset(data_dir, class_names, hyp, img_size=img_size, augment=augment, csl=csl)

datasets/custom_dataset.py:

class CustomDataset(BaseDataset):
    def __init__(self, data_dir, img_size=416, augment=True, mosaic=True, multiscale=True, normalized_labels=False):

The arguments passed do not match the actual signature of the class constructor, which is why an error appears when learning on a custom dataset

I suspect that the same problem exists in the CustomDataset class with the hyp parameter

yingkunwu commented 10 months ago

Thank you for reporting this. We had refactored this repository a few months ago and it seems that the custom dataset was not being maintained at the time. We are looking to maintain this repository again in the following weeks and make sure everything will work at the time.

If you need to run it immediately, I would suggest you to look at UCASAOD_dataset.py and DOTA_dataset.py, which had been tested, to see how does it work properly. Otherwise, you can wait for us to fix it by the end of December.