mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-01-11 14:50:49 +08:00
96 lines
4.1 KiB
Python
96 lines
4.1 KiB
Python
import dataclasses
|
|
from typing import List, Optional
|
|
|
|
from huggingface_hub import hf_hub_download
|
|
|
|
from .cmd import folder_paths
|
|
from .utils import comfy_tqdm
|
|
from posixpath import split
|
|
|
|
|
|
@dataclasses.dataclass
|
|
class HuggingFile:
|
|
"""
|
|
A file on Huggingface Hub
|
|
|
|
Attributes:
|
|
repo_id (str): The Huggingface repository of a known file
|
|
filename (str): The path to the known file in the repository
|
|
show_in_ui (bool): Not used. Will indicate whether or not the file should be shown in the UI to reduce clutter
|
|
"""
|
|
repo_id: str
|
|
filename: str
|
|
show_in_ui: Optional[bool] = True
|
|
|
|
def __str__(self):
|
|
return split(self.filename)[-1]
|
|
|
|
|
|
def get_filename_list_with_downloadable(folder_name: str, known_huggingface_files: List[HuggingFile]) -> List[str]:
|
|
existing = frozenset(folder_paths.get_filename_list(folder_name))
|
|
downloadable = frozenset(str(f) for f in known_huggingface_files)
|
|
return sorted(list(existing | downloadable))
|
|
|
|
|
|
def get_or_download(folder_name: str, filename: str, known_huggingface_files: List[HuggingFile]) -> str:
|
|
path = folder_paths.get_full_path(folder_name, filename)
|
|
|
|
if path is None:
|
|
try:
|
|
destination = folder_paths.get_folder_paths(folder_name)[0]
|
|
hugging_file = next(f for f in known_huggingface_files if str(f) == filename)
|
|
with comfy_tqdm():
|
|
path = hf_hub_download(repo_id=hugging_file.repo_id,
|
|
filename=hugging_file.filename,
|
|
local_dir=destination,
|
|
resume_download=True)
|
|
except StopIteration:
|
|
pass
|
|
except Exception:
|
|
pass
|
|
return path
|
|
|
|
|
|
KNOWN_CHECKPOINTS = [
|
|
HuggingFile("stabilityai/stable-diffusion-xl-base-1.0", "sd_xl_base_1.0.safetensors"),
|
|
HuggingFile("stabilityai/stable-diffusion-xl-refiner-1.0", "sd_xl_refiner_1.0.safetensors"),
|
|
HuggingFile("stabilityai/sdxl-turbo", "sd_xl_turbo_1.0_fp16.safetensors"),
|
|
HuggingFile("stabilityai/sdxl-turbo", "sd_xl_turbo_1.0.safetensors", show_in_ui=False),
|
|
HuggingFile("stabilityai/stable-cascade", "comfyui_checkpoints/stable_cascade_stage_b.safetensors"),
|
|
HuggingFile("stabilityai/stable-cascade", "comfyui_checkpoints/stable_cascade_stage_c.safetensors"),
|
|
HuggingFile("stabilityai/stable-cascade", "comfyui_checkpoints/stage_a.safetensors"),
|
|
HuggingFile("runwayml/stable-diffusion-v1-5", "v1-5-pruned-emaonly.safetensors"),
|
|
HuggingFile("runwayml/stable-diffusion-v1-5", "v1-5-pruned-emaonly.ckpt", show_in_ui=False),
|
|
HuggingFile("runwayml/stable-diffusion-v1-5", "v1-5-pruned.ckpt", show_in_ui=False),
|
|
HuggingFile("runwayml/stable-diffusion-v1-5", "v1-5-pruned.safetensors", show_in_ui=False),
|
|
# from https://github.com/comfyanonymous/ComfyUI_examples/tree/master/2_pass_txt2img
|
|
HuggingFile("stabilityai/stable-diffusion-2-1", "v2-1_768-ema-pruned.ckpt", show_in_ui=False),
|
|
HuggingFile("waifu-diffusion/wd-1-5-beta3", "wd-illusion-fp16.safetensors", show_in_ui=False),
|
|
HuggingFile("jomcs/NeverEnding_Dream-Feb19-2023", "CarDos Anime/cardosAnime_v10.safetensors", show_in_ui=False),
|
|
# from https://github.com/comfyanonymous/ComfyUI_examples/blob/master/area_composition/README.md
|
|
HuggingFile("ckpt/anything-v3.0", "Anything-V3.0.ckpt", show_in_ui=False),
|
|
]
|
|
|
|
KNOWN_UNCLIP_CHECKPOINTS = [
|
|
HuggingFile("stabilityai/stable-cascade", "comfyui_checkpoints/stable_cascade_stage_c.safetensors"),
|
|
HuggingFile("stabilityai/stable-diffusion-2-1-unclip", "sd21-unclip-h.ckpt"),
|
|
HuggingFile("stabilityai/stable-diffusion-2-1-unclip", "sd21-unclip-l.ckpt"),
|
|
]
|
|
|
|
KNOWN_IMAGE_ONLY_CHECKPOINTS = [
|
|
HuggingFile("stabilityai/stable-zero123", "stable_zero123.ckpt")
|
|
]
|
|
|
|
KNOWN_UPSCALERS = [
|
|
HuggingFile("lllyasviel/Annotators", "RealESRGAN_x4plus.pth")
|
|
]
|
|
|
|
KNOWN_GLIGEN_MODELS = [
|
|
HuggingFile("comfyanonymous/GLIGEN_pruned_safetensors", "gligen_sd14_textbox_pruned.safetensors"),
|
|
HuggingFile("comfyanonymous/GLIGEN_pruned_safetensors", "gligen_sd14_textbox_pruned_fp16.safetensors"),
|
|
]
|
|
|
|
KNOWN_CLIP_VISION_MODELS = [
|
|
HuggingFile("comfyanonymous/clip_vision_g", "clip_vision_g.safetensors")
|
|
]
|