Spaces:
Runtime error
Runtime error
Commit
·
e81ebd7
1
Parent(s):
44d1298
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import tensorflow as tf
|
| 3 |
+
import numpy as np
|
| 4 |
+
|
| 5 |
+
model = tf.keras.models.load_model("landColorGenV1.keras")
|
| 6 |
+
|
| 7 |
+
def generate_image(input_img):
|
| 8 |
+
input_img = tf.convert_to_tensor(input_img)
|
| 9 |
+
input_img = tf.cast(input_img,tf.float32)
|
| 10 |
+
init_shape = input_img.shape
|
| 11 |
+
input_img = tf.image.resize(input_img, [256, 256],
|
| 12 |
+
method=tf.image.ResizeMethod.NEAREST_NEIGHBOR)
|
| 13 |
+
input_img = (input_img / 127.5) -1
|
| 14 |
+
input_img = tf.reshape(input_img,(1,256,256,3))
|
| 15 |
+
output = model(input_img,training=True)
|
| 16 |
+
# out_img = output[0].numpy()* 0.5 + 0.5
|
| 17 |
+
out_img = tf.image.resize(output[0], [init_shape[0],init_shape[1]],
|
| 18 |
+
method=tf.image.ResizeMethod.NEAREST_NEIGHBOR)
|
| 19 |
+
out_img = out_img.numpy()*0.5 + 0.5
|
| 20 |
+
return out_img
|
| 21 |
+
app = gr.Interface(fn = generate_image, inputs="image", outputs="image")
|
| 22 |
+
app.launch(debug=False)
|