SpeciesClassification/demo
Annie Enchakattu db650688f2 fixed error in image re-sizing 2020-02-08 19:41:10 -08:00
..
static fixed error in image re-sizing 2020-02-08 19:41:10 -08:00
templates added species classification demo code 2019-07-19 19:54:07 -07:00
README.MD updated instructions for running demo 2020-01-20 18:25:47 -08:00
ai4e_setup_images.py updated setup code 2019-07-24 10:32:59 -07:00
app.py Added fix for XSS bug in search 2019-11-14 21:29:34 -08:00
bbox.py updated setup code 2019-07-24 10:32:59 -07:00
common.py updated package urlparse for python3 2020-02-03 09:25:37 -08:00
config.py updated setup code 2019-07-24 10:32:59 -07:00
constant.py added species classification demo code 2019-07-19 19:54:07 -07:00
enums.py updated setup code 2019-07-24 10:32:59 -07:00
inatdemo.wsgi added species classification demo code 2019-07-19 19:54:07 -07:00
predict.py updated setup code 2019-07-24 10:32:59 -07:00
sample_images.py updated setup code 2019-07-24 10:32:59 -07:00
sample_images_dir_structure.jpg Add files via upload 2019-07-24 10:49:46 -07:00
search.py updated setup code 2019-07-24 10:32:59 -07:00
search_config.py added species classification demo code 2019-07-19 19:54:07 -07:00
setup_sample_images.py update setup_sample_images.py with config info 2019-07-24 11:41:15 -07:00

README.MD

Species Classification API Demo

Overview

This demo uses the AI for Earth Species Classification API, which identifies over 5,000 plant and animal species. Visit the API home page for more information or to request an API key. The code used to train our model is available here.

You can view the demo at aka.ms/speciesclassification.

Setup Instructions

The demo was tested on an Azure VM with the following configuration:

  • Operating system: Linux (Ubuntu 18.04)
  • Size: Standard B2ms (2 CPUs, 8 GB memory)

Clone the repository and update the config file

  • Clone the repository and copy the folder demo to your local machine or server
  • Open the demo folder and update the following variables inside the config.py file (demo/config.py):
    • ReplaceROOT_PATH with the path to the demo on your local machine or server (e.g /home/.../demo)
    • Update BASE_URL with the base URL for the API (e.g https://[api-base-url]/). Refer to the API documentation for information
    • UpdateSUBSCRIPTION_KEY with your product / API key. Visit the API home page for more information on how to request an API key.

Add the sample images

  • Navigate to the folder demo/static and create a directory called animals

  • Inside the newly created directory animals add the sample images that you would like to be displayed in the demo site. The directory structure for the sample images should be as follows animal_name > image.ext as shown in the example below. A minimum of 8 valid images (jpg or png) is required for the demo to work.

      sample images directory structure

  • Run demo/setup_sample_images.py (for internal AI4E species classification site run demo/ai4e_setup_images.py). This script does the following:
    • Renames the files/directories to remove invalid characters.
    • Creates a csv index file called demo/static/data/updated_animal_list.csv, which contains the file paths and corresponding animal names (extracted from the directory names).
    • Creates a thumbnails folder from the provided images. Thumbnails are resized images from the animals folder; these are the images that are displayed on the site. While predicting, the site will look up the corresponding image in the animals folder.

Run the demo

  • Install the required packages by running the commands listed below:
pip install Flask==1.1.1
pip install requests==2.22.0
pip install urllib3==1.25.3
pip install pandas==0.24.2
pip install Pillow==6.1.0
  • To start the demo, run command python demo/app.py
  • In a browser, navigate to http://<your VM address>:5000