Downloads · 30 days
0
nbroad/p2s-infographic-lg-endpt
p2s-infographic-lg-endpt is a machine learning model from nbroad. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as apache-2.0.
This repo deploys a pix2struct model to Inference Endpoints to a single GPU. This is not meant for multiple GPUs (single gpu replicas are ok; don't use the 4xT4 option, though) or CPU.
Downloads · 30 days
0
Access
Public
Updated Nov 23, 2023
Repo size
—
Likes
0
Public
Click a slice to open those files.
.py2.3 KB · 32%
From the Hugging Face model README
This repo deploys a pix2struct model to Inference Endpoints to a single GPU. This is not meant for multiple GPUs (single gpu replicas are ok; don't use the 4xT4 option, though) or CPU.
Options:
model_name to "./"After deploying the model, inference can be done as follows:
import base64
with open("path/to/image", "rb") as f:
b64 = base64.b64encode(f.read())
question = "question to model"
payload = {
"inputs": {
"image": [b64.decode("utf-8")], # for batched inference, send list of images/questions
"question": [question]
},
"parameters":{
"max_new_tokens": 10, # can use any generation parameters
}}
import requests
API_URL = "url_to_endpoint"
headers = {
"Authorization": "Bearer HF_TOKEN",
"Content-Type": "application/json"
}
def query(payload):
response = requests.post(API_URL, headers=headers, json=payload)
return response.json()
output = query(payload)
# {'output': ['55%']}