Skip to main content

High level abstraction for deploying simple machine learning models using Flask

Project description

Easy Serve

High level abstraction for deploying simple machine learning models using Flask. This project allows you to quickly deploy a small testing model locally as an API service without complicated setup.

Build Status PyPI version License: MIT

Getting started

  1. Install the package using pip command: pip install easy_serve
  2. Extend your model using EasyServe class.
  3. Run server using this command: python -m easy_deploy.serve --class_path PATH_TO_easy_serve_CLASS --class_name YOUR_CUSTOM_easy_serve --port PORT --model_args param1=value1;param2=value2

Example

  1. Create a file custom_model.py Here's a complete example of creating and deploying a simple model:
from easy_serve import EasyServe

class TextProcessor(EasyServe):
    def __init__(self, prefix=""):
        self.prefix = prefix
    
    def model_init(self):
        print("Model initialized!")
    
    def preprocessing(self, request):
        return request.json.get('text', '')
    
    def inference(self, text):
        return f"{self.prefix} {text}".strip()
    
    def postprocessing(self, result):
        return {"result": result.upper()}
  1. Run the server
python -m easy_serve.server --class_path custom_model --class_name TextProcessor --port 5000 --model_args prefix=Hello
  1. Test with curl:
curl -X POST http://localhost:5000/prediction -H "Content-Type: application/json" -d '{"text":"world"}'

Response:

{"result":"HELLO WORLD"}

Project details


Download files

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

Source Distribution

easy_serve-0.0.1.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

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

easy_serve-0.0.1-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file easy_serve-0.0.1.tar.gz.

File metadata

  • Download URL: easy_serve-0.0.1.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for easy_serve-0.0.1.tar.gz
Algorithm Hash digest
SHA256 a10c1d97554e41cb1f3cec14b61373615ead7ac7673c1e938e6c011a1ba15078
MD5 deccb57177655c01a0f15369cbdf624b
BLAKE2b-256 8b7d72f1f5a6c97f73306f63c6772e880255ee9498af52bed537b5f4f980d48c

See more details on using hashes here.

File details

Details for the file easy_serve-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: easy_serve-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for easy_serve-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 41e7508390dbdec90cf716cf6f319a3f19908fcb48298d15ab45424721a921ef
MD5 e60ad612bf2ca749e0b10539d04e1422
BLAKE2b-256 e16ddf68a8c4646d26f373a85210055aaecdaccbc4a9ecce1eab4fb056ab6e7c

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