Skip to content

Commit

Permalink
Remove old way generation, remove legacy and unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
StAlKeR7779 committed Jun 15, 2023
1 parent 5c74045 commit 8da430f
Show file tree
Hide file tree
Showing 29 changed files with 35 additions and 6,006 deletions.
316 changes: 0 additions & 316 deletions invokeai/app/invocations/generate.py

This file was deleted.

32 changes: 30 additions & 2 deletions invokeai/app/util/step_callback.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,39 @@
import torch
from PIL import Image
from invokeai.app.models.exceptions import CanceledException
from invokeai.app.models.image import ProgressImage
from ..invocations.baseinvocation import InvocationContext
from ...backend.util.util import image_to_dataURL
from ...backend.generator.base import Generator
from ...backend.stable_diffusion import PipelineIntermediateState


def sample_to_lowres_estimated_image(samples):
# origingally adapted from code by @erucipe and @keturn here:
# https://discuss.huggingface.co/t/decoding-latents-to-rgb-without-upscaling/23204/7

# these updated numbers for v1.5 are from @torridgristle
v1_5_latent_rgb_factors = torch.tensor(
[
# R G B
[0.3444, 0.1385, 0.0670], # L1
[0.1247, 0.4027, 0.1494], # L2
[-0.3192, 0.2513, 0.2103], # L3
[-0.1307, -0.1874, -0.7445], # L4
],
dtype=samples.dtype,
device=samples.device,
)

latent_image = samples[0].permute(1, 2, 0) @ v1_5_latent_rgb_factors
latents_ubyte = (
((latent_image + 1) / 2)
.clamp(0, 1) # change scale from -1..1 to 0..1
.mul(0xFF) # to 0..255
.byte()
).cpu()

return Image.fromarray(latents_ubyte.numpy())

def stable_diffusion_step_callback(
context: InvocationContext,
intermediate_state: PipelineIntermediateState,
Expand Down Expand Up @@ -37,7 +65,7 @@ def stable_diffusion_step_callback(
# step = intermediate_state.step

# TODO: only output a preview image when requested
image = Generator.sample_to_lowres_estimated_image(sample)
image = sample_to_lowres_estimated_image(sample)

(width, height) = image.size
width *= 8
Expand Down
8 changes: 0 additions & 8 deletions invokeai/backend/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
"""
Initialization file for invokeai.backend
"""
from .generator import (
InvokeAIGeneratorBasicParams,
InvokeAIGenerator,
InvokeAIGeneratorOutput,
Txt2Img,
Img2Img,
Inpaint
)
from .model_management import (
ModelManager, ModelCache, BaseModelType,
ModelType, SubModelType, ModelInfo
Expand Down
13 changes: 0 additions & 13 deletions invokeai/backend/generator/__init__.py

This file was deleted.

Loading

0 comments on commit 8da430f

Please sign in to comment.