A simple program that lets you train a ML model for image classification.
There is also a helper script that lets you scrape training data from google images.
This script only works until python 3.10.9
Clone the repository
git clone https://github.com/rektile/Simple-Image-Classifier.git
Go into the folder
cd ./Simple-Image-Classifier
Install python requirements
pip install -r requirements.txt
There are 3 important folders inside this project you need to beware of.
- models: This is where your models are going to be saved and loaded from.
- pictures: This is where the training data needs to be.
- predict: This is where you put the pictures of the images you want to model to predict.
Get help screen for arguments
python Classifier.py -h
Example commands
# Uses the model SVC to train data, save it as SVC_model and predict the cat.jpg image
python Classifier.py -m SVC -s SVC_model -p cat.jpg
# Use the saved model named SVC_model, verbose output and predict cat.jpg and dog.jpg
python Classifier.py -l SVC_model -v -p cat.jpg dog.jpg
The label they get are based on what folder they are in.
If you have train data of dogs, put them inside a folder named dog inside of pictures.
For e.g:
pictures/
├─ dog/
│ ├─ dog_0.jpg
├─ cat/
│ ├─ cat_0.jpg
Get help screen for arguments
python TrainingDataScraper.py -h
Example commands
# Get 500 images each of dogs and cats
python TrainingDataScraper.py -a 500 -k dog cat
These images are scraped from the top results of google.
Because of this there could be random images that don't fit the keyword or are bad quality overall.
This makes the overall results of the model bad.