Рет қаралды 15,157
In this video, I show you how to deploy Transformer models straight from the Hugging Face hub to managed infrastructure on AWS, in just a few clicks. Starting from a model that I already trained for image classification, I first deploy an endpoint protected by Hugging Face token authentication. Then, I deploy a second endpoint in a private subnet, and I show you how to access it securely from your AWS account thanks to AWS PrivateLink.
⭐️⭐️⭐️ Don't forget to subscribe to be notified of future videos ⭐️⭐️⭐️
⭐️⭐️⭐️ Want to buy me a coffee? I can always use more :) www.buymeacoffee.com/julsimon ⭐️⭐️⭐️
- Model: huggingface.co/juliensimon/au...
- Inference Endpoints: huggingface.co/inference-endp...
- Inference Endpoints documentation: huggingface.co/docs/inference...
- AWS PrivateLink documentation: docs.aws.amazon.com/vpc/lates...
Code:
import requests, json, os
API_URL = ENDPOINT_URL
MY_API_TOKEN = os.getenv("MY_API_TOKEN")
headers = {"Authorization": "Bearer "+MY_API_TOKEN, "Content-Type": "image/jpg"}
def query(filename):
with open(filename, "rb") as f:
data = f.read()
response = requests.request("POST", API_URL, headers=headers, data=data)
return json.loads(response.content.decode("utf-8"))
output = query("food.jpg")