A Deep Learning based Bird Image Identification System, using Keras, TensorFlow, OpenCV, and Flask.
The 'Bird Watch' project, created by an amateur photographer and a machine learning enthusiast, is a solution to a simple problem faced by fellow wildlife photographers: a way to identify birds in photographs. The application is developed using Keras and TensorFlow, with Flask for the web application. InceptionV3 was used as the base model and was trained using transfer learning and fine-tuning techniques.
The live application can be found at https://www.birdwatch.photo/
The libraries required to run the Flask app can be installed via the following commands.
Using PIP:
pip install -r requirements.txt
Using Conda:
conda install numpy scipy h5py Pillow Click Flask itsdangerous Jinja2 MarkupSafe Werkzeug tensorflow
pip install keras
Note: You can install tensorflow-gpu
(instead of tensorflow) if you have a CUDA capable GPU.
First, head over to the Releases page and grab the latest final_model_*.h5
and class_indices_*.npy
files, and place them in the models
directory.
You can then start the Flask app can be run by running,
python application.py
The app would by default run on http://127.0.0.1:5000/
In order to train with you own images, create a data/train
directory and place your images within sub-directories for each class within the train directory (as required by the flow_from_directory function of Keras: https://keras.io/preprocessing/image/ ). Create a data/models
directory for the bottleneck features and the trained models to be saved. You can also create a data/eval
directory and place few sample images there to evaluate the model after training.
Once you have the data ready, you can run,
python bird_watch_train.py
This will run the combined training and fine-tuning script which will generate the final model files.
Note: The training may take 10+ hours to run, even on a GPU such as a RTX 2070.
Once the training is over, you will have final_model_*.h5
and class_indices_*.npy
in your data/models
directory. Copy them over to your top level models
directory and you'll be good to go.
The main requirements to run the Flask application are:
- TensorFlow
- Keras
- Flask
The full set of runtime dependencies are in the requirements.txt
In order to re-train the model, the following additional libs are needed:
- OpenCV
- Matplotlib
- Pillow