up
This commit is contained in:
+51
-8
@@ -1,3 +1,5 @@
|
|||||||
|
import copy
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
|
|
||||||
|
|
||||||
@@ -8,6 +10,7 @@ class SeamlessTile:
|
|||||||
"required": {
|
"required": {
|
||||||
"model": ("MODEL",),
|
"model": ("MODEL",),
|
||||||
"tiling": (["enable", "disable"],),
|
"tiling": (["enable", "disable"],),
|
||||||
|
"copy_model": (["Modify in place", "Make a copy"],),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -16,14 +19,26 @@ class SeamlessTile:
|
|||||||
RETURN_TYPES = ("MODEL",)
|
RETURN_TYPES = ("MODEL",)
|
||||||
FUNCTION = "run"
|
FUNCTION = "run"
|
||||||
|
|
||||||
def run(self, model, tiling):
|
def run(self, model, copy_model, tiling):
|
||||||
for m in model.model.modules():
|
if copy_model == "Modify in place":
|
||||||
if isinstance(m, torch.nn.Conv2d):
|
model_copy = model
|
||||||
if tiling == "enable":
|
else:
|
||||||
m.padding_mode = "circular"
|
model_copy = copy.deepcopy(model)
|
||||||
else:
|
if tiling == "enable":
|
||||||
m.padding_mode = "zeros"
|
model_copy.model.apply(make_circular)
|
||||||
return (model,)
|
else:
|
||||||
|
model_copy.model.apply(unmake_circular)
|
||||||
|
return (model_copy,)
|
||||||
|
|
||||||
|
|
||||||
|
def make_circular(m):
|
||||||
|
if isinstance(m, torch.nn.Conv2d):
|
||||||
|
m.padding_mode = "circular"
|
||||||
|
|
||||||
|
|
||||||
|
def unmake_circular(m):
|
||||||
|
if isinstance(m, torch.nn.Conv2d):
|
||||||
|
m.padding_mode = "zeros"
|
||||||
|
|
||||||
|
|
||||||
class CircularVAEDecode:
|
class CircularVAEDecode:
|
||||||
@@ -51,3 +66,31 @@ class CircularVAEDecode:
|
|||||||
]:
|
]:
|
||||||
layer.padding_mode = "zeros"
|
layer.padding_mode = "zeros"
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
class MakeCircularVAE:
|
||||||
|
@classmethod
|
||||||
|
def INPUT_TYPES(s):
|
||||||
|
return {
|
||||||
|
"required": {
|
||||||
|
"vae": ("VAE",),
|
||||||
|
"tiling": (["enable", "disable"],),
|
||||||
|
"copy_vae": (["Modify in place", "Make a copy"],),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RETURN_TYPES = ("VAE",)
|
||||||
|
FUNCTION = "run"
|
||||||
|
|
||||||
|
CATEGORY = "latent"
|
||||||
|
|
||||||
|
def run(self, vae, tiling, copy_vae):
|
||||||
|
if copy_vae == "Modify in place":
|
||||||
|
vae_copy = vae
|
||||||
|
else:
|
||||||
|
vae_copy = copy.deepcopy(vae)
|
||||||
|
if tiling == "enable":
|
||||||
|
vae_copy.first_stage_model.apply(make_circular)
|
||||||
|
else:
|
||||||
|
vae_copy.first_stage_model.apply(unmake_circular)
|
||||||
|
return (vae_copy,)
|
||||||
|
|||||||
+3
-1
@@ -1,13 +1,15 @@
|
|||||||
from .SeamlessTile import CircularVAEDecode, SeamlessTile
|
from .SeamlessTile import CircularVAEDecode, MakeCircularVAE, SeamlessTile
|
||||||
|
|
||||||
NODE_CLASS_MAPPINGS = {
|
NODE_CLASS_MAPPINGS = {
|
||||||
"SeamlessTile": SeamlessTile,
|
"SeamlessTile": SeamlessTile,
|
||||||
"CircularVAEDecode": CircularVAEDecode,
|
"CircularVAEDecode": CircularVAEDecode,
|
||||||
|
"MakeCircularVAE": MakeCircularVAE,
|
||||||
}
|
}
|
||||||
|
|
||||||
NODE_DISPLAY_NAME_MAPPINGS = {
|
NODE_DISPLAY_NAME_MAPPINGS = {
|
||||||
"SeamlessTile": "Seamless Tile",
|
"SeamlessTile": "Seamless Tile",
|
||||||
"CircularVAEDecode": "Circular VAE Decode (tile)",
|
"CircularVAEDecode": "Circular VAE Decode (tile)",
|
||||||
|
"MakeCircularVAE": "Make Circular VAE",
|
||||||
}
|
}
|
||||||
|
|
||||||
__all__ = [NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS]
|
__all__ = [NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS]
|
||||||
|
|||||||
Reference in New Issue
Block a user