Spaces:
Runtime error
Runtime error
add simple Space
Browse files- .gitignore +3 -0
- app.py +25 -0
.gitignore
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
flagged/
|
2 |
+
.python-version
|
3 |
+
.DS_Store
|
app.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import requests
|
2 |
+
import os
|
3 |
+
import gradio as gr
|
4 |
+
|
5 |
+
title = "Translate Text"
|
6 |
+
description = """"""
|
7 |
+
article = "Check out [the original repo](https://huggingface.co/language-tools/language-translation) that this demo is based off of."
|
8 |
+
|
9 |
+
|
10 |
+
API_URL = "https://api-inference.huggingface.co/models/t5-base"
|
11 |
+
ACCESS_TOKEN = os.environ.get("ACCESS_TOKEN")
|
12 |
+
headers = {"Authorization": f"Bearer {ACCESS_TOKEN}"}
|
13 |
+
|
14 |
+
def query(payload):
|
15 |
+
response = requests.post(API_URL, headers=headers, json={"inputs": payload})
|
16 |
+
return response.json()
|
17 |
+
|
18 |
+
gr.Interface(
|
19 |
+
fn=query,
|
20 |
+
inputs="textbox",
|
21 |
+
outputs="text",
|
22 |
+
title=title,
|
23 |
+
description=description,
|
24 |
+
article=article,
|
25 |
+
).launch()
|