auto-diffusers 2.0.21.dev1__py3-none-any.whl → 2.0.22__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.
@@ -1,4 +1,4 @@
1
- __version__ = "2.0.21.dev1"
1
+ __version__ = "2.0.22"
2
2
 
3
3
  from .pipeline_easy import (
4
4
  search_huggingface,
@@ -22,10 +22,6 @@ from typing import Dict, List, Optional, Union
22
22
 
23
23
  import requests
24
24
  import torch
25
- from huggingface_hub import hf_api, hf_hub_download
26
- from huggingface_hub.file_download import http_get
27
- from huggingface_hub.utils import validate_hf_hub_args
28
-
29
25
  from diffusers.loaders.single_file_utils import (
30
26
  VALID_URL_PREFIXES,
31
27
  _extract_repo_id_and_weights_name,
@@ -53,14 +49,19 @@ from diffusers.pipelines.stable_diffusion import (
53
49
  StableDiffusionPipeline,
54
50
  StableDiffusionUpscalePipeline,
55
51
  )
56
- from diffusers.pipelines.stable_diffusion_3 import StableDiffusion3Img2ImgPipeline, StableDiffusion3Pipeline
52
+ from diffusers.pipelines.stable_diffusion_3 import (
53
+ StableDiffusion3Img2ImgPipeline,
54
+ StableDiffusion3Pipeline,
55
+ )
57
56
  from diffusers.pipelines.stable_diffusion_xl import (
58
57
  StableDiffusionXLImg2ImgPipeline,
59
58
  StableDiffusionXLInpaintPipeline,
60
59
  StableDiffusionXLPipeline,
61
60
  )
62
61
  from diffusers.utils import logging
63
-
62
+ from huggingface_hub import hf_api, hf_hub_download
63
+ from huggingface_hub.file_download import http_get
64
+ from huggingface_hub.utils import validate_hf_hub_args
64
65
 
65
66
  logger = logging.get_logger(__name__)
66
67
 
@@ -327,7 +328,9 @@ class SearchResult:
327
328
 
328
329
 
329
330
  @validate_hf_hub_args
330
- def load_pipeline_from_single_file(pretrained_model_or_path, pipeline_mapping, **kwargs):
331
+ def load_pipeline_from_single_file(
332
+ pretrained_model_or_path, pipeline_mapping, **kwargs
333
+ ):
331
334
  r"""
332
335
  Instantiate a [`DiffusionPipeline`] from pretrained pipeline weights saved in the `.ckpt` or `.safetensors`
333
336
  format. The pipeline is set in evaluation mode (`model.eval()`) by default.
@@ -628,7 +631,9 @@ def search_huggingface(search_word: str, **kwargs) -> Union[str, SearchResult, N
628
631
  if skip_error:
629
632
  return None
630
633
  else:
631
- raise ValueError("The URL for Civitai is invalid with `for_hf`. Please use `for_civitai` instead.")
634
+ raise ValueError(
635
+ "The URL for Civitai is invalid with `for_hf`. Please use `for_civitai` instead."
636
+ )
632
637
  else:
633
638
  # Get model data from HF API
634
639
  hf_models = hf_api.list_models(
@@ -667,7 +672,8 @@ def search_huggingface(search_word: str, **kwargs) -> Union[str, SearchResult, N
667
672
  any(file_path.endswith(ext) for ext in EXTENSION)
668
673
  and not any(config in file_path for config in CONFIG_FILE_LIST)
669
674
  and not any(exc in file_path for exc in exclusion)
670
- and os.path.basename(os.path.dirname(file_path)) not in DIFFUSERS_CONFIG_DIR
675
+ and os.path.basename(os.path.dirname(file_path))
676
+ not in DIFFUSERS_CONFIG_DIR
671
677
  ):
672
678
  file_list.append(file_path)
673
679
 
@@ -679,7 +685,9 @@ def search_huggingface(search_word: str, **kwargs) -> Union[str, SearchResult, N
679
685
  if skip_error:
680
686
  return None
681
687
  else:
682
- raise ValueError("No models matching your criteria were found on huggingface.")
688
+ raise ValueError(
689
+ "No models matching your criteria were found on huggingface."
690
+ )
683
691
 
684
692
  if diffusers_model_exists:
685
693
  if download:
@@ -694,7 +702,11 @@ def search_huggingface(search_word: str, **kwargs) -> Union[str, SearchResult, N
694
702
  elif file_list:
695
703
  # Sort and find the safest model
696
704
  file_name = next(
697
- (model for model in sorted(file_list, reverse=True) if re.search(r"(?i)[-_](safe|sfw)", model)),
705
+ (
706
+ model
707
+ for model in sorted(file_list, reverse=True)
708
+ if re.search(r"(?i)[-_](safe|sfw)", model)
709
+ ),
698
710
  file_list[0],
699
711
  )
700
712
 
@@ -723,7 +735,9 @@ def search_huggingface(search_word: str, **kwargs) -> Union[str, SearchResult, N
723
735
  model_path=model_path or download_url,
724
736
  loading_method=output_info["loading_method"],
725
737
  checkpoint_format=output_info["checkpoint_format"],
726
- repo_status=RepoStatus(repo_id=repo_id, repo_hash=hf_repo_info.sha, version=revision),
738
+ repo_status=RepoStatus(
739
+ repo_id=repo_id, repo_hash=hf_repo_info.sha, version=revision
740
+ ),
727
741
  model_status=ModelStatus(
728
742
  search_word=search_word,
729
743
  site_url=download_url,
@@ -814,7 +828,9 @@ def search_civitai(search_word: str, **kwargs) -> Union[str, SearchResult, None]
814
828
 
815
829
  try:
816
830
  # Make the request to the CivitAI API
817
- response = requests.get("https://civitai.com/api/v1/models", params=params, headers=headers)
831
+ response = requests.get(
832
+ "https://civitai.com/api/v1/models", params=params, headers=headers
833
+ )
818
834
  response.raise_for_status()
819
835
  except requests.exceptions.HTTPError as err:
820
836
  raise requests.HTTPError(f"Could not get elements from the URL: {err}")
@@ -828,7 +844,9 @@ def search_civitai(search_word: str, **kwargs) -> Union[str, SearchResult, None]
828
844
  raise ValueError("Invalid JSON response")
829
845
 
830
846
  # Sort repositories by download count in descending order
831
- sorted_repos = sorted(data["items"], key=lambda x: x["stats"]["downloadCount"], reverse=True)
847
+ sorted_repos = sorted(
848
+ data["items"], key=lambda x: x["stats"]["downloadCount"], reverse=True
849
+ )
832
850
 
833
851
  for selected_repo in sorted_repos:
834
852
  repo_name = selected_repo["name"]
@@ -853,7 +871,8 @@ def search_civitai(search_word: str, **kwargs) -> Union[str, SearchResult, None]
853
871
  model_data["pickleScanResult"] == "Success"
854
872
  and model_data["virusScanResult"] == "Success"
855
873
  and any(file_name.endswith(ext) for ext in EXTENSION)
856
- and os.path.basename(os.path.dirname(file_name)) not in DIFFUSERS_CONFIG_DIR
874
+ and os.path.basename(os.path.dirname(file_name))
875
+ not in DIFFUSERS_CONFIG_DIR
857
876
  ):
858
877
  file_status = {
859
878
  "filename": file_name,
@@ -863,12 +882,16 @@ def search_civitai(search_word: str, **kwargs) -> Union[str, SearchResult, None]
863
882
 
864
883
  if models_list:
865
884
  # Sort the models list by filename and find the safest model
866
- sorted_models = sorted(models_list, key=lambda x: x["filename"], reverse=True)
885
+ sorted_models = sorted(
886
+ models_list, key=lambda x: x["filename"], reverse=True
887
+ )
867
888
  selected_model = next(
868
889
  (
869
890
  model_data
870
891
  for model_data in sorted_models
871
- if bool(re.search(r"(?i)[-_](safe|sfw)", model_data["filename"]))
892
+ if bool(
893
+ re.search(r"(?i)[-_](safe|sfw)", model_data["filename"])
894
+ )
872
895
  ),
873
896
  sorted_models[0],
874
897
  )
@@ -883,7 +906,9 @@ def search_civitai(search_word: str, **kwargs) -> Union[str, SearchResult, None]
883
906
  if skip_error:
884
907
  return None
885
908
  else:
886
- raise ValueError("No model found. Please try changing the word you are searching for.")
909
+ raise ValueError(
910
+ "No model found. Please try changing the word you are searching for."
911
+ )
887
912
 
888
913
  # Define model file status
889
914
  file_name = selected_model["filename"]
@@ -892,7 +917,9 @@ def search_civitai(search_word: str, **kwargs) -> Union[str, SearchResult, None]
892
917
  # Handle file download and setting model information
893
918
  if download:
894
919
  # The path where the model is to be saved.
895
- model_path = os.path.join(str(civitai_cache_dir), str(repo_id), str(version_id), str(file_name))
920
+ model_path = os.path.join(
921
+ str(civitai_cache_dir), str(repo_id), str(version_id), str(file_name)
922
+ )
896
923
  # Download Model File
897
924
  file_downloader(
898
925
  url=download_url,
@@ -916,7 +943,9 @@ def search_civitai(search_word: str, **kwargs) -> Union[str, SearchResult, None]
916
943
  model_path=model_path,
917
944
  loading_method=output_info["loading_method"],
918
945
  checkpoint_format=output_info["checkpoint_format"],
919
- repo_status=RepoStatus(repo_id=repo_name, repo_hash=repo_id, version=version_id),
946
+ repo_status=RepoStatus(
947
+ repo_id=repo_name, repo_hash=repo_id, version=version_id
948
+ ),
920
949
  model_status=ModelStatus(
921
950
  search_word=search_word,
922
951
  site_url=f"https://civitai.com/models/{repo_id}?modelVersionId={version_id}",
@@ -1050,7 +1079,9 @@ class AutoConfig:
1050
1079
  f"Token {token} already in tokenizer vocabulary. Please choose a different token name or remove {token} and embedding from the tokenizer and text encoder."
1051
1080
  )
1052
1081
 
1053
- expected_shape = text_encoder.get_input_embeddings().weight.shape[-1] # Expected shape of tokenizer
1082
+ expected_shape = text_encoder.get_input_embeddings().weight.shape[
1083
+ -1
1084
+ ] # Expected shape of tokenizer
1054
1085
 
1055
1086
  for search_word in pretrained_model_name_or_paths:
1056
1087
  if isinstance(search_word, str):
@@ -1081,16 +1112,23 @@ class AutoConfig:
1081
1112
  f"textual_inversion_path: {search_word} -> {textual_inversion_path.model_status.site_url}"
1082
1113
  )
1083
1114
 
1084
- pretrained_model_name_or_paths[pretrained_model_name_or_paths.index(search_word)] = (
1085
- textual_inversion_path.model_path
1086
- )
1115
+ pretrained_model_name_or_paths[
1116
+ pretrained_model_name_or_paths.index(search_word)
1117
+ ] = textual_inversion_path.model_path
1087
1118
 
1088
1119
  self.load_textual_inversion(
1089
- pretrained_model_name_or_paths, token=tokens, tokenizer=tokenizer, text_encoder=text_encoder, **kwargs
1120
+ pretrained_model_name_or_paths,
1121
+ token=tokens,
1122
+ tokenizer=tokenizer,
1123
+ text_encoder=text_encoder,
1124
+ **kwargs,
1090
1125
  )
1091
1126
 
1092
1127
  def auto_load_lora_weights(
1093
- self, pretrained_model_name_or_path_or_dict: Union[str, Dict[str, torch.Tensor]], adapter_name=None, **kwargs
1128
+ self,
1129
+ pretrained_model_name_or_path_or_dict: Union[str, Dict[str, torch.Tensor]],
1130
+ adapter_name=None,
1131
+ **kwargs,
1094
1132
  ):
1095
1133
  r"""
1096
1134
  Load LoRA weights specified in `pretrained_model_name_or_path_or_dict` into `self.unet` and
@@ -1134,7 +1172,9 @@ class AutoConfig:
1134
1172
  logger.warning(f"trained_words: {lora_path.extra_status.trained_words}")
1135
1173
  pretrained_model_name_or_path_or_dict = lora_path.model_path
1136
1174
 
1137
- self.load_lora_weights(pretrained_model_name_or_path_or_dict, adapter_name=adapter_name, **kwargs)
1175
+ self.load_lora_weights(
1176
+ pretrained_model_name_or_path_or_dict, adapter_name=adapter_name, **kwargs
1177
+ )
1138
1178
 
1139
1179
 
1140
1180
  class EasyPipelineForText2Image(AutoPipelineForText2Image):
@@ -1272,8 +1312,12 @@ class EasyPipelineForText2Image(AutoPipelineForText2Image):
1272
1312
  kwargs.update(_status)
1273
1313
 
1274
1314
  # Search for the model on Hugging Face and get the model status
1275
- hf_checkpoint_status = search_huggingface(pretrained_model_link_or_path, **kwargs)
1276
- logger.warning(f"checkpoint_path: {hf_checkpoint_status.model_status.download_url}")
1315
+ hf_checkpoint_status = search_huggingface(
1316
+ pretrained_model_link_or_path, **kwargs
1317
+ )
1318
+ logger.warning(
1319
+ f"checkpoint_path: {hf_checkpoint_status.model_status.download_url}"
1320
+ )
1277
1321
  checkpoint_path = hf_checkpoint_status.model_path
1278
1322
 
1279
1323
  # Check the format of the model checkpoint
@@ -1530,8 +1574,12 @@ class EasyPipelineForImage2Image(AutoPipelineForImage2Image):
1530
1574
  kwargs.update(_parmas)
1531
1575
 
1532
1576
  # Search for the model on Hugging Face and get the model status
1533
- hf_checkpoint_status = search_huggingface(pretrained_model_link_or_path, **kwargs)
1534
- logger.warning(f"checkpoint_path: {hf_checkpoint_status.model_status.download_url}")
1577
+ hf_checkpoint_status = search_huggingface(
1578
+ pretrained_model_link_or_path, **kwargs
1579
+ )
1580
+ logger.warning(
1581
+ f"checkpoint_path: {hf_checkpoint_status.model_status.download_url}"
1582
+ )
1535
1583
  checkpoint_path = hf_checkpoint_status.model_path
1536
1584
 
1537
1585
  # Check the format of the model checkpoint
@@ -1789,8 +1837,12 @@ class EasyPipelineForInpainting(AutoPipelineForInpainting):
1789
1837
  kwargs.update(_status)
1790
1838
 
1791
1839
  # Search for the model on Hugging Face and get the model status
1792
- hf_checkpoint_status = search_huggingface(pretrained_model_link_or_path, **kwargs)
1793
- logger.warning(f"checkpoint_path: {hf_checkpoint_status.model_status.download_url}")
1840
+ hf_checkpoint_status = search_huggingface(
1841
+ pretrained_model_link_or_path, **kwargs
1842
+ )
1843
+ logger.warning(
1844
+ f"checkpoint_path: {hf_checkpoint_status.model_status.download_url}"
1845
+ )
1794
1846
  checkpoint_path = hf_checkpoint_status.model_path
1795
1847
 
1796
1848
  # Check the format of the model checkpoint
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: auto_diffusers
3
- Version: 2.0.21.dev1
4
- Summary: Customized diffusers with model search and other functions.
3
+ Version: 2.0.22
4
+ Summary: diffusers with search engine
5
5
  Home-page: https://github.com/suzukimain/auto_diffusers
6
6
  Author: suzukimain
7
7
  Author-email: subarucosmosmain@gmail.com
@@ -20,10 +20,7 @@ Classifier: Programming Language :: Python :: 3.10
20
20
  Requires-Python: >=3.8.0
21
21
  Description-Content-Type: text/markdown
22
22
  License-File: LICENSE
23
- Requires-Dist: torch
24
- Requires-Dist: diffusers
25
- Requires-Dist: transformers
26
- Requires-Dist: huggingface-hub >=0.26.2
23
+ Requires-Dist: diffusers >=0.32.0
27
24
 
28
25
  # auto_diffusers
29
26
 
@@ -0,0 +1,8 @@
1
+ auto_diffusers/__init__.py,sha256=NNZ-_wyctMOBOzkel-Hb0HLqWXCOnMxZhJchzjtqzzE,228
2
+ auto_diffusers/pipeline_easy.py,sha256=oqImRMCRTmJztHJB9lV4wnHX6FA-5a4-mdFKszViFo0,93292
3
+ auto_diffusers/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ auto_diffusers-2.0.22.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
5
+ auto_diffusers-2.0.22.dist-info/METADATA,sha256=tWGuWIS8LNrs-n9BcYnHIUha4A7x1TdIwI_S0Vww8g0,9816
6
+ auto_diffusers-2.0.22.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
7
+ auto_diffusers-2.0.22.dist-info/top_level.txt,sha256=iYkbnc9T-VKVnoCP6AufdXcDUfUaLZ_yMG-USuYf4UQ,15
8
+ auto_diffusers-2.0.22.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.3.0)
2
+ Generator: setuptools (75.3.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,8 +0,0 @@
1
- auto_diffusers/__init__.py,sha256=d7-A3NievjIk-WF7e3bYelitxaE6xa9abi-BPhNqLak,233
2
- auto_diffusers/pipeline_easy.py,sha256=cx3vRXgeyWmIaOaIJplaC9FH-h6p4W0AmYM-7bhRnaE,92593
3
- auto_diffusers/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- auto_diffusers-2.0.21.dev1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
5
- auto_diffusers-2.0.21.dev1.dist-info/METADATA,sha256=zirapR_cy9m7wyLNwRGQdK9EDJ3Hq41myi0OTuTbwmk,9932
6
- auto_diffusers-2.0.21.dev1.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
7
- auto_diffusers-2.0.21.dev1.dist-info/top_level.txt,sha256=iYkbnc9T-VKVnoCP6AufdXcDUfUaLZ_yMG-USuYf4UQ,15
8
- auto_diffusers-2.0.21.dev1.dist-info/RECORD,,