Manikandan-Alagu commited on
Commit
1025657
1 Parent(s): 954a023

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -0
app.py CHANGED
@@ -272,11 +272,13 @@ class ImageCaptioningModel(tf.keras.Model):
272
  def load_image_from_path(img_path):
273
  img = tf.io.read_file(img_path)
274
  img = tf.io.decode_jpeg(img, channels=3)
 
275
  img = tf.keras.layers.Resizing(299, 299)(img)
276
  img = tf.keras.applications.inception_v3.preprocess_input(img)
277
  return img
278
 
279
 
 
280
  def generate_caption(img, caption_model, add_noise=False):
281
  if isinstance(img, str):
282
  img = load_image_from_path(img)
 
272
  def load_image_from_path(img_path):
273
  img = tf.io.read_file(img_path)
274
  img = tf.io.decode_jpeg(img, channels=3)
275
+ img = tf.cast(img, tf.float32) # Convert to float32
276
  img = tf.keras.layers.Resizing(299, 299)(img)
277
  img = tf.keras.applications.inception_v3.preprocess_input(img)
278
  return img
279
 
280
 
281
+
282
  def generate_caption(img, caption_model, add_noise=False):
283
  if isinstance(img, str):
284
  img = load_image_from_path(img)