mirror of
https://github.com/gradio-app/gradio.git
synced 2024-12-27 02:30:17 +08:00
working on transforms
This commit is contained in:
parent
5b29059481
commit
1ef0258e6d
@ -5,7 +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}"}
|
||||
if api_key is not None:
|
||||
headers = {"Authorization": f"Bearer {api_key}"}
|
||||
else:
|
||||
headers = {}
|
||||
|
||||
# Checking if model exists, and if so, it gets the pipeline
|
||||
response = requests.request("GET", api_url, headers=headers)
|
||||
@ -81,8 +84,11 @@ def get_huggingface_interface(model_name, api_key, alias):
|
||||
payload.update({'options': {'wait_for_model': True}})
|
||||
data = json.dumps(payload)
|
||||
response = requests.request("POST", api_url, headers=headers, data=data)
|
||||
result = json.loads(response.content.decode("utf-8"))
|
||||
output = pipeline['postprocess'](result)
|
||||
if response.status_code == 200:
|
||||
result = json.loads(response.content.decode("utf-8"))
|
||||
output = pipeline['postprocess'](result)
|
||||
else:
|
||||
raise ValueError("Could not complete request to HuggingFace API, Error {}".format(response.status_code))
|
||||
return output
|
||||
|
||||
if alias is None:
|
||||
|
@ -3,7 +3,7 @@ Ways to transform interfaces to produce new interfaces
|
||||
"""
|
||||
from gradio.interface import Interface
|
||||
|
||||
def compare(*interfaces, **options):
|
||||
def parallel(*interfaces, **options):
|
||||
fns = []
|
||||
outputs = []
|
||||
|
||||
@ -15,7 +15,7 @@ def compare(*interfaces, **options):
|
||||
repeat_outputs_per_model=False, **options)
|
||||
|
||||
|
||||
def cascade(*interfaces, **options):
|
||||
def series(*interfaces, **options):
|
||||
fns = [io.predict for io in interfaces]
|
||||
|
||||
def connected_fn(data): # actually not used.
|
||||
|
Loading…
Reference in New Issue
Block a user