Remove old files
Fix `create_image_grid`
This commit is contained in:
LEv145
2023-04-05 19:34:54 +02:00
parent 38a0ae0fd0
commit 2059c14cff
4 changed files with 3 additions and 106 deletions
-23
View File
@@ -1,23 +0,0 @@
import typing as t
from ..base import BasePlotNode, Image
class FloatImageCombineNode(BasePlotNode):
RETURN_TYPES: t.Tuple[str] = ("IMAGES",)
@classmethod
def INPUT_TYPES(cls) -> t.Dict[str, t.Any]:
return {
"required": {
"float_image_1": ("IMAGES",),
"float_image_2": ("IMAGES",),
},
}
def execute(
self,
float_image_1: t.List[Image],
float_image_2: t.List[Image],
) -> t.Tuple[t.List[Image]]:
return (float_image_1 + float_image_2,)
-18
View File
@@ -1,18 +0,0 @@
import typing as t
from ..base import BasePlotNode, Image
class ImageSetAreaNode(BasePlotNode):
RETURN_TYPES: t.Tuple[str] = ("IMAGES",)
@classmethod
def INPUT_TYPES(cls) -> t.Dict[str, t.Any]:
return {
"required": {
"image": ("IMAGE",),
},
}
def execute(self, image: Image) -> t.Tuple[t.List[Image]]:
return ([image],)
-62
View File
@@ -1,62 +0,0 @@
import typing as t
from nodes import KSamplerAdvanced # type: ignore
from ..base import BasePlotNode, Image, KSamplerXYPlotInput
class KSamplerXYPlotNode(BasePlotNode):
RETURN_TYPES: t.Tuple[str] = ("IMAGES",)
def __init__(self) -> None:
self._sampler = KSamplerAdvanced()
@classmethod
def INPUT_TYPES(cls):
result = KSamplerAdvanced.INPUT_TYPES()
result["required"]["vae"] = ("VAE", )
#result["required"]["x_items"] = ("XYPlotItem",)
#result["required"]["y_items"] = ("XYPlotItem",)
return result
def execute(
self,
vae,
#x_items,
#y_items,
**sampler_kw,
) -> tuple[t.List[Image]]:
x_items = [
KSamplerXYPlotInput(value=1, setting="cfg"),
KSamplerXYPlotInput(value=2, setting="cfg"),
]
y_items = [
KSamplerXYPlotInput(value=1, setting="noise_seed"),
KSamplerXYPlotInput(value=2, setting="noise_seed"),
]
latents = self._sample_latents(
x_items=x_items,
y_items=y_items,
sampler_kw=sampler_kw,
)
result = list(self._decode_latents(latents=latents, vae=vae))
print(result)
print(type(result[0]))
return (result,)
def _sample_latents(self, x_items, y_items, sampler_kw):
for x in x_items:
for y in y_items:
sampler_settings = sampler_kw.copy()
sampler_settings[x.setting] = x.value
sampler_settings[y.setting] = y.value
yield self._sampler.sample(**sampler_settings)[0]
def _decode_latents(self, latents, vae) -> t.Iterable[Image]:
return (
vae.decode(i["samples"])
for i in latents
)
+3 -3
View File
@@ -13,18 +13,18 @@ class XYPlotNode(BasePlotNode):
"required": { "required": {
"images": ("IMAGE",), "images": ("IMAGE",),
"gap": ("INT", {"default": 0, "min": 0}), "gap": ("INT", {"default": 0, "min": 0}),
"nrow": ("INT", {"default": 1, "min": 1}), "ncol": ("INT", {"default": 1, "min": 1}),
}, },
} }
def execute( def execute(
self, self,
images: Image, images: Image,
nrow: int, ncol: int,
gap: int gap: int
) -> tuple[Image]: ) -> tuple[Image]:
pillow_images = [tensor_to_pillow(i) for i in images] pillow_images = [tensor_to_pillow(i) for i in images]
pillow_grid = create_image_grid(pillow_images, nrow=nrow, gap=gap) pillow_grid = create_image_grid(pillow_images, ncol=ncol, gap=gap)
tensor_grid = pillow_to_tensor(pillow_grid) tensor_grid = pillow_to_tensor(pillow_grid)
return (tensor_grid,) return (tensor_grid,)