Commit
·
0363e6d
1
Parent(s):
9a2aba1
Upload 3 files
Browse files- README.md +1 -0
- g_model_AtoB_002160.h5 +3 -0
- main.py +39 -0
README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
# keras-streamlit
|
g_model_AtoB_002160.h5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:af168a96d6f548ae084a9608211822e7da935f9ace3192d25a9eb77372acd1e8
|
| 3 |
+
size 141314344
|
main.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import streamlit as st
|
| 3 |
+
|
| 4 |
+
from tensorflow.keras.models import load_model
|
| 5 |
+
|
| 6 |
+
import numpy as np
|
| 7 |
+
|
| 8 |
+
import matplitlib.pyplot as plt
|
| 9 |
+
|
| 10 |
+
st.header("Photo to Monet")
|
| 11 |
+
|
| 12 |
+
st.caption('Upload an image 256x256')
|
| 13 |
+
|
| 14 |
+
model = load_model('g_model_AtoB_002160.h5')
|
| 15 |
+
|
| 16 |
+
@st.cache
|
| 17 |
+
def load_image(image_file):
|
| 18 |
+
img=plt.imread(image_file)
|
| 19 |
+
return img
|
| 20 |
+
|
| 21 |
+
imgpath = st.file_uploader("Choose a file", type =['png', 'jpeg', 'jpg'])
|
| 22 |
+
|
| 23 |
+
if imgpath is not None:
|
| 24 |
+
|
| 25 |
+
img = load_image(imgpath )
|
| 26 |
+
|
| 27 |
+
st.image(img, width=250)
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
def convert(image):
|
| 31 |
+
img=load_image(img,target_size=(256,256))
|
| 32 |
+
img_array = np.reshape(img, (1, 256, 256, 3))
|
| 33 |
+
result=model.predict(img_array)
|
| 34 |
+
result=np.squeeze(img,axis=0)
|
| 35 |
+
return result
|
| 36 |
+
|
| 37 |
+
if st.button('Convert'):
|
| 38 |
+
result=convert(imagepath)
|
| 39 |
+
st.image(result)
|