Spaces:
Runtime error
Runtime error
import gradio as gr | |
from huggingface_hub import from_pretrained_keras | |
# Load the model from Hugging Face Hub | |
model = from_pretrained_keras("Bajiyo/Malayalam_transliteration") | |
# Function to preprocess text (replace with model-specific preprocessing if needed) | |
def preprocess_text(input_text): | |
# Assuming character-level model: convert text to sequence of integer indices | |
# Replace with your specific preprocessing steps based on the model's requirements | |
# You might need tokenization or other transformations | |
# ... | |
return preprocessed_text | |
def transliterate(input_text): | |
# Preprocess the input text | |
preprocessed_text = preprocess_text(input_text) | |
# Make predictions using the model | |
predictions = model.predict(preprocessed_text) | |
# Post-process the predictions if needed (replace with your logic) | |
output_text = predictions # Assuming model outputs transliteration directly | |
return output_text | |
textbox = gr.inputs.Textbox(label="Enter Malayalam Text") | |
demo = gr.Interface(fn=transliterate, | |
inputs=textbox, | |
outputs=gr.outputs.Textbox(label="Transliteration to English"), | |
title="Malayalam to English Transliteration" | |
) | |
demo.launch() | |