Tool for creating nanowire tools with the flask structure.
Project description
**Nanowire flask**
This library is designed to allow a python developer to easily create a nanowire plugin using the flask APIs structure.
The function you mount, 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 desired variables. In this case your variables will be ``self``, ``img`` and ``variables``.
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``
alternativly 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
**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`:- Activate or deactivate debug mode. When active will return full traceback from API when an error occurs during processing.Input must be boolean
* `host`:- default is '0.0.0.0'. Set the IP address to host the API on
* `port`:- default 5000. Set the port to host the API on
* `path`:- default '/model/predict'. Set the path for the API```
This library is designed to allow a python developer to easily create a nanowire plugin using the flask APIs structure.
The function you mount, 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 desired variables. In this case your variables will be ``self``, ``img`` and ``variables``.
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``
alternativly 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
**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`:- Activate or deactivate debug mode. When active will return full traceback from API when an error occurs during processing.Input must be boolean
* `host`:- default is '0.0.0.0'. Set the IP address to host the API on
* `port`:- default 5000. Set the port to host the API on
* `path`:- 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.15.tar.gz
(3.5 kB
view hashes)
Built Distribution
Close
Hashes for nanowire_flask-0.0.15-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c5c1372a657bb38514644534b6eab7b95c965ae038545ffddfbf38cadd1b4828 |
|
MD5 | a84c749cca021aba9bc3b6ac277a8e83 |
|
BLAKE2b-256 | 9914bdbde3bf47a99b3bb4b685c3a4ffb087eacff1fd15440d663b8d97fa1f9c |