import gradio as gr from transformers import AutoTokenizer, AutoModelForSeq2SeqLM # Model and Tokenizer Names (replace if needed) MODEL_NAME = "Bajiyo/Malayalam_transliteration" TOKENIZER_NAME = f"{MODEL_NAME}-vocab" # Load the tokenizer and model tokenizer = AutoTokenizer.from_pretrained(TOKENIZER_NAME) model = AutoModelForSeq2SeqLM.from_pretrained(MODEL_NAME) def predict(text): input_ids = tokenizer.encode(text, return_tensors="pt") outputs = model.generate(input_ids) decoded_text = tokenizer.decode(outputs[0], skip_special_tokens=True) return decoded_text interface = gr.Interface( fn=predict, inputs=gr.Textbox(label="Enter Malayalam Text"), outputs=gr.Textbox(label="Predicted English Text"), title="Malayalam to English Transliteration", description="Enter Malayalam text in the box and click 'Predict' to get the English transliteration.", ) interface.launch()