Please refer to Paper
- Python 3
From the home directory, run:
python -m venv venv
source venv/bin/activate
pip install -r requirements.txtUse the above virtual environment for training and sampling graphs from all methods.
Starting from the home directory, follow these steps for preparing each dataset.
- Download and unzip
scene_graphs.jsonfrom here into thevg_data/datadirectory. - Run
cd vg_data - Run
python data_init.py
- Download
json_datasetfrom here, unzip and place all contents of it into thevrd_data/datadirectory. - Run
cd vrd_data - Run
python data_init.py
- Download
train_dataset.p,test_dataset.pandcategories.pfrom here and place it insvg_data/data - Run
cd svg_data - Run
python data_init.py
From the varscene directory, proceed with following:
DATASET below can be any one of vg,svg or vrd
python train_base_model.py --out_dir OUTDIR --dataset DATASETpython train_property_optim_decoder.py --out_dir OUTDIR --dataset DATASET: MMD Optimized decoder. This can run only after thetrain_base_model.pyscript and requires the sameOUTDIRused in step 1
OUTDIR here is the same directory specified in training. The below commands will save a list of generated graphs as .pkl files in OUTDIR.
python unconditional_generation.py --model_dir OUTDIR --dataset DATASET(unconditional generation)python conditional_generation.py --model_dir OUTDIR --dataset DATASET(conditional generation)
Instructions for running baselines are present in respective folders. DeepGMG, GraphGen, GraphRNN are in the graphgen directory. MolGAN in the MolGAN directory and SceneGen in the SceneGen directory.
From the varscene directory, run python calc_metrics.py --dataset DATASET --data_path PATH_TO_GRAPHS_PKL
PATH_TO_GRAPHS_PKL is the path to the .pkl file containing graphs sampled by VarScene or by any other baseline.
This will print metrics for Star-Sim, Edge-sim, Node-sim, SP-K, WL-K, NSPD-K to STDOUT (corresponding to table 2 of the paper).
- Follow the
sg2imREADME.md to download thevg128.ptmodel and save it insg2im/sg2im-models - From the
directed_varscenedirectory, runpython create_sg_json.py --graphs_file PATH_TO_GRAPHS_PKL --out_json_file PATH_TO_SG_JSONfor all.pklfiles containing sampled scene graphs. This will store the scene graphs in.jsonfiles required bysg2im - From the
sg2imdirectory, follow its README.md to prepare the environment setup and generate scene images from graphs
This completes preparation of all scene images from scene graphs.
The FID, IS, precision and recall values (corresponding to table 5 of the paper) can be computed as follows:
- FID : from the
directed_varscenedirectory, runpython fid_score.py PATH_1 PATH_2. The paths here are directories containing the generated and reference images - IS : from the
directed_varscenedirectory, runpython inception_score.py --path PATH.PATHis the directory containing generated images - Precision and recall : from the
precision-recall-distributionsdirectory, follow its README.md for environment setup. Then runpython prd_from_image_folders.py --reference_dir REF_DIR --eval_dirs EVAL_DIR
The above commands will all print results to STDOUT