jbwang1997/OBBDetection

how to use obbdetection api for training

hbakrim opened this issue · 0 comments

I try to use the api of obbdetection for training (as used in mmdetection) but I got this error: TypeError: myRegister: init() got an unexpected keyword argument 'task'
Here my script for for configuration and training:
#################################################################
def configuration():

backbone = 'obb/oriented_rcnn/faster_rcnn_orpn_r50_fpn_1x_dota10.py'
weight = 'faster_rcnn_orpn_r50_fpn_1x_dota10_epoch12.pth'

cfg = Config.fromfile(f"{root}/OBBDetection/configs/{backbone}")

cfg.load_from = f"{root}/OBBDetection/ckpt/{weight}"



# Modify dataset type and path
cfg.dataset_type = 'myDataLoader'
cfg.data_root = ''

cfg.data.train.type = 'myRegister'
cfg.data.train.data_root = ''
cfg.data.train.ann_file = f'{annotations_dir}/train_dicts_roof_plan.json'   
cfg.data.train.img_prefix = ''   

cfg.data.test.type = 'myRegister'
cfg.data.test.data_root = ''
cfg.data.test.ann_file = f'{annotations_dir}/val_dicts_roof_plan.json' 
cfg.data.test.img_prefix = ''


# modify num classes of the model in box head
cfg.model.roi_head.bbox_head.num_classes = len(CLASSES)

# Set up working dir to save files and logs.
cfg.work_dir = work_dir


# Toatal epochs
cfg.total_epochs = total_epochs

# Change the evaluation metric since we use customized dataset.
cfg.evaluation = 'mAP'

cfg.total_epochs = 50

cfg.optimizer.lr = 5e-4

cfg.data.samples_per_gpu = 4
cfg.data.workers_per_gpu = 4

return cfg

#################################################################
def my_training(cfg):

# Build dataset
datasets = [build_dataset(cfg.data.train)]

# Build the detector
model = build_detector(cfg.model, train_cfg=cfg.train_cfg, test_cfg=cfg.test_cfg)

# Add an attribute for visualization convenience
model.CLASSES = datasets[0].CLASSES

# train
train_detector(model, datasets, cfg, distributed=False, validate=False)

###########################################################