MendelXu / SAN

Open-vocabulary Semantic Segmentation
https://mendelxu.github.io/SAN/
MIT License
295 stars 27 forks source link

How to train on PASCAL VOC 2012 datasets #44

Closed ChunmengLiu1 closed 7 months ago

ChunmengLiu1 commented 7 months ago

Hi! thank you for your good work.

  1. I want to train and test on the PASCAL VOC 2012 datasets. where should I change? /config/base-coco-stuff-164k-171.yaml? To change the original 'coco_2017_train_stuff_sem_seg' to 'voc_sem_seg_train' on the DATASETS:TRAIN: position?

  2. and after I changed the yaml file like above, I still met the problems as follows:

  File "/data/users/cliu/work12/SAN/san/model/criterion.py", line 222, in get_loss
    return loss_map[loss](outputs, targets, indices, num_masks)
  File "/data/users/cliu/work12/SAN/san/model/criterion.py", line 142, in loss_labels
    loss_ce = F.cross_entropy(
  File "/home/cliu/miniconda3/envs/san/lib/python3.9/site-packages/torch/nn/functional.py", line 3014, in cross_entropy
    return torch._C._nn.cross_entropy_loss(input, target, weight, _Reduction.get_enum(reduction), ignore_index, label_smoothing)
RuntimeError: weight tensor should be defined either for all or no classes

It looks like the code problem not the environment problem. Do you have any advice?

3.How do you get the 'datasets/VOC2012/annotations_detectron2/train' datasets? ti's 10582 images for PASCAL VOC 2012 train set here?

Thank you!

Irennnne commented 7 months ago

I got the same error of weight tensor after changing the yaml to adapt my own dataset. Did you solve this error?

Irennnne commented 7 months ago

I solved it now. I think this error is caused by the wrong number of classes. We should set it by this python train_net.py --eval-only --config-file <CONFIG_FILE> --num-gpus <NUM_GPU> OUTPUT_DIR <OUTPUT_PATH> MODEL.WEIGHTS <TRAINED_MODEL_PATH> MODEL.SAN.NUM_CLASSES [NUM_OF_CLASS] which is mentioned in another issue how to train on our own dataset.

MendelXu commented 7 months ago

@Irennnne is right. You can specify the number of training classes for the loss computing.

ChunmengLiu1 commented 7 months ago

I solved it now. I think this error is caused by the wrong number of classes. We should set it by this python train_net.py --eval-only --config-file <CONFIG_FILE> --num-gpus <NUM_GPU> OUTPUT_DIR <OUTPUT_PATH> MODEL.WEIGHTS <TRAINED_MODEL_PATH> MODEL.SAN.NUM_CLASSES [NUM_OF_CLASS] which is mentioned in another issue how to train on our own dataset.

Hi, thank you for sharing. But I have problems about how to find these params, like MODEL.WEIGHTS and MODEL.SAN.NUM_CLASSES. Can you give me some advice? Thank you so much!

ChunmengLiu1 commented 7 months ago

@Irennnne is right. You can specify the number of training classes for the loss computing.

Thank you fro your reply. How about the another two issues? Do you have some insight? thank you!

  1. I want to train and test on the PASCAL VOC 2012 datasets. where should I change? /config/base-coco-stuff-164k-171.yaml? To change the original 'coco_2017_train_stuff_sem_seg' to 'voc_sem_seg_train' on the DATASETS:TRAIN: position?
  2. How do you get the 'datasets/VOC2012/annotations_detectron2/train' datasets? ti's 10582 images for PASCAL VOC 2012 train set here?
  3. I have difficulty in find the params setting position. All params set in the yaml? the released code only is suitable for COCO datasets? Thank you!
MendelXu commented 7 months ago
  1. Yes.
  2. I have forgot the concrete step to get the 10582 samples. You may follow https://github.com/kazuto1011/deeplab-pytorch/blob/master/data/datasets/voc12/README.md to prepare the data.
  3. Default parameters are configured in https://github.com/MendelXu/SAN/blob/main/san/config.py. The yaml file is used to modify it.
ChunmengLiu1 commented 7 months ago

Thank you for your patience! Got it!