File size: 1,025 Bytes
b060e0a
 
 
 
 
85d3ae6
b060e0a
a810cc1
b060e0a
 
c693d16
b060e0a
5894220
b060e0a
 
 
 
1adaec6
b060e0a
390aa75
b060e0a
 
0de02d5
b060e0a
 
 
85d3ae6
b060e0a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import gradio as gr
import numpy as np
from tensorflow.keras.preprocessing.image import load_img, img_to_array
from tensorflow.keras.models import load_model
from PIL import Image
import matplotlib.pyplot as plt

inputs = gr.inputs.Image(shape=(256, 256))
o1 = gr.outputs.Image()
o2 = gr.outputs.Image()
gen_model = load_model('256_model_250ep.h5')

def colorify(pixels):
  
  pixels = (pixels - 127.5) / 127.5
  pixels = np.expand_dims(pixels, 0)
  gen_image = gen_model.predict(pixels)
  gen_image = (gen_image + 1) / 2
  
  return Image.fromarray((gen_image[0] * 255.0).astype(np.uint8))
  
title = "Colorify"
description = "Recolor your images using this lite version of PIX2PIX GAN , model is trained on 700 randomly collected images from the internet with 256*256 pixels" 
examples=[['example1.png'],['example2.jpg']]
article = "<p style='text-align: center'>"

gr.Interface(fn=colorify, inputs=inputs, outputs=o1, title=title, description=description, article=article, examples=examples, enable_queue=True).launch()