aim-uofa / AdelaiDet

AdelaiDet is an open source toolbox for multiple instance-level detection and recognition tasks.
https://git.io/AdelaiDet
Other
3.37k stars 646 forks source link

Evaluating on Custom Dataset #317

Open brdiep113 opened 3 years ago

brdiep113 commented 3 years ago
Traceback (most recent call last):

  File "tools/train_net.py", line 229, in <module>

    args=(args,),

  File "/home/brian/AdelaiDet/detectron2/detectron2/engine/launch.py", line 62, in launch

    main_func(*args)

  File "tools/train_net.py", line 217, in main

    return trainer.train()

  File "tools/train_net.py", line 89, in train

    self.train_loop(self.start_iter, self.max_iter)

  File "tools/train_net.py", line 79, in train_loop

    self.after_step()

  File "/home/brian/AdelaiDet/detectron2/detectron2/engine/train_loop.py", line 169, in after_step

    h.after_step()

  File "/home/brian/AdelaiDet/detectron2/detectron2/engine/hooks.py", line 370, in after_step

    self._do_eval()

  File "/home/brian/AdelaiDet/detectron2/detectron2/engine/hooks.py", line 345, in _do_eval

    results = self._func()

  File "/home/brian/AdelaiDet/detectron2/detectron2/engine/defaults.py", line 400, in test_and_save_results

    self._last_eval_results = self.test(self.cfg, self.model)

  File "/home/brian/AdelaiDet/detectron2/detectron2/engine/defaults.py", line 552, in test

    results_i = inference_on_dataset(model, data_loader, evaluator)

  File "/home/brian/AdelaiDet/detectron2/detectron2/evaluation/evaluator.py", line 176, in inference_on_dataset

    results = evaluator.evaluate()

  File "/home/brian/AdelaiDet/detectron2/detectron2/evaluation/coco_evaluation.py", line 175, in evaluate

    self._eval_predictions(predictions, img_ids=img_ids)

  File "/home/brian/AdelaiDet/detectron2/detectron2/evaluation/coco_evaluation.py", line 210, in _eval_predictions

    f"A prediction has class={category_id}, "

AssertionError: A prediction has class=7, but the dataset only has 1 classes and predicted class id should be in [0, 0].

Hello, I am trying to train and evaluate SOLOv2 on my own custom dataset with my own class. I am trying to do periodic validation checks however I run into an error as during the early stages, my network with the preloaded weights seems to predict class labels outside of the classes of my custom dataset. No issue seems to arise if I do not validate until the very end (presumably when my network has learned there are no other classes except the one in my dataset. Is there a way to avoid this problem and limit the predictions to only my classes/skip these cases.

ALmagical commented 3 years ago

Please change your config file, there are several places where you should set your own number of classes. Simply you can search NUM_CLASSES in your output log file, you will see where to add this parameters in your config file.

Tanveer81 commented 3 years ago

Why does SEM_SEG_HEAD has NUM_CLASSES: 54 configures for coco dataset?

ALmagical commented 3 years ago

Sorry, I don't know this.

tpfLZ commented 2 years ago

您好,请问是怎么评估自定义数据集的

ALmagical commented 2 years ago

和训练时一样,只是调用train.py时加上--eval-only参数就可以

tpfLZ commented 2 years ago

您好,可以加我下QQ:287558659吗?我想问下您关于具体的一些操作

an99990 commented 2 years ago

did you guys solve this ? i am facing this issue even after setting num_classes