markchiang commited on
Commit
d0ab3c7
·
1 Parent(s): af7f383

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -5,8 +5,15 @@ import tensorflow as tf
5
  from tensorflow.keras import layers, models, optimizers
6
  import gradio as gr
7
 
8
- # Load pre-trained model
9
- model = tf.keras.models.load_model('facial_condition_model.h5')
 
 
 
 
 
 
 
10
 
11
  # Function to preprocess image for model input
12
  def preprocess_image(image):
 
5
  from tensorflow.keras import layers, models, optimizers
6
  import gradio as gr
7
 
8
+ # Define custom optimizer for loading saved model
9
+ class CustomAdam(optimizers.Adam):
10
+ def get_config(self):
11
+ config = super().get_config()
12
+ config['name'] = 'CustomAdam'
13
+ return config
14
+
15
+ # Load pre-trained model with custom optimizer
16
+ model = tf.keras.models.load_model('facial_condition_model.h5', custom_objects={'CustomAdam': CustomAdam})
17
 
18
  # Function to preprocess image for model input
19
  def preprocess_image(image):