Spaces:
Runtime error
Runtime error
Commit ·
3a9fef7
1
Parent(s): 7f4a53c
app.py
Browse files10 unmodified lines111213141516171819202122232425262728293036 unmodified lines676869707172737475763 unmodified lines8081828384858610 unmodified linesmodel = from_pretrained_keras("RobotJelly/GauGAN-Image-generation")def predict(image_file):# print(image_file)# img = Image.open(image_file)# image_file = str(img)print("image_file-->", tf.io.read_file(image_file))image_list = []segmentation_map = image_file.replace("images", "segmentation_map").replace("jpg", "png")labels = image_file.replace("images", "segmentation_labels").replace("jpg", "bmp")print("labels", labels)image_list = [segmentation_map, image_file, labels]image = tf.image.decode_png(tf.io.read_file(image_list[1]), channels=3)image = tf.cast(image, tf.float32) / 127.5 - 136 unmodified linesreal_images = final_img_list# return tf.squeeze(real_images[1], axis=0), fake_imagereturn [(real_images[0][0]+1)/2, (fake_image[0]+1)/2]# inputinput = [gr.inputs.Image(type="filepath", label="Ground Truth - Real Image")]facades_data = []data_dir = 'examples/'3 unmodified linesfacades_data.append(image)# outputoutput = [gr.outputs.Image(type="numpy", label="Mask/Segmentation used"), gr.outputs.Image(type="numpy", label="Generated - Conditioned Images")]title = "GauGAN For Conditional Image Generation"description = "Upload an Image or take one from examples to generate realistic images that are conditioned on cue images and segmentation maps"10 unmodified lines11121314151617181920212223242536 unmodified lines6263646566676869707172733 unmodified lines7778798081828310 unmodified linesmodel = from_pretrained_keras("RobotJelly/GauGAN-Image-generation")def predict(image_file, segmentation_png, bitmap_img):image_list = [segmentation_png, image_file, bitmap_img]#segmentation_map = image_file.replace("images", "segmentation_map").replace("jpg", "png")#labels = image_file.replace("images", "segmentation_labels").replace("jpg", "bmp")#print("labels", labels)#image_list = [segmentation_map, image_file, labels]image = tf.image.decode_png(tf.io.read_file(image_list[1]), channels=3)image = tf.cast(image, tf.float32) / 127.5 - 136 unmodified linesreal_images = final_img_list# return tf.squeeze(real_images[1], axis=0), fake_imagereturn (fake_image[0]+1)/2# inputinput = [gr.inputs.Image(type="filepath", label="Ground Truth - Real Image (jpg)"),gr.inputs.Image(type="filepath", label="Segementated image (png)"),gr.inputs.Image(type="filepath", label="corresponding bitmap image (bmp)")]facades_data = []data_dir = 'examples/'3 unmodified linesfacades_data.append(image)# outputoutput = [gr.outputs.Image(type="numpy", label="Generated - Conditioned Images")]title = "GauGAN For Conditional Image Generation"description = "Upload an Image or take one from examples to generate realistic images that are conditioned on cue images and segmentation maps"
app.py+12-15