mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 09:14:35 +02:00
@@ -27,6 +27,7 @@
|
||||
- improve torch nvidia arch detection
|
||||
- add torch amd arch detection
|
||||
- fix prompt weighted lists and internal wildcards
|
||||
- improve `path_to_repo` handling for custom paths
|
||||
|
||||
## Update for 2026-04-01
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import io
|
||||
import os
|
||||
import copy
|
||||
import json
|
||||
import inspect
|
||||
import os.path
|
||||
from rich import progress # pylint: disable=redefined-builtin
|
||||
import torch
|
||||
import safetensors.torch
|
||||
@@ -12,6 +12,9 @@ from modules.logger import log, console
|
||||
from modules.sd_checkpoint import CheckpointInfo # pylint: disable=unused-import
|
||||
|
||||
|
||||
debug = log.trace if os.environ.get('SD_LOAD_DEBUG', None) is not None else lambda *args, **kwargs: None
|
||||
|
||||
|
||||
class NoWatermark:
|
||||
def apply_watermark(self, img):
|
||||
return img
|
||||
@@ -38,18 +41,32 @@ def path_to_repo(checkpoint_info):
|
||||
repo_id = checkpoint_info.name
|
||||
else:
|
||||
repo_id = checkpoint_info # fallback if fn is used with str param
|
||||
repo_orig = repo_id
|
||||
repo_id = repo_id.replace('\\', '/')
|
||||
if repo_id.startswith('Diffusers/'):
|
||||
repo_id = repo_id.split('Diffusers/')[-1]
|
||||
if repo_id.startswith('huggingface/'):
|
||||
repo_id = repo_id.split('huggingface/')[-1]
|
||||
if repo_id.startswith('models--'):
|
||||
repo_id = repo_id.split('models--')[-1]
|
||||
|
||||
remove_prefix = ['Diffusers', 'huggingface', 'models--']
|
||||
for opt in [shared.opts.ckpt_dir, shared.opts.diffusers_dir, shared.opts.hfcache_dir]:
|
||||
remove_prefix.append(opt.replace('\\', '/'))
|
||||
relative = os.path.relpath(opt, start=shared.opts.models_dir).replace('\\', '/')
|
||||
if not relative.startswith('.'):
|
||||
remove_prefix.append(relative)
|
||||
basename = os.path.basename(opt).replace('\\', '/')
|
||||
if basename:
|
||||
remove_prefix.append(basename)
|
||||
|
||||
debug(f'Path sanitize: prefixes={remove_prefix}')
|
||||
for prefix in remove_prefix:
|
||||
if repo_id.startswith(prefix):
|
||||
repo_id = repo_id.lstrip(prefix)
|
||||
break
|
||||
|
||||
repo_id = repo_id.lstrip('/')
|
||||
repo_id = repo_id.replace('--', '/')
|
||||
if repo_id.count('/') != 1:
|
||||
log.warning(f'Model: repo="{repo_id}" repository not recognized')
|
||||
if '+' in repo_id:
|
||||
repo_id = repo_id.split('+')[0]
|
||||
if repo_id.count('/') > 1:
|
||||
log.warning(f'Model: repo="{repo_id}" repository not recognized')
|
||||
debug(f'Path: from="{repo_orig}" to="{repo_id}"')
|
||||
return repo_id
|
||||
|
||||
|
||||
|
||||
@@ -163,7 +163,9 @@ class GoogleNanoBananaPipeline():
|
||||
|
||||
|
||||
def load_nanobanana(checkpoint_info, diffusers_load_config): # pylint: disable=unused-argument
|
||||
pipe = GoogleNanoBananaPipeline(model_name = checkpoint_info.filename)
|
||||
from modules import sd_models
|
||||
repo_id = sd_models.path_to_repo(checkpoint_info)
|
||||
pipe = GoogleNanoBananaPipeline(model_name = repo_id)
|
||||
return pipe
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user