Skip to main content

Serving pytorch models on an API in one line.

Project description

pytorch-deploy

Usage

from torch_deploy import deploy
deploy(your_model)

deploy Function

deploy(model: nn.Module, pre: Union[List[Callable], Callable] = None, post: Union[List[Callable], Callable] = None, host: str = "0.0.0.0", port: int = 8000, logfile: str = None)

Easily converts a pytorch model to API for production usage.

  • model: A PyTorch model which subclasses nn.Module and is callable. Model used for the API.
  • pre: A function or list of functions to be applied to the input.
  • post: Function or list of functions applied to model output before being sent as a response.
  • host: The address for serving the model.
  • port: The port for serving the model.
  • logfile: filename to create a file that stores date, ip address, and size of input for each access of the API. If None, no file will be created.

Sample Response Format

Sample Code

Testing

Run python test_server.py first and then python test_client.py in another window to test.

Dependencies

torch, torchvision, fastapi[all], requests, numpy, pydantic

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

pytorch-deploy-0.0.1.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

pytorch_deploy-0.0.1-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file pytorch-deploy-0.0.1.tar.gz.

File metadata

  • Download URL: pytorch-deploy-0.0.1.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for pytorch-deploy-0.0.1.tar.gz
Algorithm Hash digest
SHA256 cf32013cd9642db4a78839b5ccce621fcc3037d4916334c816c70f79b6b9a66a
MD5 1656881acb96196df8573caf2cbae291
BLAKE2b-256 b51351029bc877a3d741cf07482c1d992b3401f9548f6b8182c0f157185c135b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pytorch_deploy-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for pytorch_deploy-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a4cd506d06f6230d4fc9c8088613a9756c1f0bef95af2c174662a29242cd33ea
MD5 b7c6fda6065870386f6c4c071e15e089
BLAKE2b-256 e27130d29f911f5c2071f3b785d80e417bfa407fbb62e97c197a895d2dffcd63

See more details on using hashes here.

Supported by

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