Spaces:
Runtime error
Runtime error
Upload with huggingface_hub
Browse files- app.py +27 -0
- requirements.txt +4 -0
app.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
pipe = pipeline("translation", model="Helsinki-NLP/opus-mt-en-it")
|
5 |
+
|
6 |
+
def main(in_text):
|
7 |
+
print(in_text)
|
8 |
+
answer = pipe(in_text)
|
9 |
+
print(answer)
|
10 |
+
return answer[0]["translation_text"]
|
11 |
+
|
12 |
+
with gr.Blocks() as demo:
|
13 |
+
gr.Markdown("""# Translation Engine!""")
|
14 |
+
with gr.Row():
|
15 |
+
with gr.Column():
|
16 |
+
text1 = gr.Textbox(
|
17 |
+
label="Input Text",
|
18 |
+
lines=1,
|
19 |
+
)
|
20 |
+
output = gr.Textbox(label="Output Text")
|
21 |
+
b1 = gr.Button("Translate!")
|
22 |
+
b1.click(main, inputs=[text1], outputs=output)
|
23 |
+
gr.Markdown("""#### powered by [Tassle](https://bit.ly/3LXMklV)""")
|
24 |
+
|
25 |
+
|
26 |
+
if __name__ == "__main__":
|
27 |
+
demo.launch(debug=True)
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
transformers
|
3 |
+
torch
|
4 |
+
sentencepiece
|