feat(nodes): use LATENT_SCALE_FACTOR const in tensor output builders

This commit is contained in:
psychedelicious 2024-02-08 07:55:36 +11:00
parent bcb85e100d
commit bc5f356390
2 changed files with 6 additions and 4 deletions

View File

@ -5,6 +5,7 @@ import torch
from pydantic import field_validator from pydantic import field_validator
from invokeai.app.invocations.fields import FieldDescriptions, InputField, LatentsField, OutputField from invokeai.app.invocations.fields import FieldDescriptions, InputField, LatentsField, OutputField
from invokeai.app.invocations.latent import LATENT_SCALE_FACTOR
from invokeai.app.services.shared.invocation_context import InvocationContext from invokeai.app.services.shared.invocation_context import InvocationContext
from invokeai.app.util.misc import SEED_MAX from invokeai.app.util.misc import SEED_MAX
@ -70,8 +71,8 @@ class NoiseOutput(BaseInvocationOutput):
def build(cls, latents_name: str, latents: torch.Tensor, seed: int) -> "NoiseOutput": def build(cls, latents_name: str, latents: torch.Tensor, seed: int) -> "NoiseOutput":
return cls( return cls(
noise=LatentsField(latents_name=latents_name, seed=seed), noise=LatentsField(latents_name=latents_name, seed=seed),
width=latents.size()[3] * 8, width=latents.size()[3] * LATENT_SCALE_FACTOR,
height=latents.size()[2] * 8, height=latents.size()[2] * LATENT_SCALE_FACTOR,
) )

View File

@ -16,6 +16,7 @@ from invokeai.app.invocations.fields import (
OutputField, OutputField,
UIComponent, UIComponent,
) )
from invokeai.app.invocations.latent import LATENT_SCALE_FACTOR
from invokeai.app.services.images.images_common import ImageDTO from invokeai.app.services.images.images_common import ImageDTO
from invokeai.app.services.shared.invocation_context import InvocationContext from invokeai.app.services.shared.invocation_context import InvocationContext
@ -321,8 +322,8 @@ class LatentsOutput(BaseInvocationOutput):
def build(cls, latents_name: str, latents: torch.Tensor, seed: Optional[int] = None) -> "LatentsOutput": def build(cls, latents_name: str, latents: torch.Tensor, seed: Optional[int] = None) -> "LatentsOutput":
return cls( return cls(
latents=LatentsField(latents_name=latents_name, seed=seed), latents=LatentsField(latents_name=latents_name, seed=seed),
width=latents.size()[3] * 8, width=latents.size()[3] * LATENT_SCALE_FACTOR,
height=latents.size()[2] * 8, height=latents.size()[2] * LATENT_SCALE_FACTOR,
) )