Spaces:
Runtime error
Runtime error
Tanishq commited on
Commit ·
21bc8bb
1
Parent(s): bf7eb8d
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import os
|
| 3 |
+
from PIL import Image
|
| 4 |
+
from train import main
|
| 5 |
+
|
| 6 |
+
st.title("ComicInator")
|
| 7 |
+
st.write("Welcome to the ComicInator! Choose an image and see it displayed below.")
|
| 8 |
+
|
| 9 |
+
os.makedirs("input", exist_ok=True)
|
| 10 |
+
os.makedirs("evaluation", exist_ok=True)
|
| 11 |
+
|
| 12 |
+
st.sidebar.title("Choose an image")
|
| 13 |
+
uploaded_file = st.sidebar.file_uploader("Upload an image", type=["jpg", "jpeg", "png"])
|
| 14 |
+
|
| 15 |
+
if uploaded_file is not None:
|
| 16 |
+
for filename in os.listdir("input/face"):
|
| 17 |
+
file_path = os.path.join("input/face", filename)
|
| 18 |
+
os.remove(file_path)
|
| 19 |
+
with open(os.path.join("input/face", uploaded_file.name), "wb") as f:
|
| 20 |
+
f.write(uploaded_file.getvalue())
|
| 21 |
+
st.sidebar.success("Image successfully uploaded!")
|
| 22 |
+
main()
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
col1, col2 = st.columns(2)
|
| 26 |
+
|
| 27 |
+
if uploaded_file is not None:
|
| 28 |
+
col1.image(Image.open(os.path.join("evaluation", "input_0.png")), caption="Uploaded Image", use_column_width=True)
|
| 29 |
+
col2.image(Image.open(os.path.join("evaluation", "y_gen_0.png")), caption="Colorized Image", use_column_width=True)
|