Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
120 lines (87 sloc) 4.5 KB

Webpage docs

This is a basic web app to implement image recognition with local files and urls. The ./webpage folder is completelly self-contained and thus can be copied alone to your web server.


  • ./model_files: essential files for the image recognition test mode.
  • ./webpage_files: files for the webpage implementation and design.


First you have to copy the following files:

  • synsets.txt to ./webpage/model_files/data
  • your trained weights (.npz) to ./webpage/model_files/training_weights
  • your training info (.json) to ./webpage/model_files/training_info

You can additionally provide an info.txt file to be put in ./webpage/model_files/data with relevant information for each specie.

Launching the webpage

To launch the web execute the following:

cd ./webpage/webpage_files
python -m flask run

and it will start running at To run the webpage in production mode you can pip-install the gunicorn module as an easy drop-in replacement. Once installed just run

cd ./webpage/webpage_files
gunicorn webpage_demo:app -b --workers 4 --timeout 80 -k gevent

Using the API

You can query your webpage also through an API. You have to make a POST request with the images belonging to your observation.

Python snippets

Here are some Python snippets using the requests module.

Classifying URLs

im_list = ['', 

r ='', data={'mode':'url', 'url_list':im_list})

Classifying local images

im_paths = ['/home/ignacio/image_recognition/data/demo-images/image1.jpg',

im_names = [str(i) for i in range(len(im_paths))]
im_files = [open(f, 'rb') for f in im_paths]
file_dict = dict(zip(im_names, im_files))

r ='', data={'mode':'localfile'}, files=file_dict)

CURL snippets

Classifying URLs

curl --data "mode=url&url_list="

Classifying local images

curl --form mode=localfile --form 0=@/home/ignacio/image_recognition/data/demo-images/image1.jpg --form 1=@/home/ignacio/image_recognition/data/demo-images/image2.jpg


A successful response should return a json, with the labels and their respective probabilities, like the following

{u'pred_lab': [u'Rosa chinensis',
               u'Erythrina crista-galli',
               u'Tulipa agenensis',
               u'Gladiolus dubius',
               u'Spathodea campanulata'],
 u'pred_prob': [0.313213586807251,
 u'info': [u'99 images in DB',
           u'35 images in DB',
           u'67 images in DB',
           u'49 images in DB',
           u'47 images in DB'],
 u'google_images_link': ['',
 u'wikipedia_link': [u'',
 u'status': u'OK'

while unsuccessful responses will look like

{u'Error_description': u"Some urls were not in image format. Check you didn't uploaded a preview of the image rather than the image itself.",
 u'Error_type': u'Url image format error',
 u'status': u'error'}