Spaces:
Runtime error
Runtime error
Commit
·
2cdde71
1
Parent(s):
b9a154d
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
-
|
2 |
-
import
|
3 |
-
from transformers import pipeline
|
4 |
|
5 |
model_checkpoint_en2fil = "SalamaThanks/SalamaThanksTransformer_en2fil_v2"
|
6 |
model_checkpoint_fil2en = "SalamaThanks/SalamaThanksTransformer_fil2en_v2"
|
@@ -8,28 +7,20 @@ model_checkpoint_fil2en = "SalamaThanks/SalamaThanksTransformer_fil2en_v2"
|
|
8 |
translator_en2fil = pipeline("translation", model = model_checkpoint_en2fil)
|
9 |
translator_fil2en = pipeline("translation", model = model_checkpoint_fil2en)
|
10 |
|
11 |
-
|
12 |
-
#Function for English-Filipino translation
|
13 |
def transformer_en2fil(from_text):
|
14 |
results = translator_en2fil(from_text)
|
15 |
return results[0]['translation_text']
|
16 |
|
17 |
-
|
18 |
-
#Function for Filipino-English translation
|
19 |
def transformer_fil2en(from_text):
|
20 |
results = translator_fil2en(from_text)
|
21 |
return results[0]['translation_text']
|
22 |
|
23 |
-
|
24 |
-
#Function to check the "language to translate"
|
25 |
def check_lang(lang, from_text):
|
26 |
if lang == "English-to-Filipino":
|
27 |
return transformer_en2fil(from_text)
|
28 |
elif lang == "Filipino-to-English":
|
29 |
return transformer_fil2en(from_text)
|
30 |
|
31 |
-
|
32 |
-
#Creating the Gradio Interface
|
33 |
interface = gr.Interface(
|
34 |
fn=check_lang,
|
35 |
inputs=[
|
@@ -38,7 +29,4 @@ interface = gr.Interface(
|
|
38 |
outputs='text'
|
39 |
)
|
40 |
|
41 |
-
|
42 |
-
|
43 |
-
#Running the application
|
44 |
interface.launch(debug=True)
|
|
|
1 |
+
import gradio as gr # UI library
|
2 |
+
from transformers import pipeline # Transformers pipeline
|
|
|
3 |
|
4 |
model_checkpoint_en2fil = "SalamaThanks/SalamaThanksTransformer_en2fil_v2"
|
5 |
model_checkpoint_fil2en = "SalamaThanks/SalamaThanksTransformer_fil2en_v2"
|
|
|
7 |
translator_en2fil = pipeline("translation", model = model_checkpoint_en2fil)
|
8 |
translator_fil2en = pipeline("translation", model = model_checkpoint_fil2en)
|
9 |
|
|
|
|
|
10 |
def transformer_en2fil(from_text):
|
11 |
results = translator_en2fil(from_text)
|
12 |
return results[0]['translation_text']
|
13 |
|
|
|
|
|
14 |
def transformer_fil2en(from_text):
|
15 |
results = translator_fil2en(from_text)
|
16 |
return results[0]['translation_text']
|
17 |
|
|
|
|
|
18 |
def check_lang(lang, from_text):
|
19 |
if lang == "English-to-Filipino":
|
20 |
return transformer_en2fil(from_text)
|
21 |
elif lang == "Filipino-to-English":
|
22 |
return transformer_fil2en(from_text)
|
23 |
|
|
|
|
|
24 |
interface = gr.Interface(
|
25 |
fn=check_lang,
|
26 |
inputs=[
|
|
|
29 |
outputs='text'
|
30 |
)
|
31 |
|
|
|
|
|
|
|
32 |
interface.launch(debug=True)
|