SOLO
SOLO copied to clipboard
Label Error
Hello, I train solo on my custom dataset which has a single class( bird). But I got the 'person' label as output. Please help me. Appreciate.
It's just a visualisation error, it just takes "person" since that's the first class in the default coco dataset.
There are multiple possible ways you could fix it, to name a couple:
(1) Modify the classes in your checkpoint file's "meta" section (2) Make a custom dataset (the same as coco's but with different classes: https://github.com/WXinlong/SOLO/blob/master/mmdet/datasets/coco.py) and train your model with that (this is a bit overkill since your model is probably fine, it's just the class label being shown is wrong). (3) Modify directly these lines and just hardcode your own class name(s): https://github.com/WXinlong/SOLO/blob/c7b294a311bfbc59b982b29dc9d12eff42ca0acb/tools/test.py#L234-L237 (this is very rough but would probably do if it's just a temporary thing for testing)
@danielcrane Many thanks. I replaced the CLASSES part in https://github.com/WXinlong/SOLO/blob/master/mmdet/datasets/coco.py with CLASSES=('bird'), but it doesn't work and I got the "person" label again :((
@danielcrane I also changed these lines in test.py,test_ins_vis.py and test_ins.py( because of single-gpu testing ) into : if 'CLASSES' in checkpoint['meta']: model.CLASSES = 'bird' else: model.CLASSES = 'bird'
It doesn't work again :((
@danielcrane Many thanks. I replaced the CLASSES part in https://github.com/WXinlong/SOLO/blob/master/mmdet/datasets/coco.py with CLASSES=('bird'), but it doesn't work and I got the "person" label again :((
The classes are actually stored in your checkpoint file, so you'd have to retrain your model with this modified coco.py
for it to work (I believe).
How about this:
import torch
file = "path_to_your_weights_file.pth" # Replace this with the path of your weights file
file_out = "path_to_new_weights_file.pth" # Replace this with the path of the new output weights file
model = torch.load(file)
model["meta"]["classes"] = ('bird',)
torch.save(model, file_out)
Once you've done this you will have replaced the class names within your model, so when loading your model it should (I believe) pick up on these class names.
I don't have a sample to run the test files with right now to see if it works, but please give it a shot and let me know if it doesn't work.
Another place to try could be in test_ins_vis.py
on the following line:
class_names = get_classes("coco")
you could either try to change it to your new dataset name, or simply just hardcode the following temporarily:
class_names = ("bird",)
I just tested and believe this should work if the above all fail.
@danielcrane SO many thanks :)))) Your last suggestion works for me and I use the hardcode option . Thank you
@azade-a Happy that I could help, sorry it took us so long to get there!
By the way, I personally had issues with the model not learning well when training with one class, so if you also encounter the same issue then my recommendation would be to add a dummy class (with no data), I did this and it helped the training immensely.
@danielcrane Yes, I had the same issue. Actually, when I set num_classes = 1 in solo_r50_fpn_8gpu_1x.py , I got an error at the first of the training process .So I changed num_classes =2 and it works for me :))
Hi guys, I did a similar thing only training on the mapillary dataset, thus using 116 classes. I adapted the config files accordingly and registered the mapillary dataset in the data registry as a class that inherits from CocoDataset. Training has completed successfully, but when I try to visualise the results using test_ins_vis.py, I keep getting the following error:
'size mismatch for bbox_head.solo_cate.weight: copying a param with shape torch.Size([80, 512, 3, 3]) from checkpoint, the shape in current model is torch.Size([116, 512, 3, 3])'
This makes me think that my config file is not properly updated. Do you know how this can be fixed?