Spaces:
Sleeping
Sleeping
Commit
·
f2f2c77
1
Parent(s):
b338992
Update app.py
Browse files
app.py
CHANGED
|
@@ -167,7 +167,7 @@ checkpoint.restore(tf.train.latest_checkpoint(checkpoint_dir))
|
|
| 167 |
|
| 168 |
def animize(img):
|
| 169 |
img = np.array(img)
|
| 170 |
-
|
| 171 |
img = preprocess_image_test(np.reshape(img,(1,img.shape[0],img.shape[1],img.shape[2])))
|
| 172 |
img = tf.expand_dims(img,0)
|
| 173 |
prediction = generator_f2m(img)
|
|
@@ -176,9 +176,9 @@ def animize(img):
|
|
| 176 |
prediction = (prediction - np.min(prediction)) / (np.max(prediction) - np.min(prediction))
|
| 177 |
prediction = prediction * 2 - 1
|
| 178 |
prediction = (prediction[0]*0.5+0.5).numpy()
|
| 179 |
-
|
| 180 |
|
| 181 |
-
return
|
| 182 |
|
| 183 |
interface = gr.Interface(fn=animize, inputs="image", outputs="image")
|
| 184 |
interface.launch(share=True)
|
|
|
|
| 167 |
|
| 168 |
def animize(img):
|
| 169 |
img = np.array(img)
|
| 170 |
+
init_shape = img.shape
|
| 171 |
img = preprocess_image_test(np.reshape(img,(1,img.shape[0],img.shape[1],img.shape[2])))
|
| 172 |
img = tf.expand_dims(img,0)
|
| 173 |
prediction = generator_f2m(img)
|
|
|
|
| 176 |
prediction = (prediction - np.min(prediction)) / (np.max(prediction) - np.min(prediction))
|
| 177 |
prediction = prediction * 2 - 1
|
| 178 |
prediction = (prediction[0]*0.5+0.5).numpy()
|
| 179 |
+
out = tf.image.resize(prediction, [init_shape[0], init_shape[1]],method=tf.image.ResizeMethod.NEAREST_NEIGHBOR)
|
| 180 |
|
| 181 |
+
return out
|
| 182 |
|
| 183 |
interface = gr.Interface(fn=animize, inputs="image", outputs="image")
|
| 184 |
interface.launch(share=True)
|