Spaces:
Runtime error
Runtime error
File size: 1,042 Bytes
4ac6c50 876cd0e f1cb04e 876cd0e c6e8f66 fa3d9d8 876cd0e 4ac6c50 536f202 876cd0e 536f202 876cd0e eab36ec 876cd0e 05ba1e9 5461f92 05ba1e9 |
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 33 34 35 |
from blurr.text.data.all import *
from blurr.text.modeling.all import *
from huggingface_hub import hf_hub_download
from fastai.learner import load_learner
from transformers import *
import gradio as gr
def download():
#pretrained_model_name = "Helsinki-NLP/opus-mt-en-ml"
#model_cls = AutoModelForSeq2SeqLM
#hf_arch, hf_config, hf_tokenizer, hf_model = get_hf_objects(pretrained_model_name, model_cls=model_cls)
model = load_learner(hf_hub_download("kurianbenoy/kde_en_ml_translation_model", "model.pkl"))
return model
def translate_text(text):
model = download()
outputs = model.blurr_translate(text)
return outputs[0]["translation_texts"]
iface = gr.Interface(
fn=translate_text,
inputs=gr.inputs.Textbox(lines=2, label="Enter Text in English", placeholder="Type text in English Here..."),
outputs="text",
theme="huggingface",
examples=["Add All Found Feeds to Akregator.", "Hello world",]
)
iface.launch(
share=False,
cache_examples=True,
enable_queue=True,
)
|