Skip to main content

A package that sets up a local API Endpoint for a model from the HuggingFace Model Hub.

Project description

HFEndpoint - Set up local API Endpoint for any HuggingFace model

This package provides the user with one method that opens a local API endpoint for any from HuggingFace Model Hub.

This package utilizes the FastAPI library to set up an API Endpoint under 127.0.0.1:8000/docs. It also makes use of HuggingFace's transformers package, pydantic, and a package I created hfloader. Which can be found here.

Installation

The package can be installed with the following command:

pip install hfendpoint

How to Use

To use this package, all you need to do is import the package via this command.

from hfendpoint import LoadApiEndpoint

The function LoadApiEndpoint expects one variable of type str. This can be a local path to a model, or any package on the HuggingFace Model Hub.

Usage may look something along the lines of:

from hfendpoint import LoadApiEndpoint

app = LoadApiEndpoint("cardiffnlp/twitter-roberta-base-sentiment")

Important:

After running the script and loading the api endpoint, you have to call this command in cmd:

uvicorn script:app --reload

So, if the script that was written was called script.py, you need to exclude the .py in the command call.

Requirements

pip install transformers pip install fastapi pip install uvicorn pip install pydantic

Notes

I don't have plans to upkeep this project unless it necessitates it. I was able to achieve the goal I had set out when developing the package.

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

hfendpoint-1.0.3.tar.gz (2.6 kB view hashes)

Uploaded Source

Built Distribution

hfendpoint-1.0.3-py3-none-any.whl (3.0 kB view hashes)

Uploaded Python 3

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