Skip to main content

Tool for creating nanowire tools with the flask structure.

Project description

This library is designed to allow a python developer to easily create a nanowire plugin using the flask APIs structure.

The function you mount for image plugins, using the class ImagesAPI, must have the arguments img and variables if you want initialise a model or other variables when the sever starts you may make the function to be mounted into a function of a class which is initiated with the des$ You should expect img to be a PIL RGB image object and variables to be a dictionary containing the variables sent to the plugin in the curl request.

The curl requests for images may be formatted 2 ways. The first involves sending the image as a file attached to the curl request. For example:

curl -F "image=@./1.jpg" -XPOST http://0.0.0.0:5000/model/predict?threshold=0.5

alternatively the file may be sent as a link using a dictionary eg.

curl -X POST -H "Content-Type:application/json" -d '{"contentURL":"http://127.0.0.1:8000/1.jpg", "threshold":0.5}' http://0.0.0.0:5000/model/predict

At the moment it can only handle images however it will soon be expanded to handle text and eventually video and sound. The currently supported image formats are:

  • jpg

  • png

  • bmp

  • tif

  • ppm

The process for text is similar except that you should use the class TextAPI and the function should only use the arguments text and variables. You may either post a document containing the text using the command

curl -F "doc=@./doc1.txt" -XPOST http://0.0.0.0:5000/model/predict?deactivate_ngrams=True

or the raw text can be sent using:

curl -X POST -H "Content-Type:application/json" -d '{"content":"Example text about whichever subject you're interested in", "deactivate_ngrams"="True"}' http://0.0.0.0:5000/model/predict

Notes for advanced users

mount_Image_function

Parameters

  • function :- The function to be mounted on the API. The function must take img and variable as arguments and return a dictionary

  • debug_mode optional:- default is False. Set to true to activate debug mode. When active will return full traceback from API when an error occurs during processing.Input must be boolean.

  • host optional:- default is ‘0.0.0.0’. Set the IP address to host the API on

  • port optional:- default 5000. Set the port to host the API on

  • path optional:- default ‘/model/predict’. Set the path for the API

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nanowire_flask-0.0.51.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nanowire_flask-0.0.51-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file nanowire_flask-0.0.51.tar.gz.

File metadata

  • Download URL: nanowire_flask-0.0.51.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/2.7.15rc1

File hashes

Hashes for nanowire_flask-0.0.51.tar.gz
Algorithm Hash digest
SHA256 95b57a3955ce130304b53c4410907f8fc91c450b5a332503b060fabf6e4a39bd
MD5 480b1972986cef2cc34984facf7a9cb7
BLAKE2b-256 fe5caaf553e3125f0473c29b71a823de38779d8af1dc1bfca7bf7cfe63285569

See more details on using hashes here.

File details

Details for the file nanowire_flask-0.0.51-py3-none-any.whl.

File metadata

  • Download URL: nanowire_flask-0.0.51-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/2.7.15rc1

File hashes

Hashes for nanowire_flask-0.0.51-py3-none-any.whl
Algorithm Hash digest
SHA256 f4388b394e7bface599910e52c12615f2ff3aca1d87e2f0bcbf7e2517554fc6c
MD5 31157d0e40173f21b4f25bdaa2ec510b
BLAKE2b-256 6e79b8106e660592451c98e2bf7a50a0441f1ebc98d9fc48ec20ee39f3f74417

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page