Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,23 +1,22 @@
|
|
1 |
import gradio as gr
|
2 |
-
from
|
|
|
3 |
|
4 |
-
# Load your custom
|
5 |
-
|
6 |
-
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
|
7 |
-
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
8 |
|
9 |
# Function for transliteration
|
10 |
def transliterate_malayalam_to_english(malayalam_text):
|
11 |
-
# Tokenize the input
|
12 |
-
|
13 |
-
|
14 |
# Use the model for prediction
|
15 |
-
|
16 |
|
17 |
-
# Decode the output sequence
|
18 |
-
|
19 |
|
20 |
-
return
|
21 |
|
22 |
# Create a Gradio interface
|
23 |
iface = gr.Interface(
|
@@ -28,4 +27,4 @@ iface = gr.Interface(
|
|
28 |
)
|
29 |
|
30 |
# Launch the Gradio interface
|
31 |
-
iface.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('/content/drive/MyDrive/best_model.h5')
|
|
|
|
|
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(
|
|
|
27 |
)
|
28 |
|
29 |
# Launch the Gradio interface
|
30 |
+
iface.launch()
|