Spaces:
Runtime error
Runtime error
updated web app
Browse files- .gitattributes +1 -0
- app.py +36 -6
.gitattributes
CHANGED
@@ -28,3 +28,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
28 |
models/Hayao/* filter=lfs diff=lfs merge=lfs -text
|
29 |
models/Paprika/* filter=lfs diff=lfs merge=lfs -text
|
30 |
models/Shinkai/* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
28 |
models/Hayao/* filter=lfs diff=lfs merge=lfs -text
|
29 |
models/Paprika/* filter=lfs diff=lfs merge=lfs -text
|
30 |
models/Shinkai/* filter=lfs diff=lfs merge=lfs -text
|
31 |
+
images/* filter=lfs diff=lfs merge=lfs -text
|
app.py
CHANGED
@@ -8,6 +8,9 @@ import threading
|
|
8 |
# style.py
|
9 |
import style
|
10 |
|
|
|
|
|
|
|
11 |
st.set_page_config(page_title="Animefy", page_icon="images/animefy_logo.png")
|
12 |
|
13 |
model_lock = threading.Lock()
|
@@ -29,13 +32,24 @@ hide_streamlit = """
|
|
29 |
"""
|
30 |
st.markdown(hide_streamlit, unsafe_allow_html=True)
|
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
# randomizer. a workaround for clearing the contents of the file_uploader
|
33 |
if 'uploader_key' not in st.session_state:
|
34 |
st.session_state['uploader_key'] = str(randint(1000, 100000000))
|
35 |
|
36 |
# home page title and caption
|
37 |
st.markdown("""
|
38 |
-
#
|
39 |
|
40 |
Convert your photos into **anime** with _ease_ using **AnimeGAN**.
|
41 |
""")
|
@@ -58,8 +72,7 @@ with home_page.expander("📣 Here are some things to take note of...", expanded
|
|
58 |
st.write("""
|
59 |
* Do note that AnimeGAN works best with images containing **sceneries without people**.
|
60 |
* For best results, use images that **do not** contain human subjects.
|
61 |
-
*
|
62 |
-
* Fore more information on AnimeGAN, click [here](https://github.com/TonyLianLong/AnimeGAN.js).
|
63 |
""")
|
64 |
|
65 |
# upload image functionality
|
@@ -67,8 +80,19 @@ uploaded_image = home_page.file_uploader(
|
|
67 |
"If you're ready, you can now upload your image here:", type=['png','jpg','jpeg'], key=st.session_state['uploader_key']
|
68 |
)
|
69 |
|
70 |
-
#
|
|
|
71 |
if uploaded_image is not None:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
# just a preview of the uploaded image
|
73 |
home_page.markdown("""
|
74 |
#### Uploaded Image
|
@@ -92,12 +116,18 @@ if uploaded_image is not None:
|
|
92 |
|
93 |
# just some more notes for the user
|
94 |
with home_page.expander("🤔 What are these animation styles?", expanded=False):
|
95 |
-
st.
|
96 |
These styles were derived from the works of various directors! Some of these might be familiar to you:
|
97 |
* Satoshi Kon: **Paprika**
|
98 |
* Makoto **Shinkai**: Your Name, 5 Centimeters per Second, Weathering with You
|
99 |
* **Hayao** Miyazaki: Spirited Away, My Neighbor Totoro, Princess Mononoke
|
100 |
""")
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
|
102 |
home_page.write("---")
|
103 |
|
@@ -167,4 +197,4 @@ if uploaded_image is not None:
|
|
167 |
st.write("---")
|
168 |
|
169 |
# randomizer. just another workaround.
|
170 |
-
st.session_state['uploader_key'] = str(randint(1000, 100000000))
|
|
|
8 |
# style.py
|
9 |
import style
|
10 |
|
11 |
+
# utils.py
|
12 |
+
from utils import *
|
13 |
+
|
14 |
st.set_page_config(page_title="Animefy", page_icon="images/animefy_logo.png")
|
15 |
|
16 |
model_lock = threading.Lock()
|
|
|
32 |
"""
|
33 |
st.markdown(hide_streamlit, unsafe_allow_html=True)
|
34 |
|
35 |
+
def imageResCheck (image):
|
36 |
+
# load and preprocess input image as a NumPy array
|
37 |
+
image = np.asarray(load_input_image(image))
|
38 |
+
|
39 |
+
image_height, image_width = image.shape[:2]
|
40 |
+
|
41 |
+
if (image_height <= 2160 and image_width <= 2160):
|
42 |
+
return True
|
43 |
+
else:
|
44 |
+
return False
|
45 |
+
|
46 |
# randomizer. a workaround for clearing the contents of the file_uploader
|
47 |
if 'uploader_key' not in st.session_state:
|
48 |
st.session_state['uploader_key'] = str(randint(1000, 100000000))
|
49 |
|
50 |
# home page title and caption
|
51 |
st.markdown("""
|
52 |
+
# ✨ Animefy ✨
|
53 |
|
54 |
Convert your photos into **anime** with _ease_ using **AnimeGAN**.
|
55 |
""")
|
|
|
72 |
st.write("""
|
73 |
* Do note that AnimeGAN works best with images containing **sceneries without people**.
|
74 |
* For best results, use images that **do not** contain human subjects.
|
75 |
+
* Fore more information on AnimeGAN, click [here](https://github.com/TachibanaYoshino/AnimeGAN).
|
|
|
76 |
""")
|
77 |
|
78 |
# upload image functionality
|
|
|
80 |
"If you're ready, you can now upload your image here:", type=['png','jpg','jpeg'], key=st.session_state['uploader_key']
|
81 |
)
|
82 |
|
83 |
+
# some checking if the image resolution is valid
|
84 |
+
# being done only for performance purposes.
|
85 |
if uploaded_image is not None:
|
86 |
+
isValidImage = imageResCheck(uploaded_image)
|
87 |
+
else:
|
88 |
+
isValidImage = False
|
89 |
+
|
90 |
+
# warning
|
91 |
+
if uploaded_image is not None and not isValidImage:
|
92 |
+
st.caption("**Warning:** For better performance, please upload an image that will not exceed a resolution of **2160x2160**.")
|
93 |
+
|
94 |
+
# if there is an uploaded image, show next steps
|
95 |
+
if isValidImage:
|
96 |
# just a preview of the uploaded image
|
97 |
home_page.markdown("""
|
98 |
#### Uploaded Image
|
|
|
116 |
|
117 |
# just some more notes for the user
|
118 |
with home_page.expander("🤔 What are these animation styles?", expanded=False):
|
119 |
+
st.markdown("""
|
120 |
These styles were derived from the works of various directors! Some of these might be familiar to you:
|
121 |
* Satoshi Kon: **Paprika**
|
122 |
* Makoto **Shinkai**: Your Name, 5 Centimeters per Second, Weathering with You
|
123 |
* **Hayao** Miyazaki: Spirited Away, My Neighbor Totoro, Princess Mononoke
|
124 |
""")
|
125 |
+
st.write("---")
|
126 |
+
st.markdown("""
|
127 |
+
🔍 Here are some sample images for you:
|
128 |
+
""")
|
129 |
+
|
130 |
+
st.image(Image.open('images/sample.png'), caption="Image from https://github.com/TachibanaYoshino/AnimeGAN")
|
131 |
|
132 |
home_page.write("---")
|
133 |
|
|
|
197 |
st.write("---")
|
198 |
|
199 |
# randomizer. just another workaround.
|
200 |
+
st.session_state['uploader_key'] = str(randint(1000, 100000000))
|