Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,31 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
-
model.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from keras.models import load_model
|
3 |
+
from keras.preprocessing.sequence import pad_sequences
|
4 |
|
5 |
+
# Load your custom Keras model
|
6 |
+
model = load_model('models/Bajiyo/Named_entity_transliteration_malayalam"')
|
7 |
+
|
8 |
+
# Function for transliteration
|
9 |
+
def transliterate_malayalam_to_english(malayalam_text):
|
10 |
+
# Tokenize and preprocess the input (adjust this based on your preprocessing logic)
|
11 |
+
input_sequence = pad_sequences(tokenizer.texts_to_sequences([malayalam_text]), maxlen=max_seq_length, padding='post')
|
12 |
+
|
13 |
+
# Use the model for prediction
|
14 |
+
output_sequence = model.predict(input_sequence)
|
15 |
+
|
16 |
+
# Decode the output sequence to get the transliterated text (adjust this based on your decoding logic)
|
17 |
+
predicted_text = decode_output_sequence(output_sequence)
|
18 |
+
|
19 |
+
return predicted_text
|
20 |
+
|
21 |
+
# Create a Gradio interface
|
22 |
+
iface = gr.Interface(
|
23 |
+
fn=transliterate_malayalam_to_english,
|
24 |
+
inputs=gr.Textbox(prompt="Enter Malayalam Text", lines=5),
|
25 |
+
outputs=gr.Textbox(prompt="Transliterated English Text", lines=5),
|
26 |
+
live=True
|
27 |
+
)
|
28 |
+
|
29 |
+
# Launch the Gradio interface
|
30 |
+
iface.launch()
|
31 |
|
|