-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain2.py
More file actions
50 lines (29 loc) · 996 Bytes
/
main2.py
File metadata and controls
50 lines (29 loc) · 996 Bytes
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# python3 -m venv venv
# . venv/bin/activate
# pip install streamlit
# pip install torch torchvision
# streamlit run main.py
import streamlit as st
from PIL import Image
import style
st.title('Dl ops project neural style transfer')
style_name = st.sidebar.selectbox(
'Select Style',
('candy', 'mosaic', 'rain_princess', 'udnie')
)
image = "images/content-images/" + 'amber.jpg'
model= "saved_models/" + style_name + ".pth"
# input_image = st.file_uploader("Choose a file")
output_image = "images/output-images/" + style_name + "jpg"
image = st.file_uploader("Upload your file here...", type=['png', 'jpeg', 'jpg'])
# if image is not None:
# st.image(image)
st.write('### Source image:')
st.image(image, width=400) # image: numpy array
clicked = st.button('Stylize')
if clicked:
model = style.load_model(model)
style.stylize(model, image, output_image)
st.write('### Output image:')
image = Image.open(output_image)
st.image(image, width=400)