Update app.py
Browse files
app.py
CHANGED
|
@@ -158,23 +158,34 @@ def infer(
|
|
| 158 |
if latent_file: # Check if a latent file is provided
|
| 159 |
sd_image_a = torch.load(latent_file.name) # Load the latent
|
| 160 |
print("-- using latent file --")
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 173 |
image_path = f"sd35m_{seed}.png"
|
| 174 |
sd_image.save(image_path,optimize=False,compress_level=0)
|
| 175 |
upload_to_ftp(image_path)
|
| 176 |
-
|
| 177 |
-
# Convert the generated image to a tensor
|
| 178 |
generated_image_tensor = torch.tensor([np.array(sd_image).transpose(2, 0, 1)]).to('cuda') / 255.0
|
| 179 |
# Encode the generated image into latents
|
| 180 |
with torch.no_grad():
|
|
|
|
| 158 |
if latent_file: # Check if a latent file is provided
|
| 159 |
sd_image_a = torch.load(latent_file.name) # Load the latent
|
| 160 |
print("-- using latent file --")
|
| 161 |
+
print('-- generating image --')
|
| 162 |
+
with torch.no_grad():
|
| 163 |
+
sd_image = pipe(
|
| 164 |
+
prompt=enhanced_prompt, # This conversion is fine
|
| 165 |
+
negative_prompt=negative_prompt,
|
| 166 |
+
guidance_scale=guidance_scale,
|
| 167 |
+
num_inference_steps=num_inference_steps,
|
| 168 |
+
width=width,
|
| 169 |
+
height=height,
|
| 170 |
+
latent=sd_image_a,
|
| 171 |
+
generator=generator
|
| 172 |
+
).images[0]
|
| 173 |
+
else:
|
| 174 |
+
with torch.no_grad():
|
| 175 |
+
sd_image = pipe(
|
| 176 |
+
prompt=enhanced_prompt, # This conversion is fine
|
| 177 |
+
negative_prompt=negative_prompt,
|
| 178 |
+
guidance_scale=guidance_scale,
|
| 179 |
+
num_inference_steps=num_inference_steps,
|
| 180 |
+
width=width,
|
| 181 |
+
height=height,
|
| 182 |
+
generator=generator
|
| 183 |
+
).images[0]
|
| 184 |
+
print('-- got image --')
|
| 185 |
image_path = f"sd35m_{seed}.png"
|
| 186 |
sd_image.save(image_path,optimize=False,compress_level=0)
|
| 187 |
upload_to_ftp(image_path)
|
| 188 |
+
# Convert the generated image to a tensor
|
|
|
|
| 189 |
generated_image_tensor = torch.tensor([np.array(sd_image).transpose(2, 0, 1)]).to('cuda') / 255.0
|
| 190 |
# Encode the generated image into latents
|
| 191 |
with torch.no_grad():
|