Spaces:
Build error
Build error
Commit
·
8cbae1c
1
Parent(s):
d0ab3c7
Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,8 @@ import urllib
|
|
4 |
import tensorflow as tf
|
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):
|
@@ -11,6 +13,8 @@ class CustomAdam(optimizers.Adam):
|
|
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})
|
|
|
4 |
import tensorflow as tf
|
5 |
from tensorflow.keras import layers, models, optimizers
|
6 |
import gradio as gr
|
7 |
+
from tensorflow.keras.utils import get_custom_objects
|
8 |
+
from app import CustomAdam
|
9 |
|
10 |
# Define custom optimizer for loading saved model
|
11 |
class CustomAdam(optimizers.Adam):
|
|
|
13 |
config = super().get_config()
|
14 |
config['name'] = 'CustomAdam'
|
15 |
return config
|
16 |
+
|
17 |
+
get_custom_objects().update({'CustomAdam': CustomAdam})
|
18 |
|
19 |
# Load pre-trained model with custom optimizer
|
20 |
model = tf.keras.models.load_model('facial_condition_model.h5', custom_objects={'CustomAdam': CustomAdam})
|