Reaumur commited on
Commit
4fde83e
·
verified ·
1 Parent(s): 56d363b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -3,14 +3,19 @@ from PIL import Image
3
  import tensorflow as tf
4
  import numpy as np
5
  import os
 
 
 
 
 
 
 
6
 
7
  # Caching the model loading function to optimize performance
8
  @st.cache_resource
9
  def load_captcha_model():
10
  model_path = "captcha_ocr_model.h5" # Update with the actual CAPTCHA model path
11
-
12
- # Load the model without custom objects
13
- return tf.keras.models.load_model(model_path)
14
 
15
  # Load the model
16
  model = load_captcha_model()
 
3
  import tensorflow as tf
4
  import numpy as np
5
  import os
6
+ from tensorflow.keras.layers import LSTM
7
+ from keras.saving import register_keras_serializable
8
+
9
+ # Kelas LSTM Kustom
10
+ @register_keras_serializable()
11
+ class CustomLSTM(LSTM):
12
+ pass
13
 
14
  # Caching the model loading function to optimize performance
15
  @st.cache_resource
16
  def load_captcha_model():
17
  model_path = "captcha_ocr_model.h5" # Update with the actual CAPTCHA model path
18
+ return tf.keras.models.load_model(model_path, custom_objects={'CustomLSTM': CustomLSTM})
 
 
19
 
20
  # Load the model
21
  model = load_captcha_model()