LucianoCirino/efficiency-nodes-comfyui

[Bug] KSampler (Efficiency) unable to restore the global_preview_method value and fallback to No Preview.

lenkunz opened this issue · 0 comments

It seems like the function set_preview_method was unable to restore the value from preview method saved using function global_preview_method. on tsc_utils.py#L504

def set_preview_method(method):
    if method == 'auto' or method == 'LatentPreviewMethod.Auto':
        args.preview_method = latent_preview.LatentPreviewMethod.Auto
    elif method == 'latent2rgb' or method == 'LatentPreviewMethod.Latent2RGB':
        args.preview_method = latent_preview.LatentPreviewMethod.Latent2RGB
    elif method == 'taesd' or method == 'LatentPreviewMethod.TAESD':
        args.preview_method = latent_preview.LatentPreviewMethod.TAESD
    else:
        args.preview_method = latent_preview.LatentPreviewMethod.NoPreviews

This is because ComfyUI Manager will set the args.preview_method using latent_preview.LatentPreviewMethod class.
(refer to ComfyUI-Manager/init.py#L224)
I can confirm that compare the enum against string will not equal.

Slight change like this would suffice.

# efficiency-nodes-comfyui/tsc_utils.py#L504
def set_preview_method(method):
    if method == 'auto' or method == 'LatentPreviewMethod.Auto' or method == latent_preview.LatentPreviewMethod.Auto:
        args.preview_method = latent_preview.LatentPreviewMethod.Auto
    elif method == 'latent2rgb' or method == 'LatentPreviewMethod.Latent2RGB' or method == latent_preview.LatentPreviewMethod.Latent2RGB:
        args.preview_method = latent_preview.LatentPreviewMethod.Latent2RGB
    elif method == 'taesd' or method == 'LatentPreviewMethod.TAESD' or method == latent_preview.LatentPreviewMethod.TAESD:
        args.preview_method = latent_preview.LatentPreviewMethod.TAESD
    else:
        args.preview_method = latent_preview.LatentPreviewMethod.NoPreviews

Edit: Remove the ComfyUI Manager from title. I just realized that this node will set the args.preview_method to latent_preview.LatentPreviewMethod enum either. And after scan other libs, it seems like using this class is a norm.