Update app.py
Browse files
app.py
CHANGED
@@ -1,17 +1,17 @@
|
|
|
|
|
|
1 |
from transformers import pipeline
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
)
|
7 |
-
|
8 |
-
|
9 |
-
for i in range(50):
|
10 |
-
result = fill_mask(text)
|
11 |
-
r = result[random.randint(0, 4)]["sequence"]
|
12 |
-
if r not in generated_text_set:
|
13 |
-
print(r)
|
14 |
-
text = r + " [MASK]"
|
15 |
-
generated_text_set.add(r)
|
16 |
-
else:
|
17 |
-
continue
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
from transformers import pipeline
|
4 |
+
|
5 |
+
pipe = pipeline("translation", model="Helsinki-NLP/opus-mt-en-es")
|
6 |
+
|
7 |
+
def predict(text):
|
8 |
+
return pipe(text)[0]["translation_text"]
|
9 |
+
|
10 |
+
iface = gr.Interface(
|
11 |
+
fn=predict,
|
12 |
+
inputs='text',
|
13 |
+
outputs='text',
|
14 |
+
examples=[["Hello! My name is Omar"]]
|
15 |
)
|
16 |
+
|
17 |
+
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|