auto-diffusers 2.0.25.dev0__py3-none-any.whl → 2.0.32__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- auto_diffusers/__init__.py +1 -1
- auto_diffusers/pipeline_easy.py +212 -83
- {auto_diffusers-2.0.25.dev0.dist-info → auto_diffusers-2.0.32.dist-info}/METADATA +14 -5
- auto_diffusers-2.0.32.dist-info/RECORD +8 -0
- auto_diffusers-2.0.25.dev0.dist-info/RECORD +0 -8
- {auto_diffusers-2.0.25.dev0.dist-info → auto_diffusers-2.0.32.dist-info}/LICENSE +0 -0
- {auto_diffusers-2.0.25.dev0.dist-info → auto_diffusers-2.0.32.dist-info}/WHEEL +0 -0
- {auto_diffusers-2.0.25.dev0.dist-info → auto_diffusers-2.0.32.dist-info}/top_level.txt +0 -0
auto_diffusers/__init__.py
CHANGED
auto_diffusers/pipeline_easy.py
CHANGED
|
@@ -16,53 +16,60 @@
|
|
|
16
16
|
import os
|
|
17
17
|
import re
|
|
18
18
|
import types
|
|
19
|
-
from collections import OrderedDict
|
|
20
19
|
from dataclasses import asdict, dataclass, field
|
|
21
20
|
from typing import Dict, List, Optional, Union
|
|
21
|
+
from collections import OrderedDict
|
|
22
|
+
|
|
22
23
|
|
|
23
24
|
import requests
|
|
24
25
|
import torch
|
|
26
|
+
|
|
25
27
|
from diffusers.loaders.single_file_utils import (
|
|
26
28
|
VALID_URL_PREFIXES,
|
|
27
29
|
_extract_repo_id_and_weights_name,
|
|
28
30
|
infer_diffusers_model_type,
|
|
29
31
|
load_single_file_checkpoint,
|
|
30
32
|
)
|
|
31
|
-
|
|
33
|
+
|
|
34
|
+
from diffusers import (
|
|
35
|
+
StableDiffusionPipeline,
|
|
36
|
+
StableDiffusionImg2ImgPipeline,
|
|
37
|
+
StableDiffusionInpaintPipeline,
|
|
38
|
+
)
|
|
32
39
|
from diffusers.pipelines.auto_pipeline import (
|
|
33
40
|
AutoPipelineForImage2Image,
|
|
34
41
|
AutoPipelineForInpainting,
|
|
35
42
|
AutoPipelineForText2Image,
|
|
43
|
+
AUTO_TEXT2IMAGE_PIPELINES_MAPPING,
|
|
44
|
+
AUTO_IMAGE2IMAGE_PIPELINES_MAPPING,
|
|
45
|
+
AUTO_INPAINT_PIPELINES_MAPPING,
|
|
36
46
|
)
|
|
37
|
-
from diffusers.pipelines.
|
|
47
|
+
from diffusers.pipelines.pipeline_utils import DiffusionPipeline
|
|
48
|
+
from diffusers.utils import logging
|
|
49
|
+
|
|
50
|
+
from diffusers import (
|
|
51
|
+
AnimateDiffPipeline,
|
|
52
|
+
AnimateDiffSDXLPipeline,
|
|
53
|
+
StableDiffusionControlNetPipeline,
|
|
38
54
|
StableDiffusionControlNetImg2ImgPipeline,
|
|
39
55
|
StableDiffusionControlNetInpaintPipeline,
|
|
40
|
-
StableDiffusionControlNetPipeline,
|
|
41
|
-
StableDiffusionXLControlNetImg2ImgPipeline,
|
|
42
|
-
StableDiffusionXLControlNetPipeline,
|
|
43
|
-
)
|
|
44
|
-
from diffusers.pipelines.flux import FluxImg2ImgPipeline, FluxPipeline
|
|
45
|
-
from diffusers.pipelines.pipeline_utils import DiffusionPipeline
|
|
46
|
-
from diffusers.pipelines.stable_diffusion import (
|
|
47
|
-
StableDiffusionImg2ImgPipeline,
|
|
48
|
-
StableDiffusionInpaintPipeline,
|
|
49
|
-
StableDiffusionPipeline,
|
|
50
|
-
StableDiffusionUpscalePipeline,
|
|
51
|
-
)
|
|
52
|
-
from diffusers.pipelines.stable_diffusion_3 import (
|
|
53
|
-
StableDiffusion3Img2ImgPipeline,
|
|
54
|
-
StableDiffusion3Pipeline,
|
|
55
|
-
)
|
|
56
|
-
from diffusers.pipelines.stable_diffusion_xl import (
|
|
57
56
|
StableDiffusionXLImg2ImgPipeline,
|
|
58
|
-
StableDiffusionXLInpaintPipeline,
|
|
59
57
|
StableDiffusionXLPipeline,
|
|
58
|
+
StableDiffusionXLInpaintPipeline,
|
|
59
|
+
StableDiffusionUpscalePipeline,
|
|
60
|
+
StableDiffusion3Pipeline,
|
|
61
|
+
StableDiffusion3Img2ImgPipeline,
|
|
62
|
+
FluxPipeline,
|
|
63
|
+
FluxImg2ImgPipeline,
|
|
64
|
+
StableDiffusionXLControlNetPipeline,
|
|
65
|
+
StableDiffusionXLControlNetImg2ImgPipeline,
|
|
60
66
|
)
|
|
61
|
-
|
|
67
|
+
|
|
62
68
|
from huggingface_hub import hf_api, hf_hub_download
|
|
63
69
|
from huggingface_hub.file_download import http_get
|
|
64
70
|
from huggingface_hub.utils import validate_hf_hub_args
|
|
65
71
|
|
|
72
|
+
|
|
66
73
|
logger = logging.get_logger(__name__)
|
|
67
74
|
|
|
68
75
|
|
|
@@ -107,9 +114,14 @@ SINGLE_FILE_CHECKPOINT_TEXT2IMAGE_PIPELINE_MAPPING = OrderedDict(
|
|
|
107
114
|
("xl_base", StableDiffusionXLPipeline),
|
|
108
115
|
("xl_inpaint", None),
|
|
109
116
|
("xl_refiner", StableDiffusionXLPipeline),
|
|
110
|
-
]
|
|
117
|
+
],
|
|
111
118
|
)
|
|
112
119
|
|
|
120
|
+
# For single-file checkpoints we expose separate mappings for each task so callers
|
|
121
|
+
# can pick the most appropriate pipeline class set. The full, explicit mappings
|
|
122
|
+
# for image2image and inpaint are defined below; keep distinct names so they can
|
|
123
|
+
# be customized independently.
|
|
124
|
+
|
|
113
125
|
SINGLE_FILE_CHECKPOINT_IMAGE2IMAGE_PIPELINE_MAPPING = OrderedDict(
|
|
114
126
|
[
|
|
115
127
|
("animatediff_rgb", AnimateDiffPipeline),
|
|
@@ -198,7 +210,6 @@ SINGLE_FILE_CHECKPOINT_INPAINT_PIPELINE_MAPPING = OrderedDict(
|
|
|
198
210
|
]
|
|
199
211
|
)
|
|
200
212
|
|
|
201
|
-
|
|
202
213
|
CONFIG_FILE_LIST = [
|
|
203
214
|
"pytorch_model.bin",
|
|
204
215
|
"pytorch_model.fp16.bin",
|
|
@@ -213,11 +224,23 @@ CONFIG_FILE_LIST = [
|
|
|
213
224
|
]
|
|
214
225
|
|
|
215
226
|
DIFFUSERS_CONFIG_DIR = [
|
|
227
|
+
# common pipeline component folders
|
|
216
228
|
"safety_checker",
|
|
217
229
|
"unet",
|
|
218
230
|
"vae",
|
|
231
|
+
"vae_1_0",
|
|
232
|
+
"vae_decoder",
|
|
233
|
+
"vae_encoder",
|
|
219
234
|
"text_encoder",
|
|
220
235
|
"text_encoder_2",
|
|
236
|
+
"tokenizer",
|
|
237
|
+
"tokenizer_2",
|
|
238
|
+
"scheduler",
|
|
239
|
+
"transformer",
|
|
240
|
+
# legacy / other possible component folders
|
|
241
|
+
"controlnet",
|
|
242
|
+
"clip",
|
|
243
|
+
"encoder",
|
|
221
244
|
]
|
|
222
245
|
|
|
223
246
|
TOKENIZER_SHAPE_MAP = {
|
|
@@ -244,6 +267,12 @@ EXTENSION = [".safetensors", ".ckpt", ".bin"]
|
|
|
244
267
|
CACHE_HOME = os.path.expanduser("~/.cache")
|
|
245
268
|
|
|
246
269
|
|
|
270
|
+
# Set up pipeline mappings
|
|
271
|
+
AUTO_TEXT2IMAGE_PIPELINES_MAPPING["v1"] = StableDiffusionPipeline
|
|
272
|
+
AUTO_IMAGE2IMAGE_PIPELINES_MAPPING["v1"] = StableDiffusionImg2ImgPipeline
|
|
273
|
+
AUTO_INPAINT_PIPELINES_MAPPING["v1"] = StableDiffusionInpaintPipeline
|
|
274
|
+
|
|
275
|
+
|
|
247
276
|
@dataclass
|
|
248
277
|
class RepoStatus:
|
|
249
278
|
r"""
|
|
@@ -394,13 +423,12 @@ def load_pipeline_from_single_file(
|
|
|
394
423
|
if pipeline_class is None:
|
|
395
424
|
raise ValueError(
|
|
396
425
|
f"{model_type} is not supported in this pipeline."
|
|
397
|
-
"For `Text2Image`, please use `
|
|
398
|
-
"for `Image2Image` , please use `
|
|
399
|
-
"and `inpaint` is only supported in `
|
|
426
|
+
"For `Text2Image`, please use `EasyPipelineForText2Image.from_pretrained`, "
|
|
427
|
+
"for `Image2Image` , please use `EasyPipelineForImage2Image.from_pretrained`, "
|
|
428
|
+
"and `inpaint` is only supported in `EasyPipelineForInpainting.from_pretrained`"
|
|
400
429
|
)
|
|
401
430
|
|
|
402
431
|
else:
|
|
403
|
-
# Instantiate and return the pipeline with the loaded checkpoint and any additional kwargs
|
|
404
432
|
return pipeline_class.from_single_file(pretrained_model_or_path, **kwargs)
|
|
405
433
|
|
|
406
434
|
|
|
@@ -529,19 +557,40 @@ def file_downloader(
|
|
|
529
557
|
|
|
530
558
|
# Check if the file already exists at the save path
|
|
531
559
|
if os.path.exists(save_path):
|
|
560
|
+
existing_size = os.path.getsize(save_path)
|
|
561
|
+
# If file exists and not forcing download
|
|
532
562
|
if not force_download:
|
|
533
|
-
# If the file
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
# If
|
|
563
|
+
# If the file is non-empty, assume it's already downloaded
|
|
564
|
+
if existing_size > 0:
|
|
565
|
+
logger.info(f"File already exists and is non-empty: {save_path}, skipping download.")
|
|
566
|
+
return None
|
|
567
|
+
# If the file is zero bytes, remove it and proceed to download
|
|
568
|
+
logger.info(f"Found zero-byte file, removing and retrying download: {save_path}")
|
|
569
|
+
try:
|
|
570
|
+
os.remove(save_path)
|
|
571
|
+
except OSError:
|
|
572
|
+
# If removal fails, try to proceed by truncating the file
|
|
573
|
+
with open(save_path, "wb"):
|
|
574
|
+
pass
|
|
575
|
+
# If resuming is requested and file exists, append
|
|
576
|
+
if resume and os.path.exists(save_path):
|
|
538
577
|
mode = "ab"
|
|
539
578
|
file_size = os.path.getsize(save_path)
|
|
540
579
|
|
|
580
|
+
# Check if the URL is accessible before downloading. If HEAD returns 401,
|
|
581
|
+
# raise an HTTPError so callers can try the next candidate. Other HEAD
|
|
582
|
+
# failures are logged and the download is still attempted.
|
|
583
|
+
try:
|
|
584
|
+
response = requests.head(url, headers=headers, allow_redirects=True, timeout=2)
|
|
585
|
+
if response.status_code == 401:
|
|
586
|
+
raise requests.HTTPError(f"401 Unauthorized: {url}")
|
|
587
|
+
except requests.exceptions.RequestException as e:
|
|
588
|
+
logger.info(f"HEAD check failed (continuing to download): {url} -> {e}")
|
|
589
|
+
|
|
541
590
|
# Open the file in the appropriate mode (write or append)
|
|
542
591
|
with open(save_path, mode) as model_file:
|
|
543
592
|
# Call the http_get function to perform the file download
|
|
544
|
-
|
|
593
|
+
result = http_get(
|
|
545
594
|
url=url,
|
|
546
595
|
temp_file=model_file,
|
|
547
596
|
resume_size=file_size,
|
|
@@ -549,6 +598,8 @@ def file_downloader(
|
|
|
549
598
|
headers=headers,
|
|
550
599
|
proxies=proxies,
|
|
551
600
|
)
|
|
601
|
+
logger.info(f"Successfully downloaded: {url} -> {save_path}")
|
|
602
|
+
return result
|
|
552
603
|
|
|
553
604
|
|
|
554
605
|
def search_huggingface(search_word: str, **kwargs) -> Union[str, SearchResult, None]:
|
|
@@ -582,6 +633,12 @@ def search_huggingface(search_word: str, **kwargs) -> Union[str, SearchResult, N
|
|
|
582
633
|
"""
|
|
583
634
|
# Extract additional parameters from kwargs
|
|
584
635
|
revision = kwargs.pop("revision", None)
|
|
636
|
+
model_type = kwargs.pop("model_type", "checkpoint")
|
|
637
|
+
# normalize model_type for simple comparisons
|
|
638
|
+
try:
|
|
639
|
+
model_type = str(model_type).lower()
|
|
640
|
+
except Exception:
|
|
641
|
+
model_type = ""
|
|
585
642
|
checkpoint_format = kwargs.pop("checkpoint_format", "single_file")
|
|
586
643
|
download = kwargs.pop("download", False)
|
|
587
644
|
force_download = kwargs.pop("force_download", False)
|
|
@@ -603,7 +660,9 @@ def search_huggingface(search_word: str, **kwargs) -> Union[str, SearchResult, N
|
|
|
603
660
|
search_word_status = get_keyword_types(search_word)
|
|
604
661
|
|
|
605
662
|
if search_word_status["type"]["hf_repo"]:
|
|
606
|
-
hf_repo_info =
|
|
663
|
+
hf_repo_info = asdict(
|
|
664
|
+
hf_api.model_info(repo_id=search_word, securityStatus=True)
|
|
665
|
+
)
|
|
607
666
|
if download:
|
|
608
667
|
model_path = DiffusionPipeline.download(
|
|
609
668
|
search_word,
|
|
@@ -654,9 +713,11 @@ def search_huggingface(search_word: str, **kwargs) -> Union[str, SearchResult, N
|
|
|
654
713
|
for repo_info in model_dicts:
|
|
655
714
|
repo_id = repo_info["id"]
|
|
656
715
|
file_list = []
|
|
657
|
-
hf_repo_info =
|
|
716
|
+
hf_repo_info = asdict(
|
|
717
|
+
hf_api.model_info(repo_id=repo_id, securityStatus=True)
|
|
718
|
+
)
|
|
658
719
|
# Lists files with security issues.
|
|
659
|
-
hf_security_info = hf_repo_info
|
|
720
|
+
hf_security_info = hf_repo_info["security_repo_status"]
|
|
660
721
|
exclusion = [issue["path"] for issue in hf_security_info["filesWithIssues"]]
|
|
661
722
|
|
|
662
723
|
# Checks for multi-folder diffusers model or valid files (models with security issues are excluded).
|
|
@@ -674,8 +735,12 @@ def search_huggingface(search_word: str, **kwargs) -> Union[str, SearchResult, N
|
|
|
674
735
|
any(file_path.endswith(ext) for ext in EXTENSION)
|
|
675
736
|
and not any(config in file_path for config in CONFIG_FILE_LIST)
|
|
676
737
|
and not any(exc in file_path for exc in exclusion)
|
|
677
|
-
and os.path.basename(os.path.dirname(file_path))
|
|
678
|
-
|
|
738
|
+
and os.path.basename(os.path.dirname(file_path)) not in DIFFUSERS_CONFIG_DIR
|
|
739
|
+
# If caller requested checkpoint-only, exclude filenames that look like LoRA/Textual-Inversion
|
|
740
|
+
and not (
|
|
741
|
+
model_type == "checkpoint"
|
|
742
|
+
and any(kw in file_path.lower() for kw in ["lora", "textual", "inversion"])
|
|
743
|
+
)
|
|
679
744
|
):
|
|
680
745
|
file_list.append(file_path)
|
|
681
746
|
|
|
@@ -740,7 +805,7 @@ def search_huggingface(search_word: str, **kwargs) -> Union[str, SearchResult, N
|
|
|
740
805
|
loading_method=output_info["loading_method"],
|
|
741
806
|
checkpoint_format=output_info["checkpoint_format"],
|
|
742
807
|
repo_status=RepoStatus(
|
|
743
|
-
repo_id=repo_id, repo_hash=hf_repo_info
|
|
808
|
+
repo_id=repo_id, repo_hash=hf_repo_info["sha"], version=revision
|
|
744
809
|
),
|
|
745
810
|
model_status=ModelStatus(
|
|
746
811
|
search_word=search_word,
|
|
@@ -816,7 +881,7 @@ def search_civitai(search_word: str, **kwargs) -> Union[str, SearchResult, None]
|
|
|
816
881
|
params = {
|
|
817
882
|
"query": search_word,
|
|
818
883
|
"types": model_type,
|
|
819
|
-
"limit":
|
|
884
|
+
"limit": 100,
|
|
820
885
|
}
|
|
821
886
|
if base_model is not None:
|
|
822
887
|
if not isinstance(base_model, list):
|
|
@@ -837,7 +902,10 @@ def search_civitai(search_word: str, **kwargs) -> Union[str, SearchResult, None]
|
|
|
837
902
|
)
|
|
838
903
|
response.raise_for_status()
|
|
839
904
|
except requests.exceptions.HTTPError as err:
|
|
840
|
-
|
|
905
|
+
if skip_error:
|
|
906
|
+
return None
|
|
907
|
+
else:
|
|
908
|
+
raise requests.HTTPError(f"Could not get elements from the URL: {err}")
|
|
841
909
|
else:
|
|
842
910
|
try:
|
|
843
911
|
data = response.json()
|
|
@@ -848,9 +916,12 @@ def search_civitai(search_word: str, **kwargs) -> Union[str, SearchResult, None]
|
|
|
848
916
|
raise ValueError("Invalid JSON response")
|
|
849
917
|
|
|
850
918
|
# Sort repositories by download count in descending order
|
|
851
|
-
sorted_repos = sorted(
|
|
852
|
-
|
|
853
|
-
)
|
|
919
|
+
# sorted_repos = sorted(
|
|
920
|
+
# data["items"], key=lambda x: x["stats"]["downloadCount"], reverse=True
|
|
921
|
+
# )
|
|
922
|
+
|
|
923
|
+
# Since the Civitai API is broken, I will temporarily sort by name.
|
|
924
|
+
sorted_repos = sorted(data["items"], key=lambda x: x["name"], reverse=True)
|
|
854
925
|
|
|
855
926
|
for selected_repo in sorted_repos:
|
|
856
927
|
repo_name = selected_repo["name"]
|
|
@@ -889,7 +960,8 @@ def search_civitai(search_word: str, **kwargs) -> Union[str, SearchResult, None]
|
|
|
889
960
|
sorted_models = sorted(
|
|
890
961
|
models_list, key=lambda x: x["filename"], reverse=True
|
|
891
962
|
)
|
|
892
|
-
|
|
963
|
+
# Prefer safe/sfw models
|
|
964
|
+
candidate_model = next(
|
|
893
965
|
(
|
|
894
966
|
model_data
|
|
895
967
|
for model_data in sorted_models
|
|
@@ -899,11 +971,27 @@ def search_civitai(search_word: str, **kwargs) -> Union[str, SearchResult, None]
|
|
|
899
971
|
),
|
|
900
972
|
sorted_models[0],
|
|
901
973
|
)
|
|
974
|
+
|
|
975
|
+
# Validate download URL accessibility (check first file only)
|
|
976
|
+
try:
|
|
977
|
+
# Since models requiring authentication do not return results, there is no need to determine their status via status codes.
|
|
978
|
+
_resp = requests.head(
|
|
979
|
+
candidate_model["download_url"],
|
|
980
|
+
headers=headers,
|
|
981
|
+
timeout=2,
|
|
982
|
+
allow_redirects=True
|
|
983
|
+
)
|
|
984
|
+
selected_model = candidate_model
|
|
985
|
+
logger.info(f"Validated download URL: {candidate_model['download_url']}")
|
|
986
|
+
break # Exit the version loop if a valid model is found
|
|
987
|
+
except requests.exceptions.RequestException as e:
|
|
988
|
+
logger.info(f"Failed to validate URL {candidate_model['download_url']}: {e}, trying next version...")
|
|
989
|
+
continue
|
|
990
|
+
|
|
991
|
+
# If we found a valid model in this repo, exit outer repo loop
|
|
992
|
+
if selected_model:
|
|
993
|
+
break
|
|
902
994
|
|
|
903
|
-
break
|
|
904
|
-
else:
|
|
905
|
-
continue
|
|
906
|
-
break
|
|
907
995
|
|
|
908
996
|
# Exception handling when search candidates are not found
|
|
909
997
|
if not selected_model:
|
|
@@ -920,20 +1008,45 @@ def search_civitai(search_word: str, **kwargs) -> Union[str, SearchResult, None]
|
|
|
920
1008
|
|
|
921
1009
|
# Handle file download and setting model information
|
|
922
1010
|
if download:
|
|
923
|
-
#
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
file_downloader(
|
|
929
|
-
url=download_url,
|
|
930
|
-
save_path=model_path,
|
|
931
|
-
resume=resume,
|
|
932
|
-
force_download=force_download,
|
|
933
|
-
displayed_filename=file_name,
|
|
934
|
-
headers=headers,
|
|
935
|
-
**kwargs,
|
|
1011
|
+
# Try downloading from the models list, retrying on 401 errors
|
|
1012
|
+
download_success = False
|
|
1013
|
+
# Create a sorted list of all available models to try
|
|
1014
|
+
sorted_models = sorted(
|
|
1015
|
+
models_list, key=lambda x: x["filename"], reverse=True
|
|
936
1016
|
)
|
|
1017
|
+
|
|
1018
|
+
for model_candidate in sorted_models:
|
|
1019
|
+
try:
|
|
1020
|
+
file_name = model_candidate["filename"]
|
|
1021
|
+
download_url = model_candidate["download_url"]
|
|
1022
|
+
|
|
1023
|
+
# The path where the model is to be saved.
|
|
1024
|
+
model_path = os.path.join(
|
|
1025
|
+
str(civitai_cache_dir), str(repo_id), str(version_id), str(file_name)
|
|
1026
|
+
)
|
|
1027
|
+
|
|
1028
|
+
# Download Model File
|
|
1029
|
+
file_downloader(
|
|
1030
|
+
url=download_url,
|
|
1031
|
+
save_path=model_path,
|
|
1032
|
+
resume=resume,
|
|
1033
|
+
force_download=force_download,
|
|
1034
|
+
displayed_filename=file_name,
|
|
1035
|
+
headers=headers,
|
|
1036
|
+
**kwargs,
|
|
1037
|
+
)
|
|
1038
|
+
download_success = True
|
|
1039
|
+
logger.info(f"Successfully downloaded model from: {download_url}")
|
|
1040
|
+
break
|
|
1041
|
+
except requests.HTTPError as e:
|
|
1042
|
+
if "401" in str(e):
|
|
1043
|
+
logger.info(f"401 error for {download_url}, trying next candidate...")
|
|
1044
|
+
continue
|
|
1045
|
+
else:
|
|
1046
|
+
raise
|
|
1047
|
+
|
|
1048
|
+
if not download_success:
|
|
1049
|
+
raise ValueError(f"Failed to download any model file from {repo_name}. All URLs returned 401 errors.")
|
|
937
1050
|
|
|
938
1051
|
else:
|
|
939
1052
|
model_path = download_url
|
|
@@ -1113,12 +1226,12 @@ class AutoConfig:
|
|
|
1113
1226
|
# Search for the model on Civitai and get the model status
|
|
1114
1227
|
textual_inversion_path = search_civitai(search_word, **kwargs)
|
|
1115
1228
|
logger.warning(
|
|
1116
|
-
f"textual_inversion_path: {search_word} -> {textual_inversion_path.model_status.site_url}"
|
|
1229
|
+
f"textual_inversion_path: {search_word} -> {textual_inversion_path.model_status.site_url}" # type: ignore
|
|
1117
1230
|
)
|
|
1118
1231
|
|
|
1119
1232
|
pretrained_model_name_or_paths[
|
|
1120
1233
|
pretrained_model_name_or_paths.index(search_word)
|
|
1121
|
-
] = textual_inversion_path.model_path
|
|
1234
|
+
] = textual_inversion_path.model_path # type: ignore
|
|
1122
1235
|
|
|
1123
1236
|
self.load_textual_inversion(
|
|
1124
1237
|
pretrained_model_name_or_paths,
|
|
@@ -1132,6 +1245,7 @@ class AutoConfig:
|
|
|
1132
1245
|
self,
|
|
1133
1246
|
pretrained_model_name_or_path_or_dict: Union[str, Dict[str, torch.Tensor]],
|
|
1134
1247
|
adapter_name=None,
|
|
1248
|
+
base_model: Optional[Union[str, List[str]]] = None,
|
|
1135
1249
|
**kwargs,
|
|
1136
1250
|
):
|
|
1137
1251
|
r"""
|
|
@@ -1155,6 +1269,9 @@ class AutoConfig:
|
|
|
1155
1269
|
adapter_name (`str`, *optional*):
|
|
1156
1270
|
Adapter name to be used for referencing the loaded adapter model. If not specified, it will use
|
|
1157
1271
|
`default_{i}` where i is the total number of adapters being loaded.
|
|
1272
|
+
base_model (`str` or `List[str]`, *optional*):
|
|
1273
|
+
Base model tag(s) to filter LoRA models (e.g., "SD 1.5", "SDXL 1.0"). Used when searching Civitai
|
|
1274
|
+
to ensure LoRA compatibility with the current pipeline's base model.
|
|
1158
1275
|
low_cpu_mem_usage (`bool`, *optional*):
|
|
1159
1276
|
Speed up model loading by only loading the pretrained LoRA weights and not initializing the random
|
|
1160
1277
|
weights.
|
|
@@ -1169,12 +1286,24 @@ class AutoConfig:
|
|
|
1169
1286
|
"skip_error": False,
|
|
1170
1287
|
"model_type": "LORA",
|
|
1171
1288
|
}
|
|
1289
|
+
if base_model is not None:
|
|
1290
|
+
_status["base_model"] = base_model if isinstance(base_model, list) else [base_model]
|
|
1172
1291
|
kwargs.update(_status)
|
|
1173
1292
|
# Search for the model on Civitai and get the model status
|
|
1174
1293
|
lora_path = search_civitai(pretrained_model_name_or_path_or_dict, **kwargs)
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1294
|
+
# search_civitai may return a SearchResult, a string (download url or path) or None.
|
|
1295
|
+
if isinstance(lora_path, SearchResult):
|
|
1296
|
+
logger.warning(f"lora_path: {lora_path.model_status.site_url}")
|
|
1297
|
+
logger.warning(f"trained_words: {lora_path.extra_status.trained_words}")
|
|
1298
|
+
pretrained_model_name_or_path_or_dict = lora_path.model_path
|
|
1299
|
+
elif lora_path is None:
|
|
1300
|
+
raise ValueError(
|
|
1301
|
+
f"No LORA model found for {pretrained_model_name_or_path_or_dict}"
|
|
1302
|
+
)
|
|
1303
|
+
else:
|
|
1304
|
+
# fallback when search_civitai returns a plain path/URL string
|
|
1305
|
+
logger.warning(f"lora_path: {lora_path}")
|
|
1306
|
+
pretrained_model_name_or_path_or_dict = lora_path
|
|
1178
1307
|
|
|
1179
1308
|
self.load_lora_weights(
|
|
1180
1309
|
pretrained_model_name_or_path_or_dict, adapter_name=adapter_name, **kwargs
|
|
@@ -1320,12 +1449,12 @@ class EasyPipelineForText2Image(AutoPipelineForText2Image):
|
|
|
1320
1449
|
pretrained_model_link_or_path, **kwargs
|
|
1321
1450
|
)
|
|
1322
1451
|
logger.warning(
|
|
1323
|
-
f"checkpoint_path: {hf_checkpoint_status.model_status.download_url}"
|
|
1452
|
+
f"checkpoint_path: {hf_checkpoint_status.model_status.download_url}" # type: ignore
|
|
1324
1453
|
)
|
|
1325
|
-
checkpoint_path = hf_checkpoint_status.model_path
|
|
1454
|
+
checkpoint_path = hf_checkpoint_status.model_path # type: ignore
|
|
1326
1455
|
|
|
1327
1456
|
# Check the format of the model checkpoint
|
|
1328
|
-
if hf_checkpoint_status.loading_method == "from_single_file":
|
|
1457
|
+
if hf_checkpoint_status.loading_method == "from_single_file": # type: ignore
|
|
1329
1458
|
# Load the pipeline from a single file checkpoint
|
|
1330
1459
|
pipeline = load_pipeline_from_single_file(
|
|
1331
1460
|
pretrained_model_or_path=checkpoint_path,
|
|
@@ -1430,8 +1559,8 @@ class EasyPipelineForText2Image(AutoPipelineForText2Image):
|
|
|
1430
1559
|
|
|
1431
1560
|
# Search for the model on Civitai and get the model status
|
|
1432
1561
|
checkpoint_status = search_civitai(pretrained_model_link_or_path, **kwargs)
|
|
1433
|
-
logger.warning(f"checkpoint_path: {checkpoint_status.model_status.site_url}")
|
|
1434
|
-
checkpoint_path = checkpoint_status.model_path
|
|
1562
|
+
logger.warning(f"checkpoint_path: {checkpoint_status.model_status.site_url}") # type: ignore
|
|
1563
|
+
checkpoint_path = checkpoint_status.model_path # type: ignore
|
|
1435
1564
|
|
|
1436
1565
|
# Load the pipeline from a single file checkpoint
|
|
1437
1566
|
pipeline = load_pipeline_from_single_file(
|
|
@@ -1582,12 +1711,12 @@ class EasyPipelineForImage2Image(AutoPipelineForImage2Image):
|
|
|
1582
1711
|
pretrained_model_link_or_path, **kwargs
|
|
1583
1712
|
)
|
|
1584
1713
|
logger.warning(
|
|
1585
|
-
f"checkpoint_path: {hf_checkpoint_status.model_status.download_url}"
|
|
1714
|
+
f"checkpoint_path: {hf_checkpoint_status.model_status.download_url}" # type: ignore
|
|
1586
1715
|
)
|
|
1587
|
-
checkpoint_path = hf_checkpoint_status.model_path
|
|
1716
|
+
checkpoint_path = hf_checkpoint_status.model_path # type: ignore
|
|
1588
1717
|
|
|
1589
1718
|
# Check the format of the model checkpoint
|
|
1590
|
-
if hf_checkpoint_status.loading_method == "from_single_file":
|
|
1719
|
+
if hf_checkpoint_status.loading_method == "from_single_file": # type: ignore
|
|
1591
1720
|
# Load the pipeline from a single file checkpoint
|
|
1592
1721
|
pipeline = load_pipeline_from_single_file(
|
|
1593
1722
|
pretrained_model_or_path=checkpoint_path,
|
|
@@ -1693,8 +1822,8 @@ class EasyPipelineForImage2Image(AutoPipelineForImage2Image):
|
|
|
1693
1822
|
|
|
1694
1823
|
# Search for the model on Civitai and get the model status
|
|
1695
1824
|
checkpoint_status = search_civitai(pretrained_model_link_or_path, **kwargs)
|
|
1696
|
-
logger.warning(f"checkpoint_path: {checkpoint_status.model_status.site_url}")
|
|
1697
|
-
checkpoint_path = checkpoint_status.model_path
|
|
1825
|
+
logger.warning(f"checkpoint_path: {checkpoint_status.model_status.site_url}") # type: ignore
|
|
1826
|
+
checkpoint_path = checkpoint_status.model_path # type: ignore
|
|
1698
1827
|
|
|
1699
1828
|
# Load the pipeline from a single file checkpoint
|
|
1700
1829
|
pipeline = load_pipeline_from_single_file(
|
|
@@ -1845,12 +1974,12 @@ class EasyPipelineForInpainting(AutoPipelineForInpainting):
|
|
|
1845
1974
|
pretrained_model_link_or_path, **kwargs
|
|
1846
1975
|
)
|
|
1847
1976
|
logger.warning(
|
|
1848
|
-
f"checkpoint_path: {hf_checkpoint_status.model_status.download_url}"
|
|
1977
|
+
f"checkpoint_path: {hf_checkpoint_status.model_status.download_url}" # type: ignore
|
|
1849
1978
|
)
|
|
1850
|
-
checkpoint_path = hf_checkpoint_status.model_path
|
|
1979
|
+
checkpoint_path = hf_checkpoint_status.model_path # type: ignore
|
|
1851
1980
|
|
|
1852
1981
|
# Check the format of the model checkpoint
|
|
1853
|
-
if hf_checkpoint_status.loading_method == "from_single_file":
|
|
1982
|
+
if hf_checkpoint_status.loading_method == "from_single_file": # type: ignore
|
|
1854
1983
|
# Load the pipeline from a single file checkpoint
|
|
1855
1984
|
pipeline = load_pipeline_from_single_file(
|
|
1856
1985
|
pretrained_model_or_path=checkpoint_path,
|
|
@@ -1955,8 +2084,8 @@ class EasyPipelineForInpainting(AutoPipelineForInpainting):
|
|
|
1955
2084
|
|
|
1956
2085
|
# Search for the model on Civitai and get the model status
|
|
1957
2086
|
checkpoint_status = search_civitai(pretrained_model_link_or_path, **kwargs)
|
|
1958
|
-
logger.warning(f"checkpoint_path: {checkpoint_status.model_status.site_url}")
|
|
1959
|
-
checkpoint_path = checkpoint_status.model_path
|
|
2087
|
+
logger.warning(f"checkpoint_path: {checkpoint_status.model_status.site_url}") # type: ignore
|
|
2088
|
+
checkpoint_path = checkpoint_status.model_path # type: ignore
|
|
1960
2089
|
|
|
1961
2090
|
# Load the pipeline from a single file checkpoint
|
|
1962
2091
|
pipeline = load_pipeline_from_single_file(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: auto_diffusers
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.32
|
|
4
4
|
Summary: diffusers with search engine
|
|
5
5
|
Home-page: https://github.com/suzukimain/auto_diffusers
|
|
6
6
|
Author: suzukimain
|
|
@@ -23,8 +23,7 @@ License-File: LICENSE
|
|
|
23
23
|
Requires-Dist: diffusers >=0.32.0
|
|
24
24
|
Requires-Dist: transformers >=4.41.2
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+

|
|
28
27
|
|
|
29
28
|
<p>
|
|
30
29
|
<a href="https://github.com/suzukimain/auto_diffusers/blob/main/LICENSE"><img alt="GitHub release" src="https://img.shields.io/badge/license-Apache%202.0-blue.svg?style=social"></a>
|
|
@@ -45,10 +44,20 @@ Requires-Dist: transformers >=4.41.2
|
|
|
45
44
|
+ [License](#License)
|
|
46
45
|
+ [Acknowledgement](#Acknowledgement)
|
|
47
46
|
|
|
47
|
+
|
|
48
48
|
## About The Project<a name = "About_The_Project"></a>
|
|
49
|
-
Enhance the functionality of diffusers.
|
|
50
|
-
* Search models from huggingface and Civitai.
|
|
51
49
|
|
|
50
|
+
Enhance the functionality of diffusers.
|
|
51
|
+
* Search models from Hugging Face and Civitai.
|
|
52
|
+
* Officially listed in the [Hugging Face Diffusers Community Projects](https://huggingface.co/docs/diffusers/community_projects) documentation.
|
|
53
|
+
|
|
54
|
+
<details>
|
|
55
|
+
<summary>Image of the listing location on Hugging Face</summary>
|
|
56
|
+
|
|
57
|
+
[<img src="images\huggingface_highlight.png" width="420">](https://github.com/suzukimain/auto_diffusers/blob/master/images/huggingface_highlight.png)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
</details>
|
|
52
61
|
|
|
53
62
|
## How to use<a name = "How_to_use"></a>
|
|
54
63
|
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
auto_diffusers/__init__.py,sha256=c8RJ0wSpvziBqK5jq_Y9EOYkPXsEXF_eDnVyXu5jv0I,228
|
|
2
|
+
auto_diffusers/pipeline_easy.py,sha256=mVpapjENM-Djpmzdk_6r8e3ddZY2Jne4lM5AwWwnCGM,99561
|
|
3
|
+
auto_diffusers/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
auto_diffusers-2.0.32.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
5
|
+
auto_diffusers-2.0.32.dist-info/METADATA,sha256=Y4IZYwkNICxHKbVA8px9E70RbuEevJzz_XQ30WSJszE,10337
|
|
6
|
+
auto_diffusers-2.0.32.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
|
|
7
|
+
auto_diffusers-2.0.32.dist-info/top_level.txt,sha256=iYkbnc9T-VKVnoCP6AufdXcDUfUaLZ_yMG-USuYf4UQ,15
|
|
8
|
+
auto_diffusers-2.0.32.dist-info/RECORD,,
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
auto_diffusers/__init__.py,sha256=XKmoQRuUnVyCjIz95HUrWXU83xGSbupM84mf-tEzVt0,233
|
|
2
|
-
auto_diffusers/pipeline_easy.py,sha256=5lIEp864CMvBGZKSf2U_WQIC40USb7ebIlhsYlI5baA,93488
|
|
3
|
-
auto_diffusers/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
auto_diffusers-2.0.25.dev0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
5
|
-
auto_diffusers-2.0.25.dev0.dist-info/METADATA,sha256=j6mUUB7jJtPZBsBFrVw-utky4Uh0R5WN725S73ZFANM,9858
|
|
6
|
-
auto_diffusers-2.0.25.dev0.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
|
|
7
|
-
auto_diffusers-2.0.25.dev0.dist-info/top_level.txt,sha256=iYkbnc9T-VKVnoCP6AufdXcDUfUaLZ_yMG-USuYf4UQ,15
|
|
8
|
-
auto_diffusers-2.0.25.dev0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|