diff --git a/CHANGELOG.md b/CHANGELOG.md index 0807b2c2c..cbf05ab03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,8 @@ - Better Lora trigger words support - Auto refresh styles on change - **General** + - Configurable location for HF cache folder + Default is standard `~/.cache/huggingface/hub` - Reworked parser when pasting previously generated images/prompts includes all `txt2img`, `img2img` and `override` params - Reworked **model compile** diff --git a/installer.py b/installer.py index 5e7f4bc7c..531d111db 100644 --- a/installer.py +++ b/installer.py @@ -795,6 +795,8 @@ def set_environment(): os.environ.setdefault('TF_ENABLE_ONEDNN_OPTS', '0') os.environ.setdefault('USE_TORCH', '1') os.environ.setdefault('UVICORN_TIMEOUT_KEEP_ALIVE', '60') + os.environ.setdefault('HF_HUB_CACHE', opts.get('hfcache_dir', os.path.join(os.path.expanduser('~'), '.cache', 'huggingface', 'hub'))) + log.debug(f'Cache folder: {os.environ.get("HF_HUB_CACHE")}') if sys.platform == 'darwin': os.environ.setdefault('PYTORCH_ENABLE_MPS_FALLBACK', '1') diff --git a/modules/processing_diffusers.py b/modules/processing_diffusers.py index f491fa58b..a36fed906 100644 --- a/modules/processing_diffusers.py +++ b/modules/processing_diffusers.py @@ -155,7 +155,8 @@ def process_diffusers(p: StableDiffusionProcessing, seeds, prompts, negative_pro decoded = full_vae_decode(latents=latents, model=shared.sd_model) else: decoded = taesd_vae_decode(latents=latents) - # decoded = validate_sample(decoded) # TODO validate sample + # TODO validate decoded sample diffusers + # decoded = validate_sample(decoded) imgs = model.image_processor.postprocess(decoded, output_type=output_type) shared.state.job = prev_job return imgs diff --git a/modules/sd_models_compile.py b/modules/sd_models_compile.py index 353171435..67fc32740 100644 --- a/modules/sd_models_compile.py +++ b/modules/sd_models_compile.py @@ -126,13 +126,13 @@ def compile_torch(sd_model): def compile_diffusers(sd_model): if not (shared.opts.cuda_compile or shared.opts.cuda_compile_vae or shared.opts.cuda_compile_upscaler): - return + return sd_model if not hasattr(sd_model, 'unet') or not hasattr(sd_model.unet, 'config'): shared.log.warning('Model compile enabled but model has no Unet') - return + return sd_model if shared.opts.cuda_compile_backend == 'none': shared.log.warning('Model compile enabled but no backend specified') - return + return sd_model size = 8*getattr(sd_model.unet.config, 'sample_size', 0) shared.log.info(f"Model compile: pipeline={sd_model.__class__.__name__} shape={size} mode={shared.opts.cuda_compile_mode} backend={shared.opts.cuda_compile_backend} fullgraph={shared.opts.cuda_compile_fullgraph} unet={shared.opts.cuda_compile} vae={shared.opts.cuda_compile_vae} upscaler={shared.opts.cuda_compile_upscaler}") if shared.opts.cuda_compile_backend == 'stable-fast': diff --git a/modules/shared.py b/modules/shared.py index 0cb16deb8..259b04e34 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -377,6 +377,7 @@ options_templates.update(options_section(('system-paths', "System Paths"), { "models_dir": OptionInfo('models', "Base path where all models are stored", folder=True), "ckpt_dir": OptionInfo(os.path.join(paths.models_path, 'Stable-diffusion'), "Folder with stable diffusion models", folder=True), "diffusers_dir": OptionInfo(os.path.join(paths.models_path, 'Diffusers'), "Folder with Hugggingface models", folder=True), + "hfcache_dir": OptionInfo(os.path.join(os.path.expanduser('~'), '.cache', 'huggingface', 'hub'), "Folder for Hugggingface cache", folder=True), "vae_dir": OptionInfo(os.path.join(paths.models_path, 'VAE'), "Folder with VAE files", folder=True), "sd_lora": OptionInfo("", "Add LoRA to prompt", gr.Textbox, {"visible": False}), "lora_dir": OptionInfo(os.path.join(paths.models_path, 'Lora'), "Folder with LoRA network(s)", folder=True), diff --git a/modules/ui_extra_networks.py b/modules/ui_extra_networks.py index 3cd5cdecd..3a61f90f4 100644 --- a/modules/ui_extra_networks.py +++ b/modules/ui_extra_networks.py @@ -203,7 +203,7 @@ class ExtraNetworksPage: os.remove(f) elif img.width > 1024 or img.height > 1024 or os.path.getsize(f) > 65536: img = img.convert('RGB') - img.thumbnail((512, 512), Image.HAMMING) + img.thumbnail((512, 512), Image.Resampling.HAMMING) img.save(fn, quality=50) img.close() created += 1 @@ -576,7 +576,7 @@ def create_ui(container, button_parent, tabname, skip_indexing = False): fn_delete_img(image) if image.width > 512 or image.height > 512: image = image.convert('RGB') - image.thumbnail((512, 512), Image.HAMMING) + image.thumbnail((512, 512), Image.Resampling.HAMMING) try: image.save(ui.last_item.local_preview, quality=50) shared.log.debug(f'Extra network save image: item={ui.last_item.name} filename="{ui.last_item.local_preview}"') diff --git a/modules/upscaler.py b/modules/upscaler.py index fa23ddaa9..575dfdc12 100644 --- a/modules/upscaler.py +++ b/modules/upscaler.py @@ -7,8 +7,8 @@ import modules.shared from modules import modelloader -LANCZOS = (Image.Resampling.LANCZOS if hasattr(Image, 'Resampling') else Image.LANCZOS) -NEAREST = (Image.Resampling.NEAREST if hasattr(Image, 'Resampling') else Image.NEAREST) +LANCZOS = (Image.Resampling.LANCZOS if hasattr(Image, 'Resampling') else Image.Resampling.LANCZOS) +NEAREST = (Image.Resampling.NEAREST if hasattr(Image, 'Resampling') else Image.Resampling.NEAREST) models = None class Upscaler: