πŸ€– Train ResNet based model to detect if images is street art or not
Branch: master
Clone or download

README.md

npaf-logo

Street art, not street art

Train a model that detects if image is or is not street art, based on images gathered from hashtagged content.

What

The project above trains a model that detects whether an image is or is not street art. The model is trained on a image set gathered from hashtagged images for #streetart. The training data was compared against images from New York City. The image dataset was cleaned manually to have any mistagged content and NSFW images removed.

Image montage

Training results

Version two of the model and dataset, resulted in the following results:

Name Value Min Value Max
1 acc 0.804197365509982 0.375 0.9375
2 batch 130 0 130
3 loss 0.5488157922014857 0.36985594034194946 1.2533280849456787
4 size 32 31 32
5 val_acc 0.7505330491040562 0.7036247338567462 0.7974413653680765
6 val_loss 0.6231901207204058 0.5713440334873159 0.7559062163035075

Training results

The latest training results can be seen on FloydHub here: https://www.floydhub.com/rememberlenny/projects/streetart-notstreetart/3

Dataset

Dataset training dataset can be downloaded from Floydhub here: https://www.floydhub.com/rememberlenny/datasets/streetart-notstreetart

To work correctly, save the dataset into the /streetart folder.

The correct directory structure should look like this:

β”œβ”€β”€ pyimagesearch
β”‚Β Β  β”œβ”€β”€ __pycache__
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ config.cpython-36.pyc
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ __init__.cpython-36.pyc
β”‚Β Β  β”‚Β Β  └── resnet.cpython-36.pyc
β”‚Β Β  β”œβ”€β”€ config.py
β”‚Β Β  β”œβ”€β”€ __init__.py
β”‚Β Β  └── resnet.py
β”œβ”€β”€ streetart
β”‚Β Β  β”œβ”€β”€ images
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ not_streetart [4322 entries exceeds filelimit, not opening dir]
β”‚Β Β  β”‚Β Β  └── streetart [1944 entries exceeds filelimit, not opening dir]
β”‚Β Β  β”œβ”€β”€ testing
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ not_streetart [858 entries exceeds filelimit, not opening dir]
β”‚Β Β  β”‚Β Β  └── streetart [396 entries exceeds filelimit, not opening dir]
β”‚Β Β  β”œβ”€β”€ training
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ not_streetart [3124 entries exceeds filelimit, not opening dir]
β”‚Β Β  β”‚Β Β  └── streetart [1387 entries exceeds filelimit, not opening dir]
β”‚Β Β  └── validation
β”‚Β Β      β”œβ”€β”€ not_streetart [340 entries exceeds filelimit, not opening dir]
β”‚Β Β      └── streetart [161 entries exceeds filelimit, not opening dir]
β”œβ”€β”€ build_dataset.py
β”œβ”€β”€ not_streetart.png
β”œβ”€β”€ README.md
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ Street Art Detector.ipynb
β”œβ”€β”€ streetart_model.model
β”œβ”€β”€ streetart_montage.png
β”œβ”€β”€ streetart_plot.png
β”œβ”€β”€ test_model_by_generating_montage.py
└── train_model.py

How to run

  1. pip install -r requirements.txt
  2. Download dataset from Floydhub into /dataset. Folder structure for /dataset/images should match the format listed above.
  3. Run python build_dataset.py. This will create the /testing, /training, and /validation dataset.
  4. Run python train_model.py or use the python notebook and run the training step.
  5. Use python test_model_by_generating_montage.py to validate the results.