RobotJelly commited on
Commit
3a9fef7
·
1 Parent(s): 7f4a53c
Files changed (1) hide show
  1. app.py +12 -15
app.py CHANGED
@@ -11,20 +11,15 @@ from huggingface_hub import from_pretrained_keras
11
 
12
  model = from_pretrained_keras("RobotJelly/GauGAN-Image-generation")
13
 
14
- def predict(image_file):
15
- # print(image_file)
16
- # img = Image.open(image_file)
17
- # image_file = str(img)
18
- print("image_file-->", tf.io.read_file(image_file))
19
-
20
- image_list = []
21
-
22
- segmentation_map = image_file.replace("images", "segmentation_map").replace("jpg", "png")
23
 
24
- labels = image_file.replace("images", "segmentation_labels").replace("jpg", "bmp")
25
- print("labels", labels)
26
 
27
- image_list = [segmentation_map, image_file, labels]
28
 
29
  image = tf.image.decode_png(tf.io.read_file(image_list[1]), channels=3)
30
  image = tf.cast(image, tf.float32) / 127.5 - 1
@@ -67,10 +62,12 @@ def predict(image_file):
67
  real_images = final_img_list
68
 
69
  # return tf.squeeze(real_images[1], axis=0), fake_image
70
- return [(real_images[0][0]+1)/2, (fake_image[0]+1)/2]
71
 
72
  # input
73
- input = [gr.inputs.Image(type="filepath", label="Ground Truth - Real Image")]
 
 
74
 
75
  facades_data = []
76
  data_dir = 'examples/'
@@ -80,7 +77,7 @@ for idx, images in enumerate(os.listdir(data_dir)):
80
  facades_data.append(image)
81
 
82
  # output
83
- output = [gr.outputs.Image(type="numpy", label="Mask/Segmentation used"), gr.outputs.Image(type="numpy", label="Generated - Conditioned Images")]
84
 
85
  title = "GauGAN For Conditional Image Generation"
86
  description = "Upload an Image or take one from examples to generate realistic images that are conditioned on cue images and segmentation maps"
 
11
 
12
  model = from_pretrained_keras("RobotJelly/GauGAN-Image-generation")
13
 
14
+ def predict(image_file, segmentation_png, bitmap_img):
15
+ image_list = [segmentation_png, image_file, bitmap_img]
16
+
17
+ #segmentation_map = image_file.replace("images", "segmentation_map").replace("jpg", "png")
 
 
 
 
 
18
 
19
+ #labels = image_file.replace("images", "segmentation_labels").replace("jpg", "bmp")
20
+ #print("labels", labels)
21
 
22
+ #image_list = [segmentation_map, image_file, labels]
23
 
24
  image = tf.image.decode_png(tf.io.read_file(image_list[1]), channels=3)
25
  image = tf.cast(image, tf.float32) / 127.5 - 1
 
62
  real_images = final_img_list
63
 
64
  # return tf.squeeze(real_images[1], axis=0), fake_image
65
+ return (fake_image[0]+1)/2
66
 
67
  # input
68
+ input = [gr.inputs.Image(type="filepath", label="Ground Truth - Real Image (jpg)"),
69
+ gr.inputs.Image(type="filepath", label="Segementated image (png)"),
70
+ gr.inputs.Image(type="filepath", label="corresponding bitmap image (bmp)")]
71
 
72
  facades_data = []
73
  data_dir = 'examples/'
 
77
  facades_data.append(image)
78
 
79
  # output
80
+ output = [gr.outputs.Image(type="numpy", label="Generated - Conditioned Images")]
81
 
82
  title = "GauGAN For Conditional Image Generation"
83
  description = "Upload an Image or take one from examples to generate realistic images that are conditioned on cue images and segmentation maps"