microsoft / scene_graph_benchmark

image scene graph generation benchmark
MIT License
382 stars 86 forks source link

How to generate train.labelmap.tsv ? #29

Open Edwardmark opened 3 years ago

Edwardmark commented 3 years ago

Could you please tell me how to generate train.labelmap.tsv ? It seems that there is no code about it in the tsv_demo.py. @hanxiaotian Thanks.

hanxiaotian commented 3 years ago

Sorry for the confusion. At this time, you could use labelmap.json to replace train.labelmap.tsv.
The format of labelmap.json is like this:

{"label_to_idx": {"Piano": 1, "Boy": 2, "Tennis ball": 3, "Van": 4, "Football": 5, "Beer": 6, "Camera": 7, "Suitcase": 8, "Man": 9, "Bench": 10, "Dolphin": 11, "Motorcycle": 12, "Mug": 13, "Tennis racket": 14, "Drum": 15, "Spoon": 16, "Horse": 17, "Surfboard": 18, "Bicycle": 19, "Knife": 20, "Rugby ball": 21, "Woman": 22, "Handbag": 23, "Microwave oven": 24, "Flute": 25, "Girl": 26, "Taxi": 27, "Hamster": 28, "Wine glass": 29, "Backpack": 30, "Racket": 31, "Table": 32, "Pretzel": 33, "Bed": 34, "Snowboard": 35, "Car": 36, "Chair": 37, "Microphone": 38, "Coffee cup": 39, "Table tennis racket": 40, "Bottle": 41, "Guitar": 42, "Desk": 43, "Ski": 44, "Coffee table": 45, "Dog": 46, "Cat": 47, "Chopsticks": 48, "Elephant": 49, "Mobile phone": 50, "Monkey": 51, "Snake": 52, "Sofa bed": 53, "Violin": 54, "Fork": 55, "Oven": 56, "Briefcase": 57}, "predicate_to_idx": {"at": 1, "on": 2, "holds": 3, "plays": 4, "interacts_with": 5, "wears": 6, "inside_of": 7, "under": 8, "hits": 9}, "attribute_to_idx": {"Transparent": 1, "Plastic": 2, "(made of)Textile": 3, "(made of)Leather": 4, "Wooden": 5}}

Basicly, this file maps class names to index. The "predicate_to_idx" and "attribute_to_idx" fields are optional if you only need to train detector.

Thanks

Edwardmark commented 3 years ago

attribute_to_idx

so does that mean I should just copy labelmap.json to train.labelmap.tsv? Or how to change the code?

hanxiaotian commented 3 years ago

in train.yaml file, you could fill in like below,

img: train.vrd.img.tsv
hw: train.vrd.hw.tsv
label: train.vrd.label.tsv
linelist: train.vrd.linelist.tsv
labelmap: labelmap.json

Then you replace this part with your train.yaml https://github.com/microsoft/scene_graph_benchmark/blob/a93180e85ce69baf67cd6300731baff8d10c1160/sgg_configs/vgattr/vinvl_x152c4.yaml#L34

Edwardmark commented 3 years ago

@hanxiaotian Thanks.

Edwardmark commented 3 years ago

@hanxiaotian why I run train_net.py, I get the error:

TypeError: do_train() missing 1 required positional argument: 'meters'

What does it mean? And how to set meters? Thanks.

Edwardmark commented 3 years ago

@hanxiaotian And is the tsv file format right? I try to run train_net.py, but I found that the annotions read from tsv file is:

[{"rect": [748.9104, 389.93981599999995, 1599.54016, 1060.51001], "class": "60"}, {"rect": [755.5798399999999, 214.17999749999996, 1500.6697600000002, 746.2600004999999], "class": "41"}, {"rect": [331.5100799999999, 329.6098400000001, 1405.22976, 1024.320052], "class": "53"}, {"rect": [411.12991999999997, 221.56005199999996, 1150.5699200000001, 722.530116], "class": "41"}, {"rect": [458.27008, 213.50021349999997, 1183.07008, 765.3400684999999], "class": "42"}]

but in od_tsv.py, the function get_target_from_annotations, there is a line:

if self.is_load_label:
            return self.label_loader(annotations['objects'], img_size)

but the annotaions is a list, not a dict, so there is no key named "objects", did I miss something? Thanks. @hanxiaotian @pzzhang

yuchen2199 commented 2 years ago

I meet the same question. Could you tell me do you solve it?