SHI-Labs / OneFormer

OneFormer: One Transformer to Rule Universal Image Segmentation, arxiv 2022 / CVPR 2023
https://praeclarumjj3.github.io/oneformer
MIT License
1.41k stars 128 forks source link

Queries on training custom dataset for panoptic task #48

Closed sahityabonumaddi closed 1 year ago

sahityabonumaddi commented 1 year ago

I know these are very basic queries, thanks in advance !

  1. After writing a file similar to https://github.com/SHI-Labs/OneFormer/blob/main/oneformer/data/datasets/register_ade20k_panoptic.py to register custom data, I should run this specific python file separately to register. is that right?

  2. I'm using oneformerunifieddatasetmapper https://github.com/SHI-Labs/OneFormer/blob/main/oneformer/data/dataset_mappers/oneformer_unified_dataset_mapper.py

  3. I'm using config file similar to https://github.com/SHI-Labs/OneFormer/blob/5e04c9aaffd9bc73020d2238757f62346fe778c0/configs/ade20k/Base-ADE20K-UnifiedSegmentation.yaml

4.I have doubt in evaluator, can I use any provided evaluators for my dataset? if not kindly guide me through

praeclarumjj3 commented 1 year ago

Hi @sahityabonumaddi, thanks for your interest in our work.

After writing a file similar to https://github.com/SHI-Labs/OneFormer/blob/main/oneformer/data/datasets/register_ade20k_panoptic.py to register custom data, I should run this specific python file separately to register. is that right?

You don't need to run that file. Just import it inside oneformer/data/datasets/init.py.

I have doubt in evaluator, can I use any provided evaluators for my dataset? if not kindly guide me through

I am sorry, but I cannot answer that question with no knowledge about the structure of your dataset. if it's in COCO format, then you can use COCOPanopticEvaluator. Otherwise, you might need to write your own evaluator.

sahityabonumaddi commented 1 year ago

Except run length coding(RLE) in segmenting a object, it is in detectron2 standard format.

sahityabonumaddi commented 1 year ago

once I register my dataset in detectron2 standard format, which is done please guide me through how to write a evaluator for custom dataset @praeclarumjj3

praeclarumjj3 commented 1 year ago

Hi @sahityabonumaddi, Could you share the JSON format for your panoptic annotations JSON file? it is unclear to me what's the format of your dataset without which I can't help you.

Except run length coding(RLE) in segmenting a object, it is in detectron2 standard format.

There's no standard detectron2 format for a dataset. Did you mean COCO format?

sahityabonumaddi commented 1 year ago

Thanks for your reply @praeclarumjj3

By standard detectron2 standard format I mean the format of list[dict] as specified by https://detectron2.readthedocs.io/en/latest/tutorials/datasets.html

I modified the def load_ade20k_panoptic_json(json_file, image_dir, gt_dir, semseg_dir, meta): function in register_ade20k_panoptic.py to return the specified keys.

ret.append( { "file_name": image_file, "image_id": image_id, "pan_seg_file_name": label_file, "sem_seg_file_name": sem_label_file, "segments_info": segments_info, } )

this is my JSON file for panoptic annotations.

