Spaces:
Running
on
A100
Running
on
A100
return PIL images everywhere, do not convert to PNG to avoid artifacts
Browse files
app.py
CHANGED
@@ -137,7 +137,6 @@ def infer(ref_style_file, style_description, caption, progress):
|
|
137 |
height=1024
|
138 |
width=1024
|
139 |
batch_size=1
|
140 |
-
output_file='output.png'
|
141 |
|
142 |
stage_c_latent_shape, stage_b_latent_shape = calculate_latent_sizes(height, width, batch_size=batch_size)
|
143 |
|
@@ -221,13 +220,11 @@ def infer(ref_style_file, style_description, caption, progress):
|
|
221 |
# Ensure the tensor is in [C, H, W] format
|
222 |
if sampled.dim() == 3 and sampled.shape[0] == 3:
|
223 |
sampled_image = T.ToPILImage()(sampled) # Convert tensor to PIL image
|
224 |
-
# sampled_image.save(output_file) # Save the image as a PNG
|
225 |
else:
|
226 |
raise ValueError(f"Expected tensor of shape [3, H, W] but got {sampled.shape}")
|
227 |
|
228 |
progress(1.0, "Inference complete")
|
229 |
-
|
230 |
-
return sampled_image
|
231 |
|
232 |
finally:
|
233 |
# Clear CUDA cache
|
@@ -342,14 +339,12 @@ def infer_compo(style_description, ref_style_file, caption, ref_sub_file, progre
|
|
342 |
|
343 |
# Ensure the tensor is in [C, H, W] format
|
344 |
if sampled.dim() == 3 and sampled.shape[0] == 3:
|
345 |
-
output_file = 'output_compo.png'
|
346 |
sampled_image = T.ToPILImage()(sampled) # Convert tensor to PIL image
|
347 |
-
sampled_image.save(output_file) # Save the image as a PNG
|
348 |
else:
|
349 |
raise ValueError(f"Expected tensor of shape [3, H, W] but got {sampled.shape}")
|
350 |
|
351 |
progress(1.0, "Inference complete")
|
352 |
-
return
|
353 |
|
354 |
finally:
|
355 |
# Clear CUDA cache
|
|
|
137 |
height=1024
|
138 |
width=1024
|
139 |
batch_size=1
|
|
|
140 |
|
141 |
stage_c_latent_shape, stage_b_latent_shape = calculate_latent_sizes(height, width, batch_size=batch_size)
|
142 |
|
|
|
220 |
# Ensure the tensor is in [C, H, W] format
|
221 |
if sampled.dim() == 3 and sampled.shape[0] == 3:
|
222 |
sampled_image = T.ToPILImage()(sampled) # Convert tensor to PIL image
|
|
|
223 |
else:
|
224 |
raise ValueError(f"Expected tensor of shape [3, H, W] but got {sampled.shape}")
|
225 |
|
226 |
progress(1.0, "Inference complete")
|
227 |
+
return sampled_image # Return the sampled_image PIL image
|
|
|
228 |
|
229 |
finally:
|
230 |
# Clear CUDA cache
|
|
|
339 |
|
340 |
# Ensure the tensor is in [C, H, W] format
|
341 |
if sampled.dim() == 3 and sampled.shape[0] == 3:
|
|
|
342 |
sampled_image = T.ToPILImage()(sampled) # Convert tensor to PIL image
|
|
|
343 |
else:
|
344 |
raise ValueError(f"Expected tensor of shape [3, H, W] but got {sampled.shape}")
|
345 |
|
346 |
progress(1.0, "Inference complete")
|
347 |
+
return sampled_image # Return the sampled_image PIL image
|
348 |
|
349 |
finally:
|
350 |
# Clear CUDA cache
|