Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -2,23 +2,28 @@
|
|
2 |
# Autor..: joinfv
|
3 |
# Data...: 20/11/2024
|
4 |
import gradio as gr
|
5 |
-
|
6 |
from transformers import pipeline
|
7 |
|
|
|
|
|
8 |
# Load model
|
9 |
pipe = pipeline("translation", model="Helsinki-NLP/opus-mt-tc-big-en-pt")
|
10 |
|
11 |
-
def
|
12 |
-
|
|
|
|
|
|
|
13 |
|
14 |
-
title = "Tradutor inglês para brasileiro"
|
15 |
|
16 |
-
|
17 |
-
fn=
|
18 |
-
inputs=
|
19 |
-
outputs=
|
20 |
-
title=
|
21 |
-
|
22 |
)
|
23 |
|
24 |
-
|
|
|
|
2 |
# Autor..: joinfv
|
3 |
# Data...: 20/11/2024
|
4 |
import gradio as gr
|
5 |
+
import json
|
6 |
from transformers import pipeline
|
7 |
|
8 |
+
# title = "Tradutor inglês para brasileiro"
|
9 |
+
|
10 |
# Load model
|
11 |
pipe = pipeline("translation", model="Helsinki-NLP/opus-mt-tc-big-en-pt")
|
12 |
|
13 |
+
def translate(text):
|
14 |
+
result = pipe(text)[0]["translation_text"]
|
15 |
+
return {"translation": result}
|
16 |
+
# return pipe(text)[0]["translation_text"]
|
17 |
+
|
18 |
|
|
|
19 |
|
20 |
+
demo = gr.Interface(
|
21 |
+
fn=translate,
|
22 |
+
inputs="text",
|
23 |
+
outputs="text",
|
24 |
+
title="Tradutor Inglês-Português",
|
25 |
+
description="Traduza textos do inglês para o português"
|
26 |
)
|
27 |
|
28 |
+
if __name__ == "__main__":
|
29 |
+
demo.launch()
|