Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,25 +1,24 @@
|
|
1 |
-
#
|
2 |
-
#Autor..: joinfv
|
3 |
-
#Data...:20/11/2024
|
4 |
import gradio as gr
|
5 |
|
6 |
from transformers import pipeline
|
7 |
|
8 |
-
#
|
9 |
pipe = pipeline("translation", model="Helsinki-NLP/opus-mt-tc-big-en-pt")
|
10 |
|
11 |
def predict(text):
|
12 |
-
|
13 |
-
|
14 |
-
title = "Tradutor inglês para Brasileires"
|
15 |
-
iface = gr.Interface(fn="predict", inputs=[gr.Textbox(label="text", lines=3)], outputs='text', title=title, api_name="predict")
|
16 |
|
|
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
24 |
|
25 |
iface.launch()
|
|
|
1 |
+
# Tradutor NQ usando pipelines
|
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 predict(text):
|
12 |
+
return pipe(text)[0]["translation_text"]
|
|
|
|
|
|
|
13 |
|
14 |
+
title = "Tradutor inglês para brasileiro"
|
15 |
|
16 |
+
iface = gr.Interface(
|
17 |
+
fn=predict, # Passa a referência à função predict
|
18 |
+
inputs=[gr.Textbox(label="text", lines=3)],
|
19 |
+
outputs='text',
|
20 |
+
title=title,
|
21 |
+
api_name="predict"
|
22 |
+
)
|
23 |
|
24 |
iface.launch()
|