Skip to content

Commit 4a924c9

Browse files
feat(nodes): hardcode resize latents downsampling
1 parent 0453d60 commit 4a924c9

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

invokeai/app/invocations/latent.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -374,15 +374,14 @@ def invoke(self, context: InvocationContext) -> ImageOutput:
374374

375375

376376
class ResizeLatentsInvocation(BaseInvocation):
377-
"""Resizes latents to explicit width/height."""
377+
"""Resizes latents to explicit width/height (in pixels). Provided dimensions are floor-divided by 8."""
378378

379379
type: Literal["lresize"] = "lresize"
380380

381381
# Inputs
382382
latents: Optional[LatentsField] = Field(description="The latents to resize")
383383
width: int = Field(ge=64, multiple_of=8, description="The width to resize to (px)")
384384
height: int = Field(ge=64, multiple_of=8, description="The height to resize to (px)")
385-
downsample: Optional[int] = Field(default=8, ge=1, description="The downsampling factor (leave at 8 for SD)")
386385
mode: Optional[LATENTS_INTERPOLATION_MODE] = Field(default="bilinear", description="The interpolation mode")
387386
antialias: Optional[bool] = Field(default=False, description="Whether or not to antialias (applied in bilinear and bicubic modes only)")
388387

@@ -391,10 +390,7 @@ def invoke(self, context: InvocationContext) -> LatentsOutput:
391390

392391
resized_latents = torch.nn.functional.interpolate(
393392
latents,
394-
size=(
395-
self.height // self.downsample,
396-
self.width // self.downsample,
397-
),
393+
size=(self.height // 8, self.width // 8),
398394
mode=self.mode,
399395
antialias=self.antialias if self.mode in ["bilinear", "bicubic"] else False,
400396
)
@@ -414,7 +410,7 @@ class ScaleLatentsInvocation(BaseInvocation):
414410

415411
# Inputs
416412
latents: Optional[LatentsField] = Field(description="The latents to scale")
417-
scale_factor: float = Field(ge=0, description="The factor by which to scale the latents")
413+
scale_factor: float = Field(gt=0, description="The factor by which to scale the latents")
418414
mode: Optional[LATENTS_INTERPOLATION_MODE] = Field(default="bilinear", description="The interpolation mode")
419415
antialias: Optional[bool] = Field(default=False, description="Whether or not to antialias (applied in bilinear and bicubic modes only)")
420416

0 commit comments

Comments
 (0)