Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -18,21 +18,21 @@ model = Xception()
|
|
| 18 |
# Restructure model
|
| 19 |
model = Model(inputs = model.inputs , outputs = model.layers[-2].output)
|
| 20 |
|
| 21 |
-
import tensorflow as tf
|
| 22 |
|
| 23 |
-
class MyEmbedding(tf.keras.layers.Embedding):
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
|
| 34 |
-
# Load the model with custom objects
|
| 35 |
-
caption_model = tf.keras.models.load_model('model.h5', custom_objects={'MyEmbedding': MyEmbedding})
|
| 36 |
|
| 37 |
|
| 38 |
with open('captions.txt', 'r') as f:
|
|
|
|
| 18 |
# Restructure model
|
| 19 |
model = Model(inputs = model.inputs , outputs = model.layers[-2].output)
|
| 20 |
|
| 21 |
+
# import tensorflow as tf
|
| 22 |
|
| 23 |
+
# class MyEmbedding(tf.keras.layers.Embedding):
|
| 24 |
+
# def __init__(self, *args, input_length=None, **kwargs):
|
| 25 |
+
# super().__init__(*args, **kwargs)
|
| 26 |
+
# self.input_length = input_length
|
| 27 |
|
| 28 |
+
# def from_config(cls, config):
|
| 29 |
+
# input_length = config.pop('input_length', None)
|
| 30 |
+
# instance = cls(**config)
|
| 31 |
+
# instance.input_length = input_length
|
| 32 |
+
# return instance
|
| 33 |
|
| 34 |
+
# # Load the model with custom objects
|
| 35 |
+
# caption_model = tf.keras.models.load_model('model.h5', custom_objects={'MyEmbedding': MyEmbedding})
|
| 36 |
|
| 37 |
|
| 38 |
with open('captions.txt', 'r') as f:
|