Created
October 12, 2022 15:16
-
-
Save amrrs/0c6114896c66df20760a8727c3f6aadc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
model_id = "nvidia/segformer-b0-finetuned-ade-512-512" | |
api_token = # get yours at hf.co/settings/tokens | |
headers = {"Authorization": f"Bearer {api_token}"} | |
API_URL = f"https://api-inference.huggingface.co/models/{model_id}" | |
def query(data, model_id, api_token): | |
with open(filename, "rb") as f: | |
data = f.read() | |
response = requests.post(API_URL, headers=headers, data=data) | |
return response.json() | |
filename = 'SCR-tfa.jpeg' | |
data = query(filename, model_id, api_token) | |
print(data) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment