mirror of
https://github.com/gradio-app/gradio.git
synced 2024-12-21 02:19:59 +08:00
Merge branch 'abidlabs/external' of github.com:gradio-app/gradio into abidlabs/external
This commit is contained in:
commit
5b29059481
@ -5,9 +5,10 @@ from gradio import inputs, outputs
|
||||
|
||||
def get_huggingface_interface(model_name, api_key, alias):
|
||||
api_url = "https://api-inference.huggingface.co/models/{}".format(model_name)
|
||||
|
||||
headers = {"Authorization": f"Bearer {api_key}"}
|
||||
|
||||
# Checking if model exists, and if so, it gets the pipeline
|
||||
response = requests.request("GET", api_url)
|
||||
response = requests.request("GET", api_url, headers=headers)
|
||||
assert response.status_code == 200, "Invalid model name or src"
|
||||
p = response.json().get('pipeline_tag')
|
||||
|
||||
@ -79,7 +80,7 @@ def get_huggingface_interface(model_name, api_key, alias):
|
||||
payload = pipeline['preprocess'](*input)
|
||||
payload.update({'options': {'wait_for_model': True}})
|
||||
data = json.dumps(payload)
|
||||
response = requests.request("POST", api_url, data=data)
|
||||
response = requests.request("POST", api_url, headers=headers, data=data)
|
||||
result = json.loads(response.content.decode("utf-8"))
|
||||
output = pipeline['postprocess'](result)
|
||||
return output
|
||||
|
Loading…
Reference in New Issue
Block a user