Puyush commited on
Commit
5d1bdf8
·
verified ·
1 Parent(s): 461cbdc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -130,11 +130,15 @@ def distortion_free_resize(image, img_size):
130
  image = tf.image.flip_left_right(image)
131
  return image
132
 
133
- def decode_batch_predictions(img_path):
134
-
135
- img_size=(128, 32)
136
- input_image = tf.io.read_file(img_path)
137
- input_image = tf.io.decode_png(input_image, channels=1)
 
 
 
 
138
  input_image = distortion_free_resize(input_image, img_size)
139
  input_image = tf.image.convert_image_dtype(input_image, tf.float32)/255.0
140
 
 
130
  image = tf.image.flip_left_right(image)
131
  return image
132
 
133
+ def download_and_read_image(url):
134
+ img_path = tf.keras.utils.get_file(os.path.basename(url), origin=url)
135
+ img = tf.io.read_file(img_path)
136
+ return img, img_path
137
+
138
+ def decode_batch_predictions(img_url):
139
+ img, img_path = download_and_read_image(img_url)
140
+ img_size=(128, 32
141
+ input_image = tf.io.decode_png(img, channels=1)
142
  input_image = distortion_free_resize(input_image, img_size)
143
  input_image = tf.image.convert_image_dtype(input_image, tf.float32)/255.0
144