Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -5,9 +5,6 @@ from keras.preprocessing.text import Tokenizer
|
|
5 |
|
6 |
# Load your custom Keras model
|
7 |
model = load_model('/content/drive/MyDrive/best_model.h5')
|
8 |
-
|
9 |
-
# Assuming 'source_tokenizer' is the tokenizer used during training
|
10 |
-
# You may need to adapt this based on your actual tokenizer
|
11 |
tokenizer = source_tokenizer
|
12 |
|
13 |
# Function for transliteration
|
@@ -18,8 +15,8 @@ def transliterate_malayalam_to_english(malayalam_text):
|
|
18 |
# Use the model for prediction
|
19 |
output_sequence = model.predict(input_sequence)
|
20 |
|
21 |
-
#
|
22 |
-
predicted_text =
|
23 |
|
24 |
return predicted_text
|
25 |
|
|
|
5 |
|
6 |
# Load your custom Keras model
|
7 |
model = load_model('/content/drive/MyDrive/best_model.h5')
|
|
|
|
|
|
|
8 |
tokenizer = source_tokenizer
|
9 |
|
10 |
# Function for transliteration
|
|
|
15 |
# Use the model for prediction
|
16 |
output_sequence = model.predict(input_sequence)
|
17 |
|
18 |
+
# Use argmax to get the most likely characters
|
19 |
+
predicted_text = "".join([tokenizer.index_word[idx] for idx in np.argmax(output_sequence, axis=-1)[0] if idx != 0])
|
20 |
|
21 |
return predicted_text
|
22 |
|