Spaces:
Runtime error
Runtime error
File size: 1,552 Bytes
9568673 3e6df5c a84a79d 9568673 72c37b7 9568673 72c37b7 9568673 72c37b7 9568673 745cf6d a0db052 |
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 |
from transformers import AutoTokenizer, TFBertForSeq2SeqLM # Assuming TFBert model
# Load tokenizer configurations
source_tokenizer = AutoTokenizer.from_pretrained("https://huggingface.co/Bajiyo/mal_en_transliteration/tree/main/source_tokenizer_config.json")
target_tokenizer = AutoTokenizer.from_pretrained("https://huggingface.co/Bajiyo/mal_en_transliteration/tree/main/target_tokenizer_config.json")
from tensorflow.keras.models import load_model
model = load_model("https://huggingface.co/Bajiyo/mal_en_transliteration/tree/main/transliteration_model.h5")
# Load the model (replace with your actual model path)
#model = TFBertForSeq2SeqLM.from_pretrained("https://huggingface.co/Bajiyo/mal_en_transliteration/tree/main/transliteration_model.h5")
def translate(malayalam_text):
"""Function to perform Malayalam to English transliteration"""
source_ids = source_tokenizer(malayalam_text, return_tensors="pt")["input_ids"]
translated_tokens = model.generate(**source_ids)
english_text = target_tokenizer.batch_decode(translated_tokens, skip_special_tokens=True)[0]
return english_text
interface = gradio.Interface(
fn=translate,
inputs="text",
outputs="text",
title="Malayalam to English Transliteration",
description="Enter Malayalam text to get the English transliteration.",
examples=[["എങ്ങനെയാണ് ഞാൻ ഇംഗ്ലീഷിൽ സംസാരിക്കേണ്ടത്?"], ["ഹലോ എങ്ങനെയിരിക്കുന്നു?"]]
)
interface.launch()
|