feat(nodes): extract LATENT_SCALE_FACTOR to constants.py

This commit is contained in:
psychedelicious 2024-02-11 08:52:07 +11:00
parent b7ffd36cc6
commit ba7b1b2665
3 changed files with 9 additions and 7 deletions

View File

@ -0,0 +1,7 @@
LATENT_SCALE_FACTOR = 8
"""
HACK: Many nodes are currently hard-coded to use a fixed latent scale factor of 8. This is fragile, and will need to
be addressed if future models use a different latent scale factor. Also, note that there may be places where the scale
factor is hard-coded to a literal '8' rather than using this constant.
The ratio of image:latent dimensions is LATENT_SCALE_FACTOR:1, or 8:1.
"""

View File

@ -23,6 +23,7 @@ from diffusers.schedulers import SchedulerMixin as Scheduler
from pydantic import field_validator from pydantic import field_validator
from torchvision.transforms.functional import resize as tv_resize from torchvision.transforms.functional import resize as tv_resize
from invokeai.app.invocations.constants import LATENT_SCALE_FACTOR
from invokeai.app.invocations.fields import ( from invokeai.app.invocations.fields import (
ConditioningField, ConditioningField,
DenoiseMaskField, DenoiseMaskField,
@ -79,12 +80,6 @@ DEFAULT_PRECISION = choose_precision(choose_torch_device())
SAMPLER_NAME_VALUES = Literal[tuple(SCHEDULER_MAP.keys())] SAMPLER_NAME_VALUES = Literal[tuple(SCHEDULER_MAP.keys())]
# HACK: Many nodes are currently hard-coded to use a fixed latent scale factor of 8. This is fragile, and will need to
# be addressed if future models use a different latent scale factor. Also, note that there may be places where the scale
# factor is hard-coded to a literal '8' rather than using this constant.
# The ratio of image:latent dimensions is LATENT_SCALE_FACTOR:1, or 8:1.
LATENT_SCALE_FACTOR = 8
@invocation_output("scheduler_output") @invocation_output("scheduler_output")
class SchedulerOutput(BaseInvocationOutput): class SchedulerOutput(BaseInvocationOutput):

View File

@ -3,7 +3,7 @@ from typing import Union
import numpy as np import numpy as np
from invokeai.app.invocations.latent import LATENT_SCALE_FACTOR from invokeai.app.invocations.constants import LATENT_SCALE_FACTOR
from invokeai.backend.tiles.utils import TBLR, Tile, paste, seam_blend from invokeai.backend.tiles.utils import TBLR, Tile, paste, seam_blend