mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix generate backend to generate "accurate" intermediate images
- Closes #2784 - Closes #2775
This commit is contained in:
parent
24407048a5
commit
7fb2da8741
@ -137,17 +137,9 @@ class Generator:
|
|||||||
Given samples returned from a sampler, converts
|
Given samples returned from a sampler, converts
|
||||||
it into a PIL Image
|
it into a PIL Image
|
||||||
"""
|
"""
|
||||||
x_samples = self.model.decode_first_stage(samples)
|
with torch.inference_mode():
|
||||||
x_samples = torch.clamp((x_samples + 1.0) / 2.0, min=0.0, max=1.0)
|
image = self.model.decode_latents(samples)
|
||||||
if len(x_samples) != 1:
|
return self.model.numpy_to_pil(image)[0]
|
||||||
raise Exception(
|
|
||||||
f'>> expected to get a single image, but got {len(x_samples)}')
|
|
||||||
x_sample = 255.0 * rearrange(
|
|
||||||
x_samples[0].cpu().numpy(), 'c h w -> h w c'
|
|
||||||
)
|
|
||||||
return Image.fromarray(x_sample.astype(np.uint8))
|
|
||||||
|
|
||||||
# write an approximate RGB image from latent samples for a single step to PNG
|
|
||||||
|
|
||||||
def repaste_and_color_correct(self, result: Image.Image, init_image: Image.Image, init_mask: Image.Image, mask_blur_radius: int = 8) -> Image.Image:
|
def repaste_and_color_correct(self, result: Image.Image, init_image: Image.Image, init_mask: Image.Image, mask_blur_radius: int = 8) -> Image.Image:
|
||||||
if init_image is None or init_mask is None:
|
if init_image is None or init_mask is None:
|
||||||
|
Loading…
Reference in New Issue
Block a user