Spaces:
Runtime error
Runtime error
+ Switch to api-inference
Browse files
app.py
CHANGED
|
@@ -2,7 +2,7 @@ import gradio as gr
|
|
| 2 |
import json
|
| 3 |
import requests
|
| 4 |
|
| 5 |
-
API_URL = "https://huggingface.co/Helsinki-NLP/opus-mt-en-ga"
|
| 6 |
headers = {"Authorization": "Bearer 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"}
|
| 7 |
|
| 8 |
def translate(English):
|
|
@@ -11,8 +11,9 @@ def translate(English):
|
|
| 11 |
}
|
| 12 |
response = requests.post(API_URL, headers=headers, json=payload)
|
| 13 |
httpresponse = response.json()
|
| 14 |
-
print(httpresponse)
|
| 15 |
-
return httpresponse[0]["generated_text"]
|
|
|
|
| 16 |
|
| 17 |
iface = gr.Interface(
|
| 18 |
fn=translate,
|
|
@@ -22,7 +23,7 @@ iface = gr.Interface(
|
|
| 22 |
layout='aligned'
|
| 23 |
)
|
| 24 |
|
| 25 |
-
gr.outputs.Textbox(type="str", label=
|
| 26 |
|
| 27 |
if __name__ == "__main__":
|
| 28 |
app, local_url, share_url = iface.launch()
|
|
|
|
| 2 |
import json
|
| 3 |
import requests
|
| 4 |
|
| 5 |
+
API_URL = "https://api-inference.huggingface.co/models/Helsinki-NLP/opus-mt-en-ga"
|
| 6 |
headers = {"Authorization": "Bearer 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"}
|
| 7 |
|
| 8 |
def translate(English):
|
|
|
|
| 11 |
}
|
| 12 |
response = requests.post(API_URL, headers=headers, json=payload)
|
| 13 |
httpresponse = response.json()
|
| 14 |
+
# print(httpresponse)
|
| 15 |
+
# return httpresponse[0]["generated_text"]
|
| 16 |
+
return httpresponse[0]["translation_text"]
|
| 17 |
|
| 18 |
iface = gr.Interface(
|
| 19 |
fn=translate,
|
|
|
|
| 23 |
layout='aligned'
|
| 24 |
)
|
| 25 |
|
| 26 |
+
gr.outputs.Textbox(type="str", label="Irish")
|
| 27 |
|
| 28 |
if __name__ == "__main__":
|
| 29 |
app, local_url, share_url = iface.launch()
|