Spaces:
Runtime error
Runtime error
subatomicseer
commited on
Commit
·
2612f87
1
Parent(s):
7999e5a
Fixed color glitches
Browse files- app.py +5 -3
- infer_func.py +3 -2
app.py
CHANGED
@@ -85,11 +85,13 @@ if __name__ == '__main__':
|
|
85 |
alpha = st.slider('Strength of style transfer', 0.0, 1.0, 1.0, 0.01)
|
86 |
process = st.button('Stylize')
|
87 |
|
|
|
88 |
if content is not None and style is not None and process:
|
89 |
print(content, style)
|
90 |
-
with
|
91 |
-
|
92 |
-
output_image = convert(content, style, VGG_WEIGHT_FILENAME, DECODER_WEIGHT_FILENAME, alpha, color_control)
|
93 |
|
|
|
|
|
94 |
st.image(output_image, width=None, caption='Stylized Image')
|
95 |
|
|
|
85 |
alpha = st.slider('Strength of style transfer', 0.0, 1.0, 1.0, 0.01)
|
86 |
process = st.button('Stylize')
|
87 |
|
88 |
+
output_image = 'output.png'
|
89 |
if content is not None and style is not None and process:
|
90 |
print(content, style)
|
91 |
+
with st.spinner('Processing...'):
|
92 |
+
output_image = convert(content, style, VGG_WEIGHT_FILENAME, DECODER_WEIGHT_FILENAME, alpha, color_control)
|
|
|
93 |
|
94 |
+
if os.path.exists(output_image):
|
95 |
+
with col3:
|
96 |
st.image(output_image, width=None, caption='Stylized Image')
|
97 |
|
infer_func.py
CHANGED
@@ -55,6 +55,7 @@ def convert(content_path, style_path, vgg_weights_path, decoder_weights_path, al
|
|
55 |
with torch.no_grad():
|
56 |
out_tensor = style_transfer(content_tensor, style_tensor, model.encoder, model.decoder, alpha).cpu()
|
57 |
|
58 |
-
|
|
|
59 |
|
60 |
-
return
|
|
|
55 |
with torch.no_grad():
|
56 |
out_tensor = style_transfer(content_tensor, style_tensor, model.encoder, model.decoder, alpha).cpu()
|
57 |
|
58 |
+
outimage_fname = 'output.png'
|
59 |
+
torchvision.utils.save_image(out_tensor.squeeze(0), outimage_fname)
|
60 |
|
61 |
+
return outimage_fname
|