Spaces:
Runtime error
Runtime error
first commit
Browse files- app.py +43 -0
- imgs/content/content.jpg +0 -0
- imgs/style/style.jpg +0 -0
app.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from PIL import Image
|
| 3 |
+
import os
|
| 4 |
+
# import torch
|
| 5 |
+
|
| 6 |
+
style_dir = "imgs/style"
|
| 7 |
+
content_dir = "imgs/content"
|
| 8 |
+
results_dir = "imgs/results"
|
| 9 |
+
if not os.path.exists(style_dir):
|
| 10 |
+
os.mkdir(style_dir)
|
| 11 |
+
if not os.path.exists(content_dir):
|
| 12 |
+
os.mkdir(content_dir)
|
| 13 |
+
if not os.path.exists(results_dir):
|
| 14 |
+
os.mkdir(results_dir)
|
| 15 |
+
|
| 16 |
+
st.set_page_config(page_title="DiffStyle Demo", page_icon=":art:", layout="wide")
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
style_reference_image = None
|
| 20 |
+
content_reference_image = None
|
| 21 |
+
|
| 22 |
+
# Get style reference image
|
| 23 |
+
style_reference_image = st.sidebar.file_uploader("Upload style reference image", type=["jpg", "jpeg", "png"], key='style_reference')
|
| 24 |
+
if style_reference_image:
|
| 25 |
+
style_reference_image = Image.open(style_reference_image)
|
| 26 |
+
st.sidebar.image(style_reference_image, width=200)
|
| 27 |
+
|
| 28 |
+
# Get content reference image
|
| 29 |
+
content_reference_image = st.sidebar.file_uploader("Upload content reference image", type=["jpg", "jpeg", "png"], key='content_reference')
|
| 30 |
+
if content_reference_image:
|
| 31 |
+
content_reference_image = Image.open(content_reference_image)
|
| 32 |
+
st.sidebar.image(content_reference_image, width=200)
|
| 33 |
+
|
| 34 |
+
# Synthesize new image
|
| 35 |
+
# if style_reference_image and content_reference_image:
|
| 36 |
+
# # Call your AI algorithm here to synthesize a new image
|
| 37 |
+
# synthesized_image = None # placeholder for your synthesized image
|
| 38 |
+
|
| 39 |
+
# st.image(synthesized_image, caption="Synthesized image", use_column_width=True)
|
| 40 |
+
|
| 41 |
+
st.write("""
|
| 42 |
+
This is just a demo. Your AI algorithm code should be added to synthesize the new image.
|
| 43 |
+
""")
|
imgs/content/content.jpg
ADDED
|
imgs/style/style.jpg
ADDED
|