Update app.py
Browse files
app.py
CHANGED
|
@@ -195,8 +195,9 @@ def infer(
|
|
| 195 |
width=width,
|
| 196 |
height=height,
|
| 197 |
latents=sd_image_a,
|
|
|
|
| 198 |
generator=generator
|
| 199 |
-
).images
|
| 200 |
else:
|
| 201 |
print('-- generating image --')
|
| 202 |
#with torch.no_grad():
|
|
@@ -210,13 +211,19 @@ def infer(
|
|
| 210 |
width=width,
|
| 211 |
height=height,
|
| 212 |
# latents=None,
|
|
|
|
| 213 |
generator=generator,
|
| 214 |
max_sequence_length=512
|
| 215 |
-
).images
|
| 216 |
print('-- got image --')
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 220 |
# Convert the generated image to a tensor
|
| 221 |
generated_image_tensor = torch.tensor([np.array(sd_image).transpose(2, 0, 1)]).to('cuda') / 255.0
|
| 222 |
# Encode the generated image into latents
|
|
|
|
| 195 |
width=width,
|
| 196 |
height=height,
|
| 197 |
latents=sd_image_a,
|
| 198 |
+
output='latent',
|
| 199 |
generator=generator
|
| 200 |
+
).images
|
| 201 |
else:
|
| 202 |
print('-- generating image --')
|
| 203 |
#with torch.no_grad():
|
|
|
|
| 211 |
width=width,
|
| 212 |
height=height,
|
| 213 |
# latents=None,
|
| 214 |
+
output='latent',
|
| 215 |
generator=generator,
|
| 216 |
max_sequence_length=512
|
| 217 |
+
).images
|
| 218 |
print('-- got image --')
|
| 219 |
+
sd35_image = pipe.vae.decode(sd_image / 0.18215).sample
|
| 220 |
+
sd35_image = sdxl_image.cpu().permute(0, 2, 3, 1).float().detach().numpy()
|
| 221 |
+
sd35_image = (sdxl_image * 255).round().astype("uint8")
|
| 222 |
+
image_pil = Image.fromarray(sd35_image[0])
|
| 223 |
+
sd35_path = f"tst_rv_{seed}.png"
|
| 224 |
+
image_pil.save(sd35_path,optimize=False,compress_level=0)
|
| 225 |
+
upload_to_ftp(sd35_path)
|
| 226 |
+
|
| 227 |
# Convert the generated image to a tensor
|
| 228 |
generated_image_tensor = torch.tensor([np.array(sd_image).transpose(2, 0, 1)]).to('cuda') / 255.0
|
| 229 |
# Encode the generated image into latents
|