Spaces:
Runtime error
Runtime error
File size: 1,089 Bytes
34d0b6c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
import gradio as gr # UI library
from transformers import pipeline # Transformers pipeline
model_checkpoint_en2fil = "SalamaThanks/SalamaThanksTransformer_en2fil_v2"
model_checkpoint_fil2en = "SalamaThanks/SalamaThanksTransformer_fil2en_v2"
translator_en2fil = pipeline("translation", model = model_checkpoint_en2fil)
translator_fil2en = pipeline("translation", model = model_checkpoint_fil2en)
def transformer_en2fil(from_text):
results = translator_en2fil(from_text)
return results[0]['translation_text']
def transformer_fil2en(from_text):
results = translator_fil2en(from_text)
return results[0]['translation_text']
def check_lang(lang, from_text):
if lang == "English-to-Filipino":
return transformer_en2fil(from_text)
elif lang == "Filipino-to-English":
return transformer_fil2en(from_text)
interface = gr.Interface(
fn=check_lang,
inputs=[
gr.inputs.Radio(["English-to-Filipino", "Filipino-to-English"]),
gr.inputs.Textbox(lines=4, placeholder='Input Text to Translate:')],
outputs='text'
)
interface.launch(debug=True) |