Spaces:
Runtime error
Runtime error
updated visuals
Browse files
app.py
CHANGED
@@ -116,12 +116,16 @@ unsafe_allow_html=True)
|
|
116 |
# Main window configuration
|
117 |
st.title("Black and white colorizer")
|
118 |
st.markdown("This app puts color into your black and white pictures")
|
119 |
-
|
|
|
|
|
|
|
|
|
120 |
|
121 |
-
|
122 |
|
123 |
# # Sidebar
|
124 |
-
|
125 |
('Artistic', 'Stable'))
|
126 |
|
127 |
# st.sidebar.title('Model parameters')
|
@@ -130,20 +134,16 @@ color_option = st.sidebar.selectbox('Select colorizer mode',
|
|
130 |
|
131 |
# Load models
|
132 |
try:
|
133 |
-
colorizer = load_model(model_folder,
|
134 |
except:
|
135 |
colorizer = None
|
136 |
print('Error while loading the model. Please refresh the page')
|
137 |
|
138 |
if colorizer is not None:
|
139 |
-
|
140 |
|
141 |
#Choose your own image
|
142 |
-
uploaded_file =
|
143 |
-
|
144 |
-
# show = st.image(use_column_width='auto')
|
145 |
-
input_img_pos = st.empty()
|
146 |
-
output_img_pos = st.empty()
|
147 |
|
148 |
if uploaded_file is not None:
|
149 |
img_name = uploaded_file.name
|
@@ -154,14 +154,14 @@ if colorizer is not None:
|
|
154 |
resized_img_rgb = resize_img(img_rgb, max_img_size)
|
155 |
resized_pil_img = PIL.Image.fromarray(resized_img_rgb)
|
156 |
|
157 |
-
|
158 |
|
159 |
output_pil_img = colorizer.plot_transformed_pil_image(resized_pil_img, render_factor=35, compare=False)
|
160 |
|
161 |
-
|
162 |
|
163 |
# Plot images
|
164 |
-
|
165 |
-
|
166 |
|
167 |
-
|
|
|
116 |
# Main window configuration
|
117 |
st.title("Black and white colorizer")
|
118 |
st.markdown("This app puts color into your black and white pictures")
|
119 |
+
st_title_message = st.empty()
|
120 |
+
st_file_uploader = st.empty()
|
121 |
+
st_input_img = st.empty()
|
122 |
+
st_output_img = st.empty()
|
123 |
+
st_download_button = st.empty()
|
124 |
|
125 |
+
st_title_message.markdown("**Model loading, please wait** β")
|
126 |
|
127 |
# # Sidebar
|
128 |
+
st_color_option = st.sidebar.selectbox('Select colorizer mode',
|
129 |
('Artistic', 'Stable'))
|
130 |
|
131 |
# st.sidebar.title('Model parameters')
|
|
|
134 |
|
135 |
# Load models
|
136 |
try:
|
137 |
+
colorizer = load_model(model_folder, st_color_option)
|
138 |
except:
|
139 |
colorizer = None
|
140 |
print('Error while loading the model. Please refresh the page')
|
141 |
|
142 |
if colorizer is not None:
|
143 |
+
st_title_message.markdown("**To begin, please upload an image** π")
|
144 |
|
145 |
#Choose your own image
|
146 |
+
uploaded_file = st_file_uploader.file_uploader("Upload a black and white photo", type=['png', 'jpg', 'jpeg'])
|
|
|
|
|
|
|
|
|
147 |
|
148 |
if uploaded_file is not None:
|
149 |
img_name = uploaded_file.name
|
|
|
154 |
resized_img_rgb = resize_img(img_rgb, max_img_size)
|
155 |
resized_pil_img = PIL.Image.fromarray(resized_img_rgb)
|
156 |
|
157 |
+
st_title_message.markdown("**Processing your image, please wait** β")
|
158 |
|
159 |
output_pil_img = colorizer.plot_transformed_pil_image(resized_pil_img, render_factor=35, compare=False)
|
160 |
|
161 |
+
st_title_message.markdown("**To begin, please upload an image** π")
|
162 |
|
163 |
# Plot images
|
164 |
+
st_input_img.image(resized_pil_img, 'Input image', use_column_width=True)
|
165 |
+
st_output_img.image(output_pil_img, 'Output image', use_column_width=True)
|
166 |
|
167 |
+
st_download_button.markdown(get_image_download_link(output_pil_img, img_name, 'Download Image'), unsafe_allow_html=True)
|