Skip to content
This repository has been archived by the owner on Jan 9, 2024. It is now read-only.

Commit

Permalink
Mini-Patch
Browse files Browse the repository at this point in the history
  • Loading branch information
LucianoCirino authored Apr 18, 2023
1 parent 3ae297d commit de0641c
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions efficiency_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def pil2tensor(image: Image.Image) -> torch.Tensor:


# TSC Efficient Loader
# Track what objects have already been loaded into memory (*only for instances of this node)
# Track what objects have already been loaded into memory
loaded_objects = {
"ckpt": [], # (ckpt_name, location)
"clip": [], # (ckpt_name, location)
Expand Down Expand Up @@ -183,7 +183,7 @@ def INPUT_TYPES(cls):
"denoise": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01}),
"preview_image": (["Disabled", "Enabled"],),
},
"optional": { "optional_vae": ("VAE",), #change to vae
"optional": { "optional_vae": ("VAE",),
"script": ("SCRIPT",),},
"hidden": {"prompt": "PROMPT", "extra_pnginfo": "EXTRA_PNGINFO"},
}
Expand Down Expand Up @@ -301,7 +301,7 @@ def preview_images(images, filename_prefix):
# Enable vae decode on next Hold
last_helds["vae_decode"][my_unique_id] = True
return {"ui": {"images": list()},
"result": (model, positive, negative, {"samples": latent}, vae, TSC_KSampler.empty_image,)}
"result": (model, positive, negative, {"samples": latent}, vae, last_images,)}
else:
# Decode images and store
images = vae.decode(latent).cpu()
Expand All @@ -326,7 +326,7 @@ def preview_images(images, filename_prefix):
# If not in preview mode, return the results in the specified format
if preview_image == "Disabled":
return {"ui": {"images": list()},
"result": (model, positive, negative, last_latent, vae, TSC_KSampler.empty_image,)}
"result": (model, positive, negative, last_latent, vae, last_images,)}

# if preview_image == "Enabled":
else:
Expand Down Expand Up @@ -354,11 +354,6 @@ def preview_images(images, filename_prefix):
"result": (model, positive, negative, {"samples": latent}, vae, images,)}

elif sampler_state == "Script":
# If not in preview mode, return the results in the specified format
if preview_image == "Disabled":
print('\033[31mKSampler(Efficient)[{}] Error:\033[0m Preview must be enabled to use Script mode.'.format(my_unique_id))
return {"ui": {"images": list()},
"result": (model, positive, negative, last_latent, vae, TSC_KSampler.empty_image,)}

# If no script input connected, set X_type and Y_type to "Nothing"
if script is None:
Expand All @@ -369,9 +364,9 @@ def preview_images(images, filename_prefix):
X_type, X_value, Y_type, Y_value, grid_spacing, latent_id = script

if (X_type == "Nothing" and Y_type == "Nothing"):
print('\033[31mKSampler(Efficient)[{}] Error:\033[0m No valid script input detected'.format(my_unique_id))
print('\033[31mKSampler(Efficient)[{}] Error:\033[0m No valid script entry detected'.format(my_unique_id))
return {"ui": {"images": list()},
"result": (model, positive, negative, last_latent, vae, TSC_KSampler.empty_image,)}
"result": (model, positive, negative, last_latent, vae, last_images,)}

# Extract the 'samples' tensor from the dictionary
latent_image_tensor = latent_image['samples']
Expand Down Expand Up @@ -706,8 +701,12 @@ def rearrange_tensors(latent, num_cols, num_rows):
results = preview_images(images, filename_prefix)
last_helds["results"][my_unique_id] = results

# Output image results to ui and node outputs
return {"ui": {"images": results}, "result": (model, positive, negative, {"samples": latent_new}, vae, images,)}
# If not in preview mode, return the results in the specified format
if preview_image == "Disabled":
return {"ui": {"images": list()}, "result": (model, positive, negative, last_latent, vae, images,)}
else:
# Output image results to ui and node outputs
return {"ui": {"images": results}, "result": (model, positive, negative, {"samples": latent_new}, vae, images,)}


# TSC XY Plot
Expand Down

1 comment on commit de0641c

@LucianoCirino
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed how "Preview Image" on KSampler (Efficient) interacts without sampler_state and output Image.

Please sign in to comment.