Spaces:
Runtime error
Runtime error
updated app.py
Browse files- app.py +27 -19
- requirements.txt +1 -1
app.py
CHANGED
@@ -128,35 +128,43 @@ if uploaded_image is not None:
|
|
128 |
st.markdown("""
|
129 |
Here's a before and after!
|
130 |
""")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
before_col, after_col = st.columns(2)
|
132 |
with before_col:
|
133 |
# clamp and channels are used since OpenCV was used in processing the image
|
134 |
st.image(uploaded_image, clamp=True, channels='RGB')
|
|
|
135 |
with after_col:
|
136 |
# clamp and channels are used since OpenCV was used in processing the image
|
137 |
st.image(output_image, clamp=True, channels='RGB')
|
138 |
|
139 |
-
st.
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
|
151 |
st.write("---")
|
152 |
-
|
153 |
-
# retry message
|
154 |
-
st.markdown('Not satisfied? Click this to retry!')
|
155 |
-
# retry button
|
156 |
-
retry_btn = st.button("Retry!")
|
157 |
|
158 |
# randomizer. just another workaround.
|
159 |
st.session_state['uploader_key'] = str(randint(1000, 100000000))
|
160 |
-
|
161 |
-
if retry_btn:
|
162 |
-
page_container.empty()
|
|
|
128 |
st.markdown("""
|
129 |
Here's a before and after!
|
130 |
""")
|
131 |
+
|
132 |
+
# prepare output image for downloading
|
133 |
+
imageRGB = cv.cvtColor(output_image, cv.COLOR_BGR2RGB)
|
134 |
+
img_encode = cv.imencode('.jpg', imageRGB)[1]
|
135 |
+
data_encode = np.array(img_encode)
|
136 |
+
byte_encode = data_encode.tobytes()
|
137 |
+
|
138 |
before_col, after_col = st.columns(2)
|
139 |
with before_col:
|
140 |
# clamp and channels are used since OpenCV was used in processing the image
|
141 |
st.image(uploaded_image, clamp=True, channels='RGB')
|
142 |
+
|
143 |
with after_col:
|
144 |
# clamp and channels are used since OpenCV was used in processing the image
|
145 |
st.image(output_image, clamp=True, channels='RGB')
|
146 |
|
147 |
+
col1, col2, col3, col4 = st.columns(4)
|
148 |
+
|
149 |
+
with col1:
|
150 |
+
pass
|
151 |
+
with col2:
|
152 |
+
# retry message
|
153 |
+
# st.markdown('Not satisfied? Click this to retry!')
|
154 |
+
# retry button
|
155 |
+
retry_btn = st.button("Try another image")
|
156 |
+
|
157 |
+
if retry_btn:
|
158 |
+
page_container.empty()
|
159 |
+
with col3:
|
160 |
+
# some instruction for downloading
|
161 |
+
# st.write("Finally, just download your _anime-fied_ image!")
|
162 |
+
# download button
|
163 |
+
st.download_button('Download Image', byte_encode, 'output.jpg', 'jpg')
|
164 |
+
with col4:
|
165 |
+
pass
|
166 |
|
167 |
st.write("---")
|
|
|
|
|
|
|
|
|
|
|
168 |
|
169 |
# randomizer. just another workaround.
|
170 |
st.session_state['uploader_key'] = str(randint(1000, 100000000))
|
|
|
|
|
|
requirements.txt
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
-
tensorflow-gpu
|
2 |
opencv-python-headless
|
3 |
numpy
|
|
|
1 |
+
tensorflow-gpu==1.15.0
|
2 |
opencv-python-headless
|
3 |
numpy
|