Views
No views yet
binary. Below is an curl and python examplewget https://fki.tic.heia-fr.ch/static/img/a01-122-02-00.jpg -O test.jpg1curl --request POST \
2 --url https://{ENDPOINT}/ \
3 --header 'Content-Type: image/jpg' \
4 --header 'Authorization: Bearer {HF_TOKEN}' \
5 --data-binary '@test.jpg'{"text": "INDLUS THE"}wget https://fki.tic.heia-fr.ch/static/img/a01-122-02-00.jpg -O test.jpg1import json
2from typing import List
3import requests as r
4import base64
5
6ENDPOINT_URL=""
7HF_TOKEN=""
8
9def predict(path_to_image:str=None):
10 with open(path_to_image, "rb") as i:
11 b = i.read()
12 headers= {
13 "Authorization": f"Bearer {HF_TOKEN}",
14 "Content-Type": "image/jpeg" # content type of image
15 }
16 response = r.post(ENDPOINT_URL, headers=headers, data=b)
17 return response.json()
18
19prediction = predict(path_to_image="test.jpg")
20
21prediction{"text": "INDLUS THE"}