This commit is contained in:
spacepxl
2024-05-27 20:17:15 -04:00
parent efb52bcce0
commit d57ac7012e
+22
View File
@@ -170,6 +170,26 @@ class TweakStyleGANLatents:
return (z, ) return (z, )
class StyleGANLatentFromBatch:
@classmethod
def INPUT_TYPES(s):
return {
"required": {
"stylegan_latent": ("STYLEGAN_LATENT", ),
"index": ("INT", {"default": 0, "min": 0}),
},
}
RETURN_TYPES = ("STYLEGAN_LATENT",)
FUNCTION = "generate_latent"
CATEGORY = "StyleGAN/extra"
def generate_latent(self, stylegan_latent, index):
clipped_index = min(index, stylegan_latent.size(0) - 1)
z = stylegan_latent[clipped_index].unsqueeze(0).detach().clone()
return (z, )
NODE_CLASS_MAPPINGS = { NODE_CLASS_MAPPINGS = {
"LoadStyleGAN": LoadStyleGAN, "LoadStyleGAN": LoadStyleGAN,
"GenerateStyleGANLatent": GenerateStyleGANLatent, "GenerateStyleGANLatent": GenerateStyleGANLatent,
@@ -177,6 +197,7 @@ NODE_CLASS_MAPPINGS = {
"BlendStyleGANLatents": BlendStyleGANLatents, "BlendStyleGANLatents": BlendStyleGANLatents,
"BatchAverageStyleGANLatents": BatchAverageStyleGANLatents, "BatchAverageStyleGANLatents": BatchAverageStyleGANLatents,
"TweakStyleGANLatents": TweakStyleGANLatents, "TweakStyleGANLatents": TweakStyleGANLatents,
"StyleGANLatentFromBatch": StyleGANLatentFromBatch,
} }
NODE_DISPLAY_NAME_MAPPINGS = { NODE_DISPLAY_NAME_MAPPINGS = {
@@ -186,4 +207,5 @@ NODE_DISPLAY_NAME_MAPPINGS = {
"BlendStyleGANLatents": "Blend StyleGAN Latents (lerp or slerp)", "BlendStyleGANLatents": "Blend StyleGAN Latents (lerp or slerp)",
"BatchAverageStyleGANLatents": "Batch Average StyleGAN Latents", "BatchAverageStyleGANLatents": "Batch Average StyleGAN Latents",
"TweakStyleGANLatents": "Tweak StyleGAN Latents", "TweakStyleGANLatents": "Tweak StyleGAN Latents",
"StyleGANLatentFromBatch": "StyleGAN Latent From Batch",
} }