mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 01:04:32 +02:00
configurable hf cache
This commit is contained in:
@@ -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**
|
||||
|
||||
@@ -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')
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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':
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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}"')
|
||||
|
||||
+2
-2
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user