Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -102,32 +102,6 @@ image_height = 32
|
|
102 |
def distortion_free_resize(image, img_size):
|
103 |
w, h = img_size
|
104 |
image = tf.image.resize(image, size=(h, w), preserve_aspect_ratio=True)
|
105 |
-
|
106 |
-
# Check tha amount of padding needed to be done.
|
107 |
-
pad_height = h - tf.shape(image)[0]
|
108 |
-
pad_width = w - tf.shape(image)[1]
|
109 |
-
|
110 |
-
# only necessary if you want to do same amount of padding on both sides.
|
111 |
-
if pad_height % 2 != 0:
|
112 |
-
height = pad_height // 2
|
113 |
-
pad_height_top = height +1
|
114 |
-
pad_height_bottom = height
|
115 |
-
else:
|
116 |
-
pad_height_top = pad_height_bottom = pad_height // 2
|
117 |
-
|
118 |
-
if pad_width % 2 != 0:
|
119 |
-
width = pad_width // 2
|
120 |
-
pad_width_left = width + 1
|
121 |
-
pad_width_right = width
|
122 |
-
else:
|
123 |
-
pad_width_left = pad_width_right = pad_width // 2
|
124 |
-
|
125 |
-
image = tf.pad(
|
126 |
-
image, paddings=[
|
127 |
-
[pad_height_top, pad_height_bottom],
|
128 |
-
[pad_width_left, pad_width_right],
|
129 |
-
[0, 0],
|
130 |
-
],)
|
131 |
image = tf.transpose(image, perm=[1,0,2])
|
132 |
image = tf.image.flip_left_right(image)
|
133 |
return image
|
|
|
102 |
def distortion_free_resize(image, img_size):
|
103 |
w, h = img_size
|
104 |
image = tf.image.resize(image, size=(h, w), preserve_aspect_ratio=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
image = tf.transpose(image, perm=[1,0,2])
|
106 |
image = tf.image.flip_left_right(image)
|
107 |
return image
|