google / sg2im

Code for "Image Generation from Scene Graphs", Johnson et al, CVPR 2018
Apache License 2.0
1.29k stars 230 forks source link

scene graphs #12

Open SunshineJunFu opened 5 years ago

SunshineJunFu commented 5 years ago

Could you provide codes for generating scene graphs in JSON format?

moon-landing commented 3 years ago

sg2im/data/coco.py

wang-zm18 commented 3 years ago

hi, could you please tell me how to visualize scene graphs on the validation dataset of COCO-Stuff? There are lack of prepared json files for each image.

jcjohnson commented 3 years ago

This is the function we used to make scene graph visualizations:

https://github.com/google/sg2im/blob/master/sg2im/vis.py#L110

There isn't any code that works out-of-the-box to run this on COCO-Stuff validation images; but it should be pretty straightforward to write a standalone script that builds a COCO data loader, (https://github.com/google/sg2im/blob/master/sg2im/data/coco.py), iterates through it to construct random scene graphs, then use the draw_scene_graph function to visualize them.

wang-zm18 commented 3 years ago

Thank you, Justin! I have complete this code. But a found a small mistake in line 139 of vis.py. I think "p = vocab['pred_name_to_idx'][triples[i, 1].item()]" should be changed into "p = vocab['pred_idx_to_name'][triples[i, 1].item()]".