suriya7 commited on
Commit
29cef18
·
verified ·
1 Parent(s): 9a3828b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -1
app.py CHANGED
@@ -18,7 +18,22 @@ model = Xception()
18
  # Restructure model
19
  model = Model(inputs = model.inputs , outputs = model.layers[-2].output)
20
 
21
- caption_model = tf.keras.models.load_model('model.h5')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
  with open('captions.txt', 'r') as f:
24
  next(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:
39
  next(f)