vishalkryadav
commited on
Commit
•
86018aa
1
Parent(s):
b2bcf83
Update app.py
Browse files
app.py
CHANGED
@@ -118,8 +118,13 @@ def prediction(df):
|
|
118 |
#x_model = tf.keras.models.load_model('my_model.h5')
|
119 |
try:
|
120 |
x_model = tf.keras.models.load_model('my_model.h5')
|
121 |
-
except:
|
122 |
-
|
|
|
|
|
|
|
|
|
|
|
123 |
y_pred = x_model.predict(X_test_df)
|
124 |
#predicition = []
|
125 |
#for i in list(y_pred):
|
|
|
118 |
#x_model = tf.keras.models.load_model('my_model.h5')
|
119 |
try:
|
120 |
x_model = tf.keras.models.load_model('my_model.h5')
|
121 |
+
except (OSError, ValueError):
|
122 |
+
# Load the model as a TFSMLayer if .h5 loading fails
|
123 |
+
tfs_layer = tf.keras.layers.TFSMLayer('my_model', call_endpoint='serving_default')
|
124 |
+
# Create a new model using the TFSMLayer
|
125 |
+
inputs = tf.keras.Input(shape=(X_test_df.shape[1],))
|
126 |
+
outputs = tfs_layer(inputs)
|
127 |
+
x_model = tf.keras.Model(inputs=inputs, outputs=outputs)
|
128 |
y_pred = x_model.predict(X_test_df)
|
129 |
#predicition = []
|
130 |
#for i in list(y_pred):
|