Repository for the paper Degraded Polygons Raise Fundamental Questions of Neural Network Perception by Leonard Tang and Dan Ley.
Datasets of degraded polygons can be generated using the following command
python3 shape_generator.py --num-shapes-per-class, -n <N>
--img-size, -s <S>
--min-radius-div, -m <M>
--remove-prop, -r, <R>
--thickness, -t, <T>
--save-dir, -d <D>
[--generate-whole, -w]
Parameters:
N
— number of shapes to generate per class (default: 1000)S
— length of square images (default: 224)M
— minimum radius of polygon circumcircles (default: 5)R
— proportion of polygons to remove (default: 0.3)T
— thickness of polygons (default: 2)D
— save directory of dataset (default: './images224/shapes')
Use the --generate-whole
flag to save non-degraded polygons
The vision models used in our experiments can be trained with the following command
python3 train.py --data, -d <DATA>
--model, -m <MODEL>
--learning-rate, -lr <LEARNING_RATE>
--momentum <MOMENTUM>
--batch-size, -b <BATCH_SIZE>
--epochs, -e <EPOCHS>
--decay, -wd <DECAY>
--save-dir <SAVE_DIR>
--num-workers, -w <NUM_WORKERS>
--pretrained-path, --p <PRETRAINED_PATH>
[--pretrained-imagenet, -pi]
[--evaluate, -e]
Model checkpoints can be found at this link.
Parameters:
DATA
— directory of dataset (default: './images224/shapes')MODEL
— name of model to train e.g. 'resnet18', 'resnet50', 'mlpmixer', or 'vit' (default: 'resnet18')LEARNING_RATE
— initial learning rate of optimizer (default: 0.01)MOMENTUM
— momentum of optimizer (default: 0.9)BATCH_SIZE
— batch size of optimizer (default: 512)EPOCHS
— number of training epochs (default: 120)DECAY
— weight decay value (default: 0.0001)SAVE_DIR
— save directory of model checkpoints (default: './checkpoints224')NUM_WORKERS
— number of workers for PyTorch (default: 16)PRETRAINED_PATH
— optional path to pretrained models
Use the --pretrained-imagenet
flag to use a model pretrained on ImageNet-1K, and the --evaluate
flag to skip training and go straight to evaluation (accuracy on whole shapes, accuracy on degraded shapes, breakdown per class, etc.)