File size: 671 Bytes
476e166
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21c3383
97e52ab
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import requests
import os
import gradio as gr

title = "Translate Text"
description = """"""
article = "Check out [the original repo](https://huggingface.co/language-tools/language-translation) that this demo is based off of."


API_URL = "https://api-inference.huggingface.co/models/t5-base"
ACCESS_TOKEN = os.environ.get("ACCESS_TOKEN")
headers = {"Authorization": f"Bearer {ACCESS_TOKEN}"}

def query(payload):
    response = requests.post(API_URL, headers=headers, json={"inputs": payload})
    return response.json()
	
gr.Interface(
    fn=query,
    inputs="textbox",
    outputs="text",
    title=title,
    description=description,
    article=article
).launch()