Spaces:
Runtime error
Runtime error
dariush-bahrami
commited on
Commit
·
ac463e3
1
Parent(s):
57e3eaa
Update app
Browse files
app.py
CHANGED
@@ -1,15 +1,32 @@
|
|
1 |
import streamlit as st
|
2 |
import numpy as np
|
|
|
|
|
|
|
3 |
|
4 |
with st.container():
|
5 |
col1, col2 = st.columns(2)
|
6 |
|
7 |
with col1:
|
8 |
-
|
9 |
-
if
|
10 |
-
st.image(
|
11 |
|
12 |
with col2:
|
13 |
-
|
14 |
-
if
|
15 |
-
st.image(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
import numpy as np
|
3 |
+
from colortransfer import transfer_color, convert_bytes_to_pil
|
4 |
+
import io
|
5 |
+
from PIL import Image
|
6 |
|
7 |
with st.container():
|
8 |
col1, col2 = st.columns(2)
|
9 |
|
10 |
with col1:
|
11 |
+
target_img = st.file_uploader("Choose Target Image", type=["png", "jpg"])
|
12 |
+
if target_img is not None:
|
13 |
+
st.image(target_img, width=256)
|
14 |
|
15 |
with col2:
|
16 |
+
style_img = st.file_uploader("Choose Style Image", type=["png", "jpg"])
|
17 |
+
if style_img is not None:
|
18 |
+
st.image(style_img, width=256)
|
19 |
+
|
20 |
+
|
21 |
+
with st.container():
|
22 |
+
if st.button("Transfer!"):
|
23 |
+
if target_img is not None and style_img is not None:
|
24 |
+
result = transfer_color(
|
25 |
+
np.asarray(convert_bytes_to_pil(style_img.read())),
|
26 |
+
np.asarray(convert_bytes_to_pil(target_img.read())),
|
27 |
+
)
|
28 |
+
st.image(result, width=700)
|
29 |
+
else:
|
30 |
+
st.error("You need to specify the target and style images first")
|
31 |
+
else:
|
32 |
+
st.write("Upload images and press Transfer button")
|