The substance classifier is used by the SUBS metric. We train it a mix of crops obtained from the opensurfaces dataset and stationary textures dataset. More details are provided in the supplementary metrics section of the paper.
Download the opensurfaces dataset. The download script will extract the rectified surface masks.
From those extracted rectified surface masks, we prepare a train_masks directory and a val_masks directory having masks with following file names.
Then, we use the following script to extract crops from these rectified surface masks.
python scripts/plan2scene/metric_impl/substance_classifier/prepare_opensurfaces_crops.py ./data/processed/open-surfaces-crops/train PATH/TO/train_masks
python scripts/plan2scene/metric_impl/substance_classifier/prepare_opensurfaces_crops.py ./data/processed/open-surfaces-crops/val PATH/TO/val_masksWe use the following script to extract crops from the texture dataset.
python scripts/plan2scene/metric_impl/substance_classifier/prepare_texture_crops.py ./data/processed/stationary-textures-crops/train PATH/TO/TRAIN/TEXTURES
python scripts/plan2scene/metric_impl/substance_classifier/prepare_texture_crops.py ./data/processed/stationary-textures-crops/val PATH/TO/VAL/TEXTURES-
Make sure the crops extracted from the texture dataset are in the
[PROJECT_ROOT]/data/processed/stationary-textures-dataset-crops/trainand/data/processed/stationary-textures-crops/valdirectories. -
Make sure the crops extracted from opensurfaces rectified surface masks are in the
/data/processed/open-surfaces-crops/trainand[PROJECT_ROOT]/data/processed/open-surfaces-crops/valdirectories. -
Run the following command to start training. This will continue training for 200 epochs.
export PYTHONPATH=./code/src python ./code/scripts/plan2scene/metric_impl/substance_classifier/train.py ./trained_models/substance_classifier/default ./conf/plan2scene/substance_classifier_conf/default.json --save-model-interval 1Checkpoints are saved at './trained_models/substance_classifier/default/checkpoints' directory.
-
Preview learning curves using Tensorboard.
tensorboard --logdir=./trained_models/substance_classifier/default/tensorboard
-
Choose the best checkpoint based on substance classification accuracy. Update
substance_classifier.checkpoint_pathfield of./conf/plan2scene/metric.jsonto point to the best checkpoint. Updatesubstance_classifier.conf_pathfield of the same file to./trained_models/substance_classifier/default/conf/substance_classifier_conf.json