Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to generate train.labelmap.tsv ? #29

Open
Edwardmark opened this issue Jul 2, 2021 · 7 comments
Open

How to generate train.labelmap.tsv ? #29

Edwardmark opened this issue Jul 2, 2021 · 7 comments

Comments

@Edwardmark
Copy link

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
Copy link
Contributor

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
Copy link
Author

attribute_to_idx

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

@hanxiaotian
Copy link
Contributor

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

TRAIN: ("visualgenome/train_vgoi6_clipped.yaml",)

@Edwardmark
Copy link
Author

@hanxiaotian Thanks.

@Edwardmark
Copy link
Author

@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
Copy link
Author

@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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants