photo2monet / main.py
ayaderaghul's picture
Upload 3 files
0363e6d
raw
history blame
No virus
769 Bytes
import streamlit as st
from tensorflow.keras.models import load_model
import numpy as np
import matplitlib.pyplot as plt
st.header("Photo to Monet")
st.caption('Upload an image 256x256')
model = load_model('g_model_AtoB_002160.h5')
@st.cache
def load_image(image_file):
img=plt.imread(image_file)
return img
imgpath = st.file_uploader("Choose a file", type =['png', 'jpeg', 'jpg'])
if imgpath is not None:
img = load_image(imgpath )
st.image(img, width=250)
def convert(image):
img=load_image(img,target_size=(256,256))
img_array = np.reshape(img, (1, 256, 256, 3))
result=model.predict(img_array)
result=np.squeeze(img,axis=0)
return result
if st.button('Convert'):
result=convert(imagepath)
st.image(result)