mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-07-01 21:07:20 +08:00
High quality Stable Cascade Stage C previews via previewer.safetensors
This commit is contained in:
parent
3a0eeee320
commit
96be1c553c
@ -232,7 +232,7 @@ To use a textual inversion concepts/embeddings in a text prompt put them in the
|
|||||||
|
|
||||||
Use ```--preview-method auto``` to enable previews.
|
Use ```--preview-method auto``` to enable previews.
|
||||||
|
|
||||||
The default installation includes a fast latent preview method that's low-resolution. To enable higher-quality previews with [TAESD](https://github.com/madebyollin/taesd), download the [taesd_decoder.pth, taesdxl_decoder.pth, taesd3_decoder.pth and taef1_decoder.pth](https://github.com/madebyollin/taesd/) and place them in the `models/vae_approx` folder. Once they're installed, restart ComfyUI and launch it with `--preview-method taesd` to enable high-quality previews.
|
The default installation includes a fast latent preview method that's low-resolution. To enable higher-quality previews with [TAESD](https://github.com/madebyollin/taesd) or the Stable Cascade previewer, download [taesd_decoder.pth, taesdxl_decoder.pth, taesd3_decoder.pth and taef1_decoder.pth](https://github.com/madebyollin/taesd/) and/or [previewer.safetensors](https://huggingface.co/stabilityai/stable-cascade/resolve/main/previewer.safetensors) and place them in the `models/vae_approx` folder. Once they're installed, restart ComfyUI and launch it with `--preview-method taesd` to enable high-quality previews.
|
||||||
|
|
||||||
## How to use TLS/SSL?
|
## How to use TLS/SSL?
|
||||||
Generate a self-signed certificate (not appropriate for shared/production use) and key by running the command: `openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -sha256 -days 3650 -nodes -subj "/C=XX/ST=StateName/L=CityName/O=CompanyName/OU=CompanySectionName/CN=CommonNameOrHostname"`
|
Generate a self-signed certificate (not appropriate for shared/production use) and key by running the command: `openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -sha256 -days 3650 -nodes -subj "/C=XX/ST=StateName/L=CityName/O=CompanyName/OU=CompanySectionName/CN=CommonNameOrHostname"`
|
||||||
|
@ -95,6 +95,7 @@ class SC_Prior(LatentFormat):
|
|||||||
[ 0.0542, 0.1545, 0.1325],
|
[ 0.0542, 0.1545, 0.1325],
|
||||||
[-0.0352, -0.1672, -0.2541]
|
[-0.0352, -0.1672, -0.2541]
|
||||||
]
|
]
|
||||||
|
taesd_decoder_name = "previewer.safetensors"
|
||||||
|
|
||||||
class SC_B(LatentFormat):
|
class SC_B(LatentFormat):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -8,6 +8,7 @@ import comfy.model_management
|
|||||||
import folder_paths
|
import folder_paths
|
||||||
import comfy.utils
|
import comfy.utils
|
||||||
import logging
|
import logging
|
||||||
|
from comfy.ldm.cascade.stage_c_coder import Previewer
|
||||||
|
|
||||||
MAX_PREVIEW_RESOLUTION = args.preview_size
|
MAX_PREVIEW_RESOLUTION = args.preview_size
|
||||||
|
|
||||||
@ -35,6 +36,17 @@ class TAESDPreviewerImpl(LatentPreviewer):
|
|||||||
return preview_to_image(x_sample)
|
return preview_to_image(x_sample)
|
||||||
|
|
||||||
|
|
||||||
|
class StageCPreviewer(Previewer):
|
||||||
|
def __init__(self, path):
|
||||||
|
super().__init__()
|
||||||
|
sd = comfy.utils.load_torch_file(path, safe_load=True)
|
||||||
|
self.load_state_dict(sd, strict=True)
|
||||||
|
self.eval()
|
||||||
|
|
||||||
|
def decode(self, latent):
|
||||||
|
return self(latent)
|
||||||
|
|
||||||
|
|
||||||
class Latent2RGBPreviewer(LatentPreviewer):
|
class Latent2RGBPreviewer(LatentPreviewer):
|
||||||
def __init__(self, latent_rgb_factors):
|
def __init__(self, latent_rgb_factors):
|
||||||
self.latent_rgb_factors = torch.tensor(latent_rgb_factors, device="cpu")
|
self.latent_rgb_factors = torch.tensor(latent_rgb_factors, device="cpu")
|
||||||
@ -64,6 +76,9 @@ def get_previewer(device, latent_format):
|
|||||||
|
|
||||||
if method == LatentPreviewMethod.TAESD:
|
if method == LatentPreviewMethod.TAESD:
|
||||||
if taesd_decoder_path:
|
if taesd_decoder_path:
|
||||||
|
if 'previewer' in taesd_decoder_path:
|
||||||
|
taesd = StageCPreviewer(taesd_decoder_path).to(device)
|
||||||
|
else:
|
||||||
taesd = TAESD(None, taesd_decoder_path, latent_channels=latent_format.latent_channels).to(device)
|
taesd = TAESD(None, taesd_decoder_path, latent_channels=latent_format.latent_channels).to(device)
|
||||||
previewer = TAESDPreviewerImpl(taesd)
|
previewer = TAESDPreviewerImpl(taesd)
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user