Downloads · 30 days
0
Dheerajsahi/hf-inference-endpoints
hf-inference-endpoints is a machine learning model from Dheerajsahi. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
This project demonstrates how to deploy a fine-tuned model to Hugging Face Inference Endpoints, making it accessible via a REST API.
Downloads · 30 days
0
Access
Public
Updated Dec 22, 2025
Repo size
—
Likes
0
Public
Click a slice to open those files.
.py10.5 KB · 61%
From the Hugging Face model README
This project demonstrates how to deploy a fine-tuned model to Hugging Face Inference Endpoints, making it accessible via a REST API.
Deployment Setup: Created scripts and documentation for deploying models to Hugging Face Inference Endpoints, which provides a managed, scalable way to serve models in production.
Endpoint Management: Implemented functionality to:
Testing: Created a test script to make requests to deployed endpoints and verify they're working correctly.
deploy_endpoint.py: Script to create and manage Inference Endpointstest_endpoint.py: Script to test a deployed endpointREADME.md: This fileNavigate to Inference Endpoints:
Configure Endpoint:
imdb-sentiment-classifier)your-username/imdb-sentiment-distilbert)CPU-2: For testing and low trafficGPU-T4-Small: For moderate trafficGPU-T4-Medium or larger: For high trafficDeploy:
Get Endpoint URL:
https://xxxxx.us-east-1.aws.endpoints.huggingface.cloudfrom huggingface_hub import HfApi
api = HfApi()
endpoint = api.create_inference_endpoint(
name="imdb-sentiment-classifier",
repository="your-username/imdb-sentiment-distilbert",
framework="pytorch",
task="text-classification",
instance_type="cpu-2",
region="us-east-1",
vendor="aws",
)
See deploy_endpoint.py for a complete example.
import requests
endpoint_url = "https://your-endpoint-url"
headers = {
"Authorization": "Bearer YOUR_HF_TOKEN",
"Content-Type": "application/json"
}
payload = {
"inputs": "This movie was fantastic!"
}
response = requests.post(f"{endpoint_url}/", headers=headers, json=payload)
print(response.json())
Or use the provided test script:
export HF_ENDPOINT_URL="https://your-endpoint-url"
export HF_TOKEN="your-token"
python test_endpoint.py
curl https://your-endpoint-url/ \
-X POST \
-H "Authorization: Bearer YOUR_HF_TOKEN" \
-H "Content-Type: application/json" \
-d '{"inputs": "This movie was fantastic!"}'
from huggingface_hub import HfApi
api = HfApi()
endpoints = api.list_inference_endpoints()
for endpoint in endpoints:
print(f"{endpoint.name}: {endpoint.status}")
You can update instance type, scale, or other settings through the web interface or API.
Via Web Interface:
Via API:
api.delete_inference_endpoint("imdb-sentiment-classifier")
For a text classification endpoint, the response will look like:
[
{
"label": "POSITIVE",
"score": 0.9998
}
]