{"id": "00001", "width": 1024, "height": 1024, "file_name": "images/airport/100/img_1_0_1552039977070010400.png" ,

"detection": [{"id": 3853443, "category_id": 13, "category_name": "smallvehicle", "segmentation": [459, 985, 458, 986, 457, 986, 456, 986, 455, 987, 454, 987, 453, 987, 453, 988, 453, 989, 453, 990, 453, 991, 453, 992, 453, 993, 453, 994, 453, 995, 453, 996, 454, 997, 455, 997, 456, 997, 457, 997, 458, 997, 459, 998, 460, 998, 461, 998, 462, 998, 463, 998, 464, 998, 465, 998, 466, 998, 467, 998, 468, 998, 469, 998, 470, 998, 471, 997, 472, 997, 473, 997, 474, 997, 475, 997, 476, 997, 477, 996, 478, 996, 479, 995, 480, 994, 480, 993, 480, 992, 480, 991, 480, 990, 480, 989, 480, 988, 479, 987, 479, 986, 478, 986, 477, 986, 476, 985, 475, 985, 474, 985, 474, 986, 473, 987, 472, 986, 471, 986, 470, 986, 469, 986, 468, 986, 467, 986, 466, 986, 465, 986, 464, 986, 463, 986, 462, 986, 461, 985, 460, 985], "hbbox": [453, 985, 28, 14], "obbox": [[453, 998], [453, 985], [480, 985], [480, 998]]},

{"id": 11965944, "category_id": 13, "category_name": "smallvehicle", "segmentation": [861, 819, 860, 820, 860, 821, 860, 822, 859, 823, 859, 824, 859, 825, 859, 826, 860, 827, 861, 828, 862, 829, 863, 829, 864, 830, 865, 830, 866, 831, 867, 831, 868, 831, 869, 832, 869, 833, 870, 832, 871, 832, 872, 833, 873, 833, 874, 834, 875, 834, 876, 834, 877, 835, 878, 835, 879, 835, 880, 836, 881, 836, 882, 836, 883, 836, 884, 837, 885, 836, 885, 835, 885, 834, 886, 833, 886, 832, 886, 831, 887, 830, 886, 829, 885, 828, 884, 827, 883, 826, 882, 826, 881, 825, 880, 824, 879, 824, 878, 825, 877, 824, 876, 824, 875, 823, 874, 823, 873, 823, 872, 822, 871, 822, 870, 821, 869, 821, 868, 821, 867, 820, 866, 819, 865, 819, 864, 819, 863, 819, 862, 819], "hbbox": [859, 819, 29, 19], "obbox": [[884, 838], [856, 828], [860, 817], [888, 826]]},

{"id": 5370071, "category_id": 13, "category_name": "smallvehicle", "segmentation": [833, 768, 832, 769, 831, 769, 830, 769, 829, 770, 828, 770, 828, 771, 828, 772, 828, 773, 828, 774, 829, 775, 829, 776, 830, 777, 830, 778, 831, 779, 831, 780, 831, 781, 832, 782, 832, 783, 832, 784, 833, 785, 833, 786, 833, 787, 833, 788, 834, 789, 834, 790, 835, 791, 836, 792, 836, 793, 837, 794, 837, 795, 838, 796, 839, 796, 840, 796, 841, 795, 842, 795, 843, 795, 844, 794, 845, 794, 846, 793, 845, 792, 845, 791, 845, 790, 845, 789, 844, 788, 844, 787, 844, 786, 843, 785, 843, 784, 843, 783, 842, 782, 842, 781, 841, 780, 841, 779, 841, 778, 840, 777, 840, 776, 840, 775, 839, 774, 839, 773, 838, 772, 838, 771, 837, 770, 836, 769, 835, 768, 834, 768], "hbbox": [828, 768, 19, 29], "obbox": [[836, 797], [826, 770], [837, 766], [846, 793]]},

{"id": 12301172, "category_id": 13, "category_name": "smallvehicle", "segmentation": [830, 829, 829, 830, 828, 830, 827, 830, 826, 831, 825, 832, 825, 833, 825, 834, 825, 835, 826, 836, 826, 837, 827, 838, 827, 839, 828, 840, 828, 841, 829, 842, 829, 843, 829, 844, 830, 845, 830, 846, 830, 847, 831, 848, 830, 849, 831, 850, 831, 851, 832, 852, 833, 853, 833, 854, 834, 854, 835, 855, 836, 855, 837, 855, 838, 855, 839, 854, 840, 854, 841, 854, 842, 853, 842, 852, 842, 851, 842, 850, 842, 849, 842, 848, 842, 847, 842, 846, 841, 845, 841, 844, 840, 843, 840, 842, 840, 841, 839, 840, 839, 839, 839, 838, 838, 837, 838, 836, 838, 835, 837, 834, 837, 833, 836, 832, 836, 831, 835, 830, 835, 829, 834, 829, 833, 829, 832, 829, 831, 829], "hbbox": [825, 829, 18, 27], "obbox": [[832, 856], [823, 831], [835, 827], [844, 852]]}],

"segmentation": {"panoptic_filename": "panoptic/airport/100/img_1_5_1552039977068509700.png", "semantic_filename": "semantic/airport/100/img_1_5_1552039977068509700.png"}}

thanks in advance!