Anithprakash's picture
Update app.py
0dfe8f7 verified
raw
history blame contribute delete
956 Bytes
import gradio as gr
import tensorflow as tf
import keras
import os
import numpy as np
import matplotlib.pyplot as plt
#loading model
cycleGen=tf.keras.models.load_model('cycle-gen-models/model')
cycleGen.load_weights('cycle-gen-models/weights')
def imageProcessing(img):
#img=tf.io.read_file(img_path)
img=tf.image.decode_jpeg(img,channels=3)
img=tf.image.resize(img,[256,256])
img=(img/127.5)-1
img=tf.expand_dims(img,axis=0)
return img
def image_change(inputs):
img=imageProcessing(inputs)
fake_monet,_,_,_=cycleGen((img,img),training=False)
#prediction=(prediction * 127.5 + 127.5).astype(np.uint8)
prediction=(fake_monet[0] * 127.5 + 127.5).numpy().astype(np.uint8)
return prediction
Title="Monet Mimic image πŸ–ŒοΈπŸŽ¨"
demo=gr.Interface(
fn=image_change,
inputs=gr.Image(type="filepath"),
img=image_change(input),
title=Title,
outputs=gr.Image(img)
)
demo.launch()