auto-diffusers 2.0.13__py3-none-any.whl → 2.0.16__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.
@@ -15,96 +15,185 @@
15
15
 
16
16
  import os
17
17
  import re
18
- import requests
19
- from tqdm.auto import tqdm
20
- from typing import Union
18
+ import types
21
19
  from collections import OrderedDict
22
- from dataclasses import (
23
- dataclass,
24
- asdict
25
- )
20
+ from dataclasses import asdict, dataclass
21
+ from typing import Dict, List, Optional, Union
26
22
 
23
+ import requests
24
+ import torch
25
+ from huggingface_hub import hf_api, hf_hub_download
27
26
  from huggingface_hub.file_download import http_get
28
27
  from huggingface_hub.utils import validate_hf_hub_args
29
- from huggingface_hub import (
30
- hf_api,
31
- hf_hub_download,
32
- )
33
28
 
34
- from diffusers.utils import logging
35
29
  from diffusers.loaders.single_file_utils import (
30
+ VALID_URL_PREFIXES,
31
+ _extract_repo_id_and_weights_name,
36
32
  infer_diffusers_model_type,
37
33
  load_single_file_checkpoint,
38
- _extract_repo_id_and_weights_name,
39
- VALID_URL_PREFIXES,
40
34
  )
35
+ from diffusers.pipelines.animatediff import AnimateDiffPipeline, AnimateDiffSDXLPipeline
41
36
  from diffusers.pipelines.auto_pipeline import (
42
- AutoPipelineForText2Image,
43
37
  AutoPipelineForImage2Image,
44
38
  AutoPipelineForInpainting,
39
+ AutoPipelineForText2Image,
45
40
  )
46
41
  from diffusers.pipelines.controlnet import (
47
42
  StableDiffusionControlNetImg2ImgPipeline,
48
43
  StableDiffusionControlNetInpaintPipeline,
49
44
  StableDiffusionControlNetPipeline,
45
+ StableDiffusionXLControlNetImg2ImgPipeline,
46
+ StableDiffusionXLControlNetPipeline,
50
47
  )
48
+ from diffusers.pipelines.flux import FluxImg2ImgPipeline, FluxPipeline
49
+ from diffusers.pipelines.pipeline_utils import DiffusionPipeline
51
50
  from diffusers.pipelines.stable_diffusion import (
52
51
  StableDiffusionImg2ImgPipeline,
53
52
  StableDiffusionInpaintPipeline,
54
53
  StableDiffusionPipeline,
54
+ StableDiffusionUpscalePipeline,
55
55
  )
56
+ from diffusers.pipelines.stable_diffusion_3 import StableDiffusion3Img2ImgPipeline, StableDiffusion3Pipeline
56
57
  from diffusers.pipelines.stable_diffusion_xl import (
57
58
  StableDiffusionXLImg2ImgPipeline,
58
59
  StableDiffusionXLInpaintPipeline,
59
60
  StableDiffusionXLPipeline,
60
61
  )
61
- from diffusers.pipelines.pipeline_utils import DiffusionPipeline
62
+ from diffusers.utils import logging
63
+
62
64
 
63
65
  logger = logging.get_logger(__name__)
64
66
 
65
67
 
66
68
  SINGLE_FILE_CHECKPOINT_TEXT2IMAGE_PIPELINE_MAPPING = OrderedDict(
67
69
  [
68
- ("xl_base", StableDiffusionXLPipeline),
69
- ("xl_refiner", StableDiffusionXLPipeline),
70
- ("xl_inpaint", None),
71
- ("playground-v2-5", StableDiffusionXLPipeline),
72
- ("upscale", None),
70
+ ("animatediff_rgb", AnimateDiffPipeline),
71
+ ("animatediff_scribble", AnimateDiffPipeline),
72
+ ("animatediff_sdxl_beta", AnimateDiffSDXLPipeline),
73
+ ("animatediff_v1", AnimateDiffPipeline),
74
+ ("animatediff_v2", AnimateDiffPipeline),
75
+ ("animatediff_v3", AnimateDiffPipeline),
76
+ ("autoencoder-dc-f128c512", None),
77
+ ("autoencoder-dc-f32c32", None),
78
+ ("autoencoder-dc-f32c32-sana", None),
79
+ ("autoencoder-dc-f64c128", None),
80
+ ("controlnet", StableDiffusionControlNetPipeline),
81
+ ("controlnet_xl", StableDiffusionXLControlNetPipeline),
82
+ ("controlnet_xl_large", StableDiffusionXLControlNetPipeline),
83
+ ("controlnet_xl_mid", StableDiffusionXLControlNetPipeline),
84
+ ("controlnet_xl_small", StableDiffusionXLControlNetPipeline),
85
+ ("flux-depth", FluxPipeline),
86
+ ("flux-dev", FluxPipeline),
87
+ ("flux-fill", FluxPipeline),
88
+ ("flux-schnell", FluxPipeline),
89
+ ("hunyuan-video", None),
73
90
  ("inpainting", None),
74
91
  ("inpainting_v2", None),
75
- ("controlnet", StableDiffusionControlNetPipeline),
76
- ("v2", StableDiffusionPipeline),
92
+ ("ltx-video", None),
93
+ ("ltx-video-0.9.1", None),
94
+ ("mochi-1-preview", None),
95
+ ("playground-v2-5", StableDiffusionXLPipeline),
96
+ ("sd3", StableDiffusion3Pipeline),
97
+ ("sd35_large", StableDiffusion3Pipeline),
98
+ ("sd35_medium", StableDiffusion3Pipeline),
99
+ ("stable_cascade_stage_b", None),
100
+ ("stable_cascade_stage_b_lite", None),
101
+ ("stable_cascade_stage_c", None),
102
+ ("stable_cascade_stage_c_lite", None),
103
+ ("upscale", StableDiffusionUpscalePipeline),
77
104
  ("v1", StableDiffusionPipeline),
105
+ ("v2", StableDiffusionPipeline),
106
+ ("xl_base", StableDiffusionXLPipeline),
107
+ ("xl_inpaint", None),
108
+ ("xl_refiner", StableDiffusionXLPipeline),
78
109
  ]
79
110
  )
80
111
 
81
112
  SINGLE_FILE_CHECKPOINT_IMAGE2IMAGE_PIPELINE_MAPPING = OrderedDict(
82
113
  [
83
- ("xl_base", StableDiffusionXLImg2ImgPipeline),
84
- ("xl_refiner", StableDiffusionXLImg2ImgPipeline),
85
- ("xl_inpaint", None),
86
- ("playground-v2-5", StableDiffusionXLImg2ImgPipeline),
87
- ("upscale", None),
114
+ ("animatediff_rgb", AnimateDiffPipeline),
115
+ ("animatediff_scribble", AnimateDiffPipeline),
116
+ ("animatediff_sdxl_beta", AnimateDiffSDXLPipeline),
117
+ ("animatediff_v1", AnimateDiffPipeline),
118
+ ("animatediff_v2", AnimateDiffPipeline),
119
+ ("animatediff_v3", AnimateDiffPipeline),
120
+ ("autoencoder-dc-f128c512", None),
121
+ ("autoencoder-dc-f32c32", None),
122
+ ("autoencoder-dc-f32c32-sana", None),
123
+ ("autoencoder-dc-f64c128", None),
124
+ ("controlnet", StableDiffusionControlNetImg2ImgPipeline),
125
+ ("controlnet_xl", StableDiffusionXLControlNetImg2ImgPipeline),
126
+ ("controlnet_xl_large", StableDiffusionXLControlNetImg2ImgPipeline),
127
+ ("controlnet_xl_mid", StableDiffusionXLControlNetImg2ImgPipeline),
128
+ ("controlnet_xl_small", StableDiffusionXLControlNetImg2ImgPipeline),
129
+ ("flux-depth", FluxImg2ImgPipeline),
130
+ ("flux-dev", FluxImg2ImgPipeline),
131
+ ("flux-fill", FluxImg2ImgPipeline),
132
+ ("flux-schnell", FluxImg2ImgPipeline),
133
+ ("hunyuan-video", None),
88
134
  ("inpainting", None),
89
135
  ("inpainting_v2", None),
90
- ("controlnet", StableDiffusionControlNetImg2ImgPipeline),
91
- ("v2", StableDiffusionImg2ImgPipeline),
136
+ ("ltx-video", None),
137
+ ("ltx-video-0.9.1", None),
138
+ ("mochi-1-preview", None),
139
+ ("playground-v2-5", StableDiffusionXLImg2ImgPipeline),
140
+ ("sd3", StableDiffusion3Img2ImgPipeline),
141
+ ("sd35_large", StableDiffusion3Img2ImgPipeline),
142
+ ("sd35_medium", StableDiffusion3Img2ImgPipeline),
143
+ ("stable_cascade_stage_b", None),
144
+ ("stable_cascade_stage_b_lite", None),
145
+ ("stable_cascade_stage_c", None),
146
+ ("stable_cascade_stage_c_lite", None),
147
+ ("upscale", StableDiffusionUpscalePipeline),
92
148
  ("v1", StableDiffusionImg2ImgPipeline),
149
+ ("v2", StableDiffusionImg2ImgPipeline),
150
+ ("xl_base", StableDiffusionXLImg2ImgPipeline),
151
+ ("xl_inpaint", None),
152
+ ("xl_refiner", StableDiffusionXLImg2ImgPipeline),
93
153
  ]
94
154
  )
95
155
 
96
156
  SINGLE_FILE_CHECKPOINT_INPAINT_PIPELINE_MAPPING = OrderedDict(
97
157
  [
98
- ("xl_base", None),
99
- ("xl_refiner", None),
100
- ("xl_inpaint", StableDiffusionXLInpaintPipeline),
101
- ("playground-v2-5", None),
102
- ("upscale", None),
158
+ ("animatediff_rgb", None),
159
+ ("animatediff_scribble", None),
160
+ ("animatediff_sdxl_beta", None),
161
+ ("animatediff_v1", None),
162
+ ("animatediff_v2", None),
163
+ ("animatediff_v3", None),
164
+ ("autoencoder-dc-f128c512", None),
165
+ ("autoencoder-dc-f32c32", None),
166
+ ("autoencoder-dc-f32c32-sana", None),
167
+ ("autoencoder-dc-f64c128", None),
168
+ ("controlnet", StableDiffusionControlNetInpaintPipeline),
169
+ ("controlnet_xl", None),
170
+ ("controlnet_xl_large", None),
171
+ ("controlnet_xl_mid", None),
172
+ ("controlnet_xl_small", None),
173
+ ("flux-depth", None),
174
+ ("flux-dev", None),
175
+ ("flux-fill", None),
176
+ ("flux-schnell", None),
177
+ ("hunyuan-video", None),
103
178
  ("inpainting", StableDiffusionInpaintPipeline),
104
179
  ("inpainting_v2", StableDiffusionInpaintPipeline),
105
- ("controlnet", StableDiffusionControlNetInpaintPipeline),
106
- ("v2", None),
180
+ ("ltx-video", None),
181
+ ("ltx-video-0.9.1", None),
182
+ ("mochi-1-preview", None),
183
+ ("playground-v2-5", None),
184
+ ("sd3", None),
185
+ ("sd35_large", None),
186
+ ("sd35_medium", None),
187
+ ("stable_cascade_stage_b", None),
188
+ ("stable_cascade_stage_b_lite", None),
189
+ ("stable_cascade_stage_c", None),
190
+ ("stable_cascade_stage_c_lite", None),
191
+ ("upscale", StableDiffusionUpscalePipeline),
107
192
  ("v1", None),
193
+ ("v2", None),
194
+ ("xl_base", None),
195
+ ("xl_inpaint", StableDiffusionXLInpaintPipeline),
196
+ ("xl_refiner", None),
108
197
  ]
109
198
  )
110
199
 
@@ -122,18 +211,38 @@ CONFIG_FILE_LIST = [
122
211
  "diffusion_pytorch_model.non_ema.safetensors",
123
212
  ]
124
213
 
125
- DIFFUSERS_CONFIG_DIR = ["safety_checker", "unet", "vae", "text_encoder", "text_encoder_2"]
126
-
127
- INPAINT_PIPELINE_KEYS = [
128
- "xl_inpaint",
129
- "inpainting",
130
- "inpainting_v2",
214
+ DIFFUSERS_CONFIG_DIR = [
215
+ "safety_checker",
216
+ "unet",
217
+ "vae",
218
+ "text_encoder",
219
+ "text_encoder_2",
131
220
  ]
132
221
 
133
- EXTENSION = [".safetensors", ".ckpt", ".bin"]
222
+ TOKENIZER_SHAPE_MAP = {
223
+ 768: [
224
+ "SD 1.4",
225
+ "SD 1.5",
226
+ "SD 1.5 LCM",
227
+ "SDXL 0.9",
228
+ "SDXL 1.0",
229
+ "SDXL 1.0 LCM",
230
+ "SDXL Distilled",
231
+ "SDXL Turbo",
232
+ "SDXL Lightning",
233
+ "PixArt a",
234
+ "Playground v2",
235
+ "Pony",
236
+ ],
237
+ 1024: ["SD 2.0", "SD 2.0 768", "SD 2.1", "SD 2.1 768", "SD 2.1 Unclip"],
238
+ }
239
+
240
+
241
+ EXTENSION = [".safetensors", ".ckpt", ".bin"]
134
242
 
135
243
  CACHE_HOME = os.path.expanduser("~/.cache")
136
244
 
245
+
137
246
  @dataclass
138
247
  class RepoStatus:
139
248
  r"""
@@ -147,10 +256,12 @@ class RepoStatus:
147
256
  version (`str`):
148
257
  The version ID of the repository.
149
258
  """
259
+
150
260
  repo_id: str = ""
151
261
  repo_hash: str = ""
152
262
  version: str = ""
153
263
 
264
+
154
265
  @dataclass
155
266
  class ModelStatus:
156
267
  r"""
@@ -165,11 +276,29 @@ class ModelStatus:
165
276
  The name of the model file.
166
277
  local (`bool`):
167
278
  Whether the model exists locally
279
+ site_url (`str`):
280
+ The URL of the site where the model is hosted.
168
281
  """
282
+
169
283
  search_word: str = ""
170
284
  download_url: str = ""
171
285
  file_name: str = ""
172
286
  local: bool = False
287
+ site_url: str = ""
288
+
289
+
290
+ @dataclass
291
+ class ExtraStatus:
292
+ r"""
293
+ Data class for storing extra status information.
294
+
295
+ Attributes:
296
+ trained_words (`str`):
297
+ The words used to trigger the model
298
+ """
299
+
300
+ trained_words: Union[List[str], None] = None
301
+
173
302
 
174
303
  @dataclass
175
304
  class SearchResult:
@@ -188,11 +317,13 @@ class SearchResult:
188
317
  model_status (`ModelStatus`):
189
318
  The status of the model.
190
319
  """
320
+
191
321
  model_path: str = ""
192
- loading_method: Union[str, None] = None
322
+ loading_method: Union[str, None] = None
193
323
  checkpoint_format: Union[str, None] = None
194
324
  repo_status: RepoStatus = RepoStatus()
195
325
  model_status: ModelStatus = ModelStatus()
326
+ extra_status: ExtraStatus = ExtraStatus()
196
327
 
197
328
 
198
329
  @validate_hf_hub_args
@@ -282,7 +413,7 @@ def get_keyword_types(keyword):
282
413
  `dict`: A dictionary containing the model format, loading method,
283
414
  and various types and extra types flags.
284
415
  """
285
-
416
+
286
417
  # Initialize the status dictionary with default values
287
418
  status = {
288
419
  "checkpoint_format": None,
@@ -299,16 +430,16 @@ def get_keyword_types(keyword):
299
430
  "missing_model_index": None,
300
431
  },
301
432
  }
302
-
433
+
303
434
  # Check if the keyword is an HTTP or HTTPS URL
304
435
  status["extra_type"]["url"] = bool(re.search(r"^(https?)://", keyword))
305
-
436
+
306
437
  # Check if the keyword is a file
307
438
  if os.path.isfile(keyword):
308
439
  status["type"]["local"] = True
309
440
  status["checkpoint_format"] = "single_file"
310
441
  status["loading_method"] = "from_single_file"
311
-
442
+
312
443
  # Check if the keyword is a directory
313
444
  elif os.path.isdir(keyword):
314
445
  status["type"]["local"] = True
@@ -316,13 +447,13 @@ def get_keyword_types(keyword):
316
447
  status["loading_method"] = "from_pretrained"
317
448
  if not os.path.exists(os.path.join(keyword, "model_index.json")):
318
449
  status["extra_type"]["missing_model_index"] = True
319
-
450
+
320
451
  # Check if the keyword is a Civitai URL
321
452
  elif keyword.startswith("https://civitai.com/"):
322
453
  status["type"]["civitai_url"] = True
323
454
  status["checkpoint_format"] = "single_file"
324
455
  status["loading_method"] = None
325
-
456
+
326
457
  # Check if the keyword starts with any valid URL prefixes
327
458
  elif any(keyword.startswith(prefix) for prefix in VALID_URL_PREFIXES):
328
459
  repo_id, weights_name = _extract_repo_id_and_weights_name(keyword)
@@ -334,27 +465,27 @@ def get_keyword_types(keyword):
334
465
  status["type"]["hf_repo"] = True
335
466
  status["checkpoint_format"] = "diffusers"
336
467
  status["loading_method"] = "from_pretrained"
337
-
468
+
338
469
  # Check if the keyword matches a Hugging Face repository format
339
470
  elif re.match(r"^[^/]+/[^/]+$", keyword):
340
471
  status["type"]["hf_repo"] = True
341
472
  status["checkpoint_format"] = "diffusers"
342
473
  status["loading_method"] = "from_pretrained"
343
-
474
+
344
475
  # If none of the above apply
345
476
  else:
346
477
  status["type"]["other"] = True
347
478
  status["checkpoint_format"] = None
348
479
  status["loading_method"] = None
349
-
480
+
350
481
  return status
351
482
 
352
483
 
353
484
  def file_downloader(
354
- url,
355
- save_path,
356
- **kwargs,
357
- ) -> None:
485
+ url,
486
+ save_path,
487
+ **kwargs,
488
+ ) -> None:
358
489
  """
359
490
  Downloads a file from a given URL and saves it to the specified path.
360
491
 
@@ -374,7 +505,7 @@ def file_downloader(
374
505
  displayed_filename (`str`, *optional*):
375
506
  The filename of the file that is being downloaded. Value is used only to display a nice progress bar. If
376
507
  not set, the filename is guessed from the URL or the `Content-Disposition` header.
377
-
508
+
378
509
  returns:
379
510
  None
380
511
  """
@@ -385,6 +516,7 @@ def file_downloader(
385
516
  proxies = kwargs.pop("proxies", None)
386
517
  force_download = kwargs.pop("force_download", False)
387
518
  displayed_filename = kwargs.pop("displayed_filename", None)
519
+
388
520
  # Default mode for file writing and initial file size
389
521
  mode = "wb"
390
522
  file_size = 0
@@ -396,7 +528,7 @@ def file_downloader(
396
528
  if os.path.exists(save_path):
397
529
  if not force_download:
398
530
  # If the file exists and force_download is False, skip the download
399
- logger.warning(f"File already exists: {save_path}, skipping download.")
531
+ logger.info(f"File already exists: {save_path}, skipping download.")
400
532
  return None
401
533
  elif resume:
402
534
  # If resuming, set mode to append binary and get current file size
@@ -499,7 +631,7 @@ def search_huggingface(search_word: str, **kwargs) -> Union[str, SearchResult, N
499
631
  pipeline_tag=pipeline_tag,
500
632
  full=True,
501
633
  gated=gated,
502
- token=token
634
+ token=token,
503
635
  )
504
636
  model_dicts = [asdict(value) for value in list(hf_models)]
505
637
 
@@ -514,25 +646,22 @@ def search_huggingface(search_word: str, **kwargs) -> Union[str, SearchResult, N
514
646
  for repo_info in model_dicts:
515
647
  repo_id = repo_info["id"]
516
648
  file_list = []
517
- hf_repo_info = hf_api.model_info(
518
- repo_id=repo_id,
519
- securityStatus=True
520
- )
649
+ hf_repo_info = hf_api.model_info(repo_id=repo_id, securityStatus=True)
521
650
  # Lists files with security issues.
522
651
  hf_security_info = hf_repo_info.security_repo_status
523
- exclusion = [issue['path'] for issue in hf_security_info['filesWithIssues']]
652
+ exclusion = [issue["path"] for issue in hf_security_info["filesWithIssues"]]
524
653
 
525
654
  # Checks for multi-folder diffusers model or valid files (models with security issues are excluded).
526
655
  if hf_security_info["scansDone"]:
527
656
  for info in repo_info["siblings"]:
528
657
  file_path = info["rfilename"]
529
- if (
530
- "model_index.json" == file_path
531
- and checkpoint_format in ["diffusers", "all"]
532
- ):
658
+ if "model_index.json" == file_path and checkpoint_format in [
659
+ "diffusers",
660
+ "all",
661
+ ]:
533
662
  diffusers_model_exists = True
534
663
  break
535
-
664
+
536
665
  elif (
537
666
  any(file_path.endswith(ext) for ext in EXTENSION)
538
667
  and not any(config in file_path for config in CONFIG_FILE_LIST)
@@ -540,7 +669,7 @@ def search_huggingface(search_word: str, **kwargs) -> Union[str, SearchResult, N
540
669
  and os.path.basename(os.path.dirname(file_path)) not in DIFFUSERS_CONFIG_DIR
541
670
  ):
542
671
  file_list.append(file_path)
543
-
672
+
544
673
  # Exit from the loop if a multi-folder diffusers model or valid file is found
545
674
  if diffusers_model_exists or file_list:
546
675
  break
@@ -560,18 +689,13 @@ def search_huggingface(search_word: str, **kwargs) -> Union[str, SearchResult, N
560
689
  )
561
690
  else:
562
691
  model_path = repo_id
563
-
692
+
564
693
  elif file_list:
565
694
  # Sort and find the safest model
566
695
  file_name = next(
567
- (
568
- model
569
- for model in sorted(file_list, reverse=True)
570
- if re.search(r"(?i)[-_](safe|sfw)", model)
571
- ),
572
- file_list[0]
696
+ (model for model in sorted(file_list, reverse=True) if re.search(r"(?i)[-_](safe|sfw)", model)),
697
+ file_list[0],
573
698
  )
574
-
575
699
 
576
700
  if download:
577
701
  model_path = hf_hub_download(
@@ -581,12 +705,12 @@ def search_huggingface(search_word: str, **kwargs) -> Union[str, SearchResult, N
581
705
  token=token,
582
706
  force_download=force_download,
583
707
  )
584
-
708
+
585
709
  if file_name:
586
710
  download_url = f"https://huggingface.co/{repo_id}/blob/main/{file_name}"
587
711
  else:
588
712
  download_url = f"https://huggingface.co/{repo_id}"
589
-
713
+
590
714
  output_info = get_keyword_types(model_path)
591
715
 
592
716
  if include_params:
@@ -594,22 +718,20 @@ def search_huggingface(search_word: str, **kwargs) -> Union[str, SearchResult, N
594
718
  model_path=model_path or download_url,
595
719
  loading_method=output_info["loading_method"],
596
720
  checkpoint_format=output_info["checkpoint_format"],
597
- repo_status=RepoStatus(
598
- repo_id=repo_id,
599
- repo_hash=hf_repo_info.sha,
600
- version=revision
601
- ),
721
+ repo_status=RepoStatus(repo_id=repo_id, repo_hash=hf_repo_info.sha, version=revision),
602
722
  model_status=ModelStatus(
603
723
  search_word=search_word,
724
+ site_url=download_url,
604
725
  download_url=download_url,
605
726
  file_name=file_name,
606
727
  local=download,
607
- )
728
+ ),
729
+ extra_status=ExtraStatus(trained_words=None),
608
730
  )
609
-
731
+
610
732
  else:
611
733
  return model_path
612
-
734
+
613
735
 
614
736
  def search_civitai(search_word: str, **kwargs) -> Union[str, SearchResult, None]:
615
737
  r"""
@@ -620,6 +742,8 @@ def search_civitai(search_word: str, **kwargs) -> Union[str, SearchResult, None]
620
742
  The search query string.
621
743
  model_type (`str`, *optional*, defaults to `Checkpoint`):
622
744
  The type of model to search for.
745
+ sort (`str`, *optional*):
746
+ The order in which you wish to sort the results(for example, `Highest Rated`, `Most Downloaded`, `Newest`).
623
747
  base_model (`str`, *optional*):
624
748
  The base model to filter by.
625
749
  download (`bool`, *optional*, defaults to `False`):
@@ -643,6 +767,7 @@ def search_civitai(search_word: str, **kwargs) -> Union[str, SearchResult, None]
643
767
 
644
768
  # Extract additional parameters from kwargs
645
769
  model_type = kwargs.pop("model_type", "Checkpoint")
770
+ sort = kwargs.pop("sort", None)
646
771
  download = kwargs.pop("download", False)
647
772
  base_model = kwargs.pop("base_model", None)
648
773
  force_download = kwargs.pop("force_download", False)
@@ -657,6 +782,7 @@ def search_civitai(search_word: str, **kwargs) -> Union[str, SearchResult, None]
657
782
  repo_name = ""
658
783
  repo_id = ""
659
784
  version_id = ""
785
+ trainedWords = ""
660
786
  models_list = []
661
787
  selected_repo = {}
662
788
  selected_model = {}
@@ -667,21 +793,23 @@ def search_civitai(search_word: str, **kwargs) -> Union[str, SearchResult, None]
667
793
  params = {
668
794
  "query": search_word,
669
795
  "types": model_type,
670
- "sort": "Most Downloaded",
671
796
  "limit": 20,
672
797
  }
673
798
  if base_model is not None:
799
+ if not isinstance(base_model, list):
800
+ base_model = [base_model]
674
801
  params["baseModel"] = base_model
675
802
 
803
+ if sort is not None:
804
+ params["sort"] = sort
805
+
676
806
  headers = {}
677
807
  if token:
678
808
  headers["Authorization"] = f"Bearer {token}"
679
809
 
680
810
  try:
681
811
  # Make the request to the CivitAI API
682
- response = requests.get(
683
- "https://civitai.com/api/v1/models", params=params, headers=headers
684
- )
812
+ response = requests.get("https://civitai.com/api/v1/models", params=params, headers=headers)
685
813
  response.raise_for_status()
686
814
  except requests.exceptions.HTTPError as err:
687
815
  raise requests.HTTPError(f"Could not get elements from the URL: {err}")
@@ -693,7 +821,7 @@ def search_civitai(search_word: str, **kwargs) -> Union[str, SearchResult, None]
693
821
  return None
694
822
  else:
695
823
  raise ValueError("Invalid JSON response")
696
-
824
+
697
825
  # Sort repositories by download count in descending order
698
826
  sorted_repos = sorted(data["items"], key=lambda x: x["stats"]["downloadCount"], reverse=True)
699
827
 
@@ -702,24 +830,31 @@ def search_civitai(search_word: str, **kwargs) -> Union[str, SearchResult, None]
702
830
  repo_id = selected_repo["id"]
703
831
 
704
832
  # Sort versions within the selected repo by download count
705
- sorted_versions = sorted(selected_repo["modelVersions"], key=lambda x: x["stats"]["downloadCount"], reverse=True)
833
+ sorted_versions = sorted(
834
+ selected_repo["modelVersions"],
835
+ key=lambda x: x["stats"]["downloadCount"],
836
+ reverse=True,
837
+ )
706
838
  for selected_version in sorted_versions:
707
839
  version_id = selected_version["id"]
840
+ trainedWords = selected_version["trainedWords"]
708
841
  models_list = []
709
- for model_data in selected_version["files"]:
710
- # Check if the file passes security scans and has a valid extension
711
- file_name = model_data["name"]
712
- if (
713
- model_data["pickleScanResult"] == "Success"
714
- and model_data["virusScanResult"] == "Success"
715
- and any(file_name.endswith(ext) for ext in EXTENSION)
716
- and os.path.basename(os.path.dirname(file_name)) not in DIFFUSERS_CONFIG_DIR
717
- ):
718
- file_status = {
719
- "filename": file_name,
720
- "download_url": model_data["downloadUrl"],
721
- }
722
- models_list.append(file_status)
842
+ # When searching for textual inversion, results other than the values entered for the base model may come up, so check again.
843
+ if base_model is None or selected_version["baseModel"] in base_model:
844
+ for model_data in selected_version["files"]:
845
+ # Check if the file passes security scans and has a valid extension
846
+ file_name = model_data["name"]
847
+ if (
848
+ model_data["pickleScanResult"] == "Success"
849
+ and model_data["virusScanResult"] == "Success"
850
+ and any(file_name.endswith(ext) for ext in EXTENSION)
851
+ and os.path.basename(os.path.dirname(file_name)) not in DIFFUSERS_CONFIG_DIR
852
+ ):
853
+ file_status = {
854
+ "filename": file_name,
855
+ "download_url": model_data["downloadUrl"],
856
+ }
857
+ models_list.append(file_status)
723
858
 
724
859
  if models_list:
725
860
  # Sort the models list by filename and find the safest model
@@ -730,21 +865,21 @@ def search_civitai(search_word: str, **kwargs) -> Union[str, SearchResult, None]
730
865
  for model_data in sorted_models
731
866
  if bool(re.search(r"(?i)[-_](safe|sfw)", model_data["filename"]))
732
867
  ),
733
- sorted_models[0]
868
+ sorted_models[0],
734
869
  )
735
870
 
736
871
  break
737
872
  else:
738
873
  continue
739
874
  break
740
-
875
+
741
876
  # Exception handling when search candidates are not found
742
877
  if not selected_model:
743
878
  if skip_error:
744
879
  return None
745
880
  else:
746
881
  raise ValueError("No model found. Please try changing the word you are searching for.")
747
-
882
+
748
883
  # Define model file status
749
884
  file_name = selected_model["filename"]
750
885
  download_url = selected_model["download_url"]
@@ -752,9 +887,7 @@ def search_civitai(search_word: str, **kwargs) -> Union[str, SearchResult, None]
752
887
  # Handle file download and setting model information
753
888
  if download:
754
889
  # The path where the model is to be saved.
755
- model_path = os.path.join(
756
- str(civitai_cache_dir), str(repo_id), str(version_id), str(file_name)
757
- )
890
+ model_path = os.path.join(str(civitai_cache_dir), str(repo_id), str(version_id), str(file_name))
758
891
  # Download Model File
759
892
  file_downloader(
760
893
  url=download_url,
@@ -778,26 +911,232 @@ def search_civitai(search_word: str, **kwargs) -> Union[str, SearchResult, None]
778
911
  model_path=model_path,
779
912
  loading_method=output_info["loading_method"],
780
913
  checkpoint_format=output_info["checkpoint_format"],
781
- repo_status=RepoStatus(
782
- repo_id=repo_name,
783
- repo_hash=repo_id,
784
- version=version_id
785
- ),
914
+ repo_status=RepoStatus(repo_id=repo_name, repo_hash=repo_id, version=version_id),
786
915
  model_status=ModelStatus(
787
916
  search_word=search_word,
917
+ site_url=f"https://civitai.com/models/{repo_id}?modelVersionId={version_id}",
788
918
  download_url=download_url,
789
919
  file_name=file_name,
790
- local=output_info["type"]["local"]
791
- )
920
+ local=output_info["type"]["local"],
921
+ ),
922
+ extra_status=ExtraStatus(trained_words=trainedWords or None),
792
923
  )
793
924
 
794
925
 
795
- class EasyPipelineForText2Image(AutoPipelineForText2Image):
926
+ def add_methods(pipeline):
796
927
  r"""
928
+ Add methods from `AutoConfig` to the pipeline.
929
+
930
+ Parameters:
931
+ pipeline (`Pipeline`):
932
+ The pipeline to which the methods will be added.
933
+ """
934
+ for attr_name in dir(AutoConfig):
935
+ attr_value = getattr(AutoConfig, attr_name)
936
+ if callable(attr_value) and not attr_name.startswith("__"):
937
+ setattr(pipeline, attr_name, types.MethodType(attr_value, pipeline))
938
+ return pipeline
939
+
940
+
941
+ class AutoConfig:
942
+ def auto_load_textual_inversion(
943
+ self,
944
+ pretrained_model_name_or_path: Union[str, List[str]],
945
+ token: Optional[Union[str, List[str]]] = None,
946
+ base_model: Optional[Union[str, List[str]]] = None,
947
+ tokenizer=None,
948
+ text_encoder=None,
949
+ **kwargs,
950
+ ):
951
+ r"""
952
+ Load Textual Inversion embeddings into the text encoder of [`StableDiffusionPipeline`] (both 🤗 Diffusers and
953
+ Automatic1111 formats are supported).
954
+
955
+ Parameters:
956
+ pretrained_model_name_or_path (`str` or `os.PathLike` or `List[str or os.PathLike]` or `Dict` or `List[Dict]`):
957
+ Can be either one of the following or a list of them:
958
+
959
+ - Search keywords for pretrained model (for example `EasyNegative`).
960
+ - A string, the *model id* (for example `sd-concepts-library/low-poly-hd-logos-icons`) of a
961
+ pretrained model hosted on the Hub.
962
+ - A path to a *directory* (for example `./my_text_inversion_directory/`) containing the textual
963
+ inversion weights.
964
+ - A path to a *file* (for example `./my_text_inversions.pt`) containing textual inversion weights.
965
+ - A [torch state
966
+ dict](https://pytorch.org/tutorials/beginner/saving_loading_models.html#what-is-a-state-dict).
967
+
968
+ token (`str` or `List[str]`, *optional*):
969
+ Override the token to use for the textual inversion weights. If `pretrained_model_name_or_path` is a
970
+ list, then `token` must also be a list of equal length.
971
+ text_encoder ([`~transformers.CLIPTextModel`], *optional*):
972
+ Frozen text-encoder ([clip-vit-large-patch14](https://huggingface.co/openai/clip-vit-large-patch14)).
973
+ If not specified, function will take self.tokenizer.
974
+ tokenizer ([`~transformers.CLIPTokenizer`], *optional*):
975
+ A `CLIPTokenizer` to tokenize text. If not specified, function will take self.tokenizer.
976
+ weight_name (`str`, *optional*):
977
+ Name of a custom weight file. This should be used when:
978
+
979
+ - The saved textual inversion file is in 🤗 Diffusers format, but was saved under a specific weight
980
+ name such as `text_inv.bin`.
981
+ - The saved textual inversion file is in the Automatic1111 format.
982
+ cache_dir (`Union[str, os.PathLike]`, *optional*):
983
+ Path to a directory where a downloaded pretrained model configuration is cached if the standard cache
984
+ is not used.
985
+ force_download (`bool`, *optional*, defaults to `False`):
986
+ Whether or not to force the (re-)download of the model weights and configuration files, overriding the
987
+ cached versions if they exist.
797
988
 
798
- [`AutoPipelineForText2Image`] is a generic pipeline class that instantiates a text-to-image pipeline class. The
989
+ proxies (`Dict[str, str]`, *optional*):
990
+ A dictionary of proxy servers to use by protocol or endpoint, for example, `{'http': 'foo.bar:3128',
991
+ 'http://hostname': 'foo.bar:4012'}`. The proxies are used on each request.
992
+ local_files_only (`bool`, *optional*, defaults to `False`):
993
+ Whether to only load local model weights and configuration files or not. If set to `True`, the model
994
+ won't be downloaded from the Hub.
995
+ token (`str` or *bool*, *optional*):
996
+ The token to use as HTTP bearer authorization for remote files. If `True`, the token generated from
997
+ `diffusers-cli login` (stored in `~/.huggingface`) is used.
998
+ revision (`str`, *optional*, defaults to `"main"`):
999
+ The specific model version to use. It can be a branch name, a tag name, a commit id, or any identifier
1000
+ allowed by Git.
1001
+ subfolder (`str`, *optional*, defaults to `""`):
1002
+ The subfolder location of a model file within a larger model repository on the Hub or locally.
1003
+ mirror (`str`, *optional*):
1004
+ Mirror source to resolve accessibility issues if you're downloading a model in China. We do not
1005
+ guarantee the timeliness or safety of the source, and you should refer to the mirror site for more
1006
+ information.
1007
+
1008
+ Examples:
1009
+
1010
+ ```py
1011
+ >>> from auto_diffusers import EasyPipelineForText2Image
1012
+
1013
+ >>> pipeline = EasyPipelineForText2Image.from_huggingface("stable-diffusion-v1-5")
1014
+
1015
+ >>> pipeline.auto_load_textual_inversion("EasyNegative", token="EasyNegative")
1016
+
1017
+ >>> image = pipeline(prompt).images[0]
1018
+ ```
1019
+
1020
+ """
1021
+ # 1. Set tokenizer and text encoder
1022
+ tokenizer = tokenizer or getattr(self, "tokenizer", None)
1023
+ text_encoder = text_encoder or getattr(self, "text_encoder", None)
1024
+
1025
+ # Check if tokenizer and text encoder are provided
1026
+ if tokenizer is None or text_encoder is None:
1027
+ raise ValueError("Tokenizer and text encoder must be provided.")
1028
+
1029
+ # 2. Normalize inputs
1030
+ pretrained_model_name_or_paths = (
1031
+ [pretrained_model_name_or_path]
1032
+ if not isinstance(pretrained_model_name_or_path, list)
1033
+ else pretrained_model_name_or_path
1034
+ )
1035
+
1036
+ # 2.1 Normalize tokens
1037
+ tokens = [token] if not isinstance(token, list) else token
1038
+ if tokens[0] is None:
1039
+ tokens = tokens * len(pretrained_model_name_or_paths)
1040
+
1041
+ for check_token in tokens:
1042
+ # Check if token is already in tokenizer vocabulary
1043
+ if check_token in tokenizer.get_vocab():
1044
+ raise ValueError(
1045
+ f"Token {token} already in tokenizer vocabulary. Please choose a different token name or remove {token} and embedding from the tokenizer and text encoder."
1046
+ )
1047
+
1048
+ expected_shape = text_encoder.get_input_embeddings().weight.shape[-1] # Expected shape of tokenizer
1049
+
1050
+ for search_word in pretrained_model_name_or_paths:
1051
+ if isinstance(search_word, str):
1052
+ # Update kwargs to ensure the model is downloaded and parameters are included
1053
+ _status = {
1054
+ "download": True,
1055
+ "include_params": True,
1056
+ "skip_error": False,
1057
+ "model_type": "TextualInversion",
1058
+ }
1059
+ # Get tags for the base model of textual inversion compatible with tokenizer.
1060
+ # If the tokenizer is 768-dimensional, set tags for SD 1.x and SDXL.
1061
+ # If the tokenizer is 1024-dimensional, set tags for SD 2.x.
1062
+ if expected_shape in TOKENIZER_SHAPE_MAP:
1063
+ # Retrieve the appropriate tags from the TOKENIZER_SHAPE_MAP based on the expected shape
1064
+ tags = TOKENIZER_SHAPE_MAP[expected_shape]
1065
+ if base_model is not None:
1066
+ if isinstance(base_model, list):
1067
+ tags.extend(base_model)
1068
+ else:
1069
+ tags.append(base_model)
1070
+ _status["base_model"] = tags
1071
+
1072
+ kwargs.update(_status)
1073
+ # Search for the model on Civitai and get the model status
1074
+ textual_inversion_path = search_civitai(search_word, **kwargs)
1075
+ logger.warning(
1076
+ f"textual_inversion_path: {search_word} -> {textual_inversion_path.model_status.site_url}"
1077
+ )
1078
+
1079
+ pretrained_model_name_or_paths[pretrained_model_name_or_paths.index(search_word)] = (
1080
+ textual_inversion_path.model_path
1081
+ )
1082
+
1083
+ self.load_textual_inversion(
1084
+ pretrained_model_name_or_paths, token=tokens, tokenizer=tokenizer, text_encoder=text_encoder, **kwargs
1085
+ )
1086
+
1087
+ def auto_load_lora_weights(
1088
+ self, pretrained_model_name_or_path_or_dict: Union[str, Dict[str, torch.Tensor]], adapter_name=None, **kwargs
1089
+ ):
1090
+ r"""
1091
+ Load LoRA weights specified in `pretrained_model_name_or_path_or_dict` into `self.unet` and
1092
+ `self.text_encoder`.
1093
+
1094
+ All kwargs are forwarded to `self.lora_state_dict`.
1095
+
1096
+ See [`~loaders.StableDiffusionLoraLoaderMixin.lora_state_dict`] for more details on how the state dict is
1097
+ loaded.
1098
+
1099
+ See [`~loaders.StableDiffusionLoraLoaderMixin.load_lora_into_unet`] for more details on how the state dict is
1100
+ loaded into `self.unet`.
1101
+
1102
+ See [`~loaders.StableDiffusionLoraLoaderMixin.load_lora_into_text_encoder`] for more details on how the state
1103
+ dict is loaded into `self.text_encoder`.
1104
+
1105
+ Parameters:
1106
+ pretrained_model_name_or_path_or_dict (`str` or `os.PathLike` or `dict`):
1107
+ See [`~loaders.StableDiffusionLoraLoaderMixin.lora_state_dict`].
1108
+ adapter_name (`str`, *optional*):
1109
+ Adapter name to be used for referencing the loaded adapter model. If not specified, it will use
1110
+ `default_{i}` where i is the total number of adapters being loaded.
1111
+ low_cpu_mem_usage (`bool`, *optional*):
1112
+ Speed up model loading by only loading the pretrained LoRA weights and not initializing the random
1113
+ weights.
1114
+ kwargs (`dict`, *optional*):
1115
+ See [`~loaders.StableDiffusionLoraLoaderMixin.lora_state_dict`].
1116
+ """
1117
+ if isinstance(pretrained_model_name_or_path_or_dict, str):
1118
+ # Update kwargs to ensure the model is downloaded and parameters are included
1119
+ _status = {
1120
+ "download": True,
1121
+ "include_params": True,
1122
+ "skip_error": False,
1123
+ "model_type": "LORA",
1124
+ }
1125
+ kwargs.update(_status)
1126
+ # Search for the model on Civitai and get the model status
1127
+ lora_path = search_civitai(pretrained_model_name_or_path_or_dict, **kwargs)
1128
+ logger.warning(f"lora_path: {lora_path.model_status.site_url}")
1129
+ logger.warning(f"trained_words: {lora_path.extra_status.trained_words}")
1130
+ pretrained_model_name_or_path_or_dict = lora_path.model_path
1131
+
1132
+ self.load_lora_weights(pretrained_model_name_or_path_or_dict, adapter_name=adapter_name, **kwargs)
1133
+
1134
+
1135
+ class EasyPipelineForText2Image(AutoPipelineForText2Image, AutoConfig):
1136
+ r"""
1137
+ [`EasyPipelineForText2Image`] is a generic pipeline class that instantiates a text-to-image pipeline class. The
799
1138
  specific underlying pipeline class is automatically selected from either the
800
- [`~AutoPipelineForText2Image.from_pretrained`] or [`~AutoPipelineForText2Image.from_pipe`] methods.
1139
+ [`~EasyPipelineForText2Image.from_pretrained`], [`~EasyPipelineForText2Image.from_pipe`], [`~EasyPipelineForText2Image.from_huggingface`] or [`~EasyPipelineForText2Image.from_civitai`] methods.
801
1140
 
802
1141
  This class cannot be instantiated using `__init__()` (throws an error).
803
1142
 
@@ -814,7 +1153,6 @@ class EasyPipelineForText2Image(AutoPipelineForText2Image):
814
1153
  # EnvironmentError is returned
815
1154
  super().__init__()
816
1155
 
817
-
818
1156
  @classmethod
819
1157
  @validate_hf_hub_args
820
1158
  def from_huggingface(cls, pretrained_model_link_or_path, **kwargs):
@@ -913,9 +1251,9 @@ class EasyPipelineForText2Image(AutoPipelineForText2Image):
913
1251
  Examples:
914
1252
 
915
1253
  ```py
916
- >>> from diffusers import AutoPipelineForText2Image
1254
+ >>> from auto_diffusers import EasyPipelineForText2Image
917
1255
 
918
- >>> pipeline = AutoPipelineForText2Image.from_huggingface("stable-diffusion-v1-5")
1256
+ >>> pipeline = EasyPipelineForText2Image.from_huggingface("stable-diffusion-v1-5")
919
1257
  >>> image = pipeline(prompt).images[0]
920
1258
  ```
921
1259
  """
@@ -929,21 +1267,21 @@ class EasyPipelineForText2Image(AutoPipelineForText2Image):
929
1267
  kwargs.update(_status)
930
1268
 
931
1269
  # Search for the model on Hugging Face and get the model status
932
- hf_model_status = search_huggingface(pretrained_model_link_or_path, **kwargs)
933
- logger.warning(f"checkpoint_path: {hf_model_status.model_status.download_url}")
934
- checkpoint_path = hf_model_status.model_path
935
-
1270
+ hf_checkpoint_status = search_huggingface(pretrained_model_link_or_path, **kwargs)
1271
+ logger.warning(f"checkpoint_path: {hf_checkpoint_status.model_status.download_url}")
1272
+ checkpoint_path = hf_checkpoint_status.model_path
1273
+
936
1274
  # Check the format of the model checkpoint
937
- if hf_model_status.checkpoint_format == "single_file":
1275
+ if hf_checkpoint_status.loading_method == "from_single_file":
938
1276
  # Load the pipeline from a single file checkpoint
939
1277
  return load_pipeline_from_single_file(
940
1278
  pretrained_model_or_path=checkpoint_path,
941
1279
  pipeline_mapping=SINGLE_FILE_CHECKPOINT_TEXT2IMAGE_PIPELINE_MAPPING,
942
- **kwargs
1280
+ **kwargs,
943
1281
  )
944
1282
  else:
945
1283
  return cls.from_pretrained(checkpoint_path, **kwargs)
946
-
1284
+
947
1285
  @classmethod
948
1286
  def from_civitai(cls, pretrained_model_link_or_path, **kwargs):
949
1287
  r"""
@@ -1021,9 +1359,9 @@ class EasyPipelineForText2Image(AutoPipelineForText2Image):
1021
1359
  Examples:
1022
1360
 
1023
1361
  ```py
1024
- >>> from diffusers import AutoPipelineForText2Image
1362
+ >>> from auto_diffusers import EasyPipelineForText2Image
1025
1363
 
1026
- >>> pipeline = AutoPipelineForText2Image.from_huggingface("stable-diffusion-v1-5")
1364
+ >>> pipeline = EasyPipelineForText2Image.from_huggingface("stable-diffusion-v1-5")
1027
1365
  >>> image = pipeline(prompt).images[0]
1028
1366
  ```
1029
1367
  """
@@ -1037,25 +1375,25 @@ class EasyPipelineForText2Image(AutoPipelineForText2Image):
1037
1375
  kwargs.update(_status)
1038
1376
 
1039
1377
  # Search for the model on Civitai and get the model status
1040
- model_status = search_civitai(pretrained_model_link_or_path, **kwargs)
1041
- logger.warning(f"checkpoint_path: {model_status.model_status.download_url}")
1042
- checkpoint_path = model_status.model_path
1378
+ checkpoint_status = search_civitai(pretrained_model_link_or_path, **kwargs)
1379
+ logger.warning(f"checkpoint_path: {checkpoint_status.model_status.site_url}")
1380
+ checkpoint_path = checkpoint_status.model_path
1043
1381
 
1044
1382
  # Load the pipeline from a single file checkpoint
1045
- return load_pipeline_from_single_file(
1383
+ pipeline = load_pipeline_from_single_file(
1046
1384
  pretrained_model_or_path=checkpoint_path,
1047
1385
  pipeline_mapping=SINGLE_FILE_CHECKPOINT_TEXT2IMAGE_PIPELINE_MAPPING,
1048
- **kwargs
1386
+ **kwargs,
1049
1387
  )
1050
-
1388
+ return add_methods(pipeline)
1051
1389
 
1052
1390
 
1053
1391
  class EasyPipelineForImage2Image(AutoPipelineForImage2Image):
1054
1392
  r"""
1055
1393
 
1056
- [`AutoPipelineForImage2Image`] is a generic pipeline class that instantiates an image-to-image pipeline class. The
1394
+ [`EasyPipelineForImage2Image`] is a generic pipeline class that instantiates an image-to-image pipeline class. The
1057
1395
  specific underlying pipeline class is automatically selected from either the
1058
- [`~AutoPipelineForImage2Image.from_pretrained`] or [`~AutoPipelineForImage2Image.from_pipe`] methods.
1396
+ [`~EasyPipelineForImage2Image.from_pretrained`], [`~EasyPipelineForImage2Image.from_pipe`], [`~EasyPipelineForImage2Image.from_huggingface`] or [`~EasyPipelineForImage2Image.from_civitai`] methods.
1059
1397
 
1060
1398
  This class cannot be instantiated using `__init__()` (throws an error).
1061
1399
 
@@ -1071,7 +1409,7 @@ class EasyPipelineForImage2Image(AutoPipelineForImage2Image):
1071
1409
  def __init__(self, *args, **kwargs):
1072
1410
  # EnvironmentError is returned
1073
1411
  super().__init__()
1074
-
1412
+
1075
1413
  @classmethod
1076
1414
  @validate_hf_hub_args
1077
1415
  def from_huggingface(cls, pretrained_model_link_or_path, **kwargs):
@@ -1170,10 +1508,10 @@ class EasyPipelineForImage2Image(AutoPipelineForImage2Image):
1170
1508
  Examples:
1171
1509
 
1172
1510
  ```py
1173
- >>> from diffusers import AutoPipelineForText2Image
1511
+ >>> from auto_diffusers import EasyPipelineForImage2Image
1174
1512
 
1175
- >>> pipeline = AutoPipelineForText2Image.from_huggingface("stable-diffusion-v1-5")
1176
- >>> image = pipeline(prompt).images[0]
1513
+ >>> pipeline = EasyPipelineForImage2Image.from_huggingface("stable-diffusion-v1-5")
1514
+ >>> image = pipeline(prompt, image).images[0]
1177
1515
  ```
1178
1516
  """
1179
1517
  # Update kwargs to ensure the model is downloaded and parameters are included
@@ -1186,21 +1524,23 @@ class EasyPipelineForImage2Image(AutoPipelineForImage2Image):
1186
1524
  kwargs.update(_parmas)
1187
1525
 
1188
1526
  # Search for the model on Hugging Face and get the model status
1189
- model_status = search_huggingface(pretrained_model_link_or_path, **kwargs)
1190
- logger.warning(f"checkpoint_path: {model_status.model_status.download_url}")
1191
- checkpoint_path = model_status.model_path
1192
-
1527
+ hf_checkpoint_status = search_huggingface(pretrained_model_link_or_path, **kwargs)
1528
+ logger.warning(f"checkpoint_path: {hf_checkpoint_status.model_status.download_url}")
1529
+ checkpoint_path = hf_checkpoint_status.model_path
1530
+
1193
1531
  # Check the format of the model checkpoint
1194
- if model_status.checkpoint_format == "single_file":
1532
+ if hf_checkpoint_status.loading_method == "from_single_file":
1195
1533
  # Load the pipeline from a single file checkpoint
1196
- return load_pipeline_from_single_file(
1534
+ pipeline = load_pipeline_from_single_file(
1197
1535
  pretrained_model_or_path=checkpoint_path,
1198
1536
  pipeline_mapping=SINGLE_FILE_CHECKPOINT_IMAGE2IMAGE_PIPELINE_MAPPING,
1199
- **kwargs
1537
+ **kwargs,
1200
1538
  )
1201
1539
  else:
1202
- return cls.from_pretrained(checkpoint_path, **kwargs)
1203
-
1540
+ pipeline = cls.from_pretrained(checkpoint_path, **kwargs)
1541
+
1542
+ return add_methods(pipeline)
1543
+
1204
1544
  @classmethod
1205
1545
  def from_civitai(cls, pretrained_model_link_or_path, **kwargs):
1206
1546
  r"""
@@ -1278,10 +1618,10 @@ class EasyPipelineForImage2Image(AutoPipelineForImage2Image):
1278
1618
  Examples:
1279
1619
 
1280
1620
  ```py
1281
- >>> from diffusers import AutoPipelineForText2Image
1621
+ >>> from auto_diffusers import EasyPipelineForImage2Image
1282
1622
 
1283
- >>> pipeline = AutoPipelineForText2Image.from_huggingface("stable-diffusion-v1-5")
1284
- >>> image = pipeline(prompt).images[0]
1623
+ >>> pipeline = EasyPipelineForImage2Image.from_huggingface("stable-diffusion-v1-5")
1624
+ >>> image = pipeline(prompt, image).images[0]
1285
1625
  ```
1286
1626
  """
1287
1627
  # Update kwargs to ensure the model is downloaded and parameters are included
@@ -1294,25 +1634,24 @@ class EasyPipelineForImage2Image(AutoPipelineForImage2Image):
1294
1634
  kwargs.update(_status)
1295
1635
 
1296
1636
  # Search for the model on Civitai and get the model status
1297
- model_status = search_civitai(pretrained_model_link_or_path, **kwargs)
1298
- logger.warning(f"checkpoint_path: {model_status.model_status.download_url}")
1299
- checkpoint_path = model_status.model_path
1637
+ checkpoint_status = search_civitai(pretrained_model_link_or_path, **kwargs)
1638
+ logger.warning(f"checkpoint_path: {checkpoint_status.model_status.site_url}")
1639
+ checkpoint_path = checkpoint_status.model_path
1300
1640
 
1301
1641
  # Load the pipeline from a single file checkpoint
1302
1642
  return load_pipeline_from_single_file(
1303
1643
  pretrained_model_or_path=checkpoint_path,
1304
1644
  pipeline_mapping=SINGLE_FILE_CHECKPOINT_IMAGE2IMAGE_PIPELINE_MAPPING,
1305
- **kwargs
1645
+ **kwargs,
1306
1646
  )
1307
1647
 
1308
-
1309
1648
 
1310
1649
  class EasyPipelineForInpainting(AutoPipelineForInpainting):
1311
1650
  r"""
1312
1651
 
1313
- [`AutoPipelineForInpainting`] is a generic pipeline class that instantiates an inpainting pipeline class. The
1652
+ [`EasyPipelineForInpainting`] is a generic pipeline class that instantiates an inpainting pipeline class. The
1314
1653
  specific underlying pipeline class is automatically selected from either the
1315
- [`~AutoPipelineForInpainting.from_pretrained`] or [`~AutoPipelineForInpainting.from_pipe`] methods.
1654
+ [`~EasyPipelineForInpainting.from_pretrained`], [`~EasyPipelineForInpainting.from_pipe`], [`~EasyPipelineForInpainting.from_huggingface`] or [`~EasyPipelineForInpainting.from_civitai`] methods.
1316
1655
 
1317
1656
  This class cannot be instantiated using `__init__()` (throws an error).
1318
1657
 
@@ -1328,7 +1667,7 @@ class EasyPipelineForInpainting(AutoPipelineForInpainting):
1328
1667
  def __init__(self, *args, **kwargs):
1329
1668
  # EnvironmentError is returned
1330
1669
  super().__init__()
1331
-
1670
+
1332
1671
  @classmethod
1333
1672
  @validate_hf_hub_args
1334
1673
  def from_huggingface(cls, pretrained_model_link_or_path, **kwargs):
@@ -1427,10 +1766,10 @@ class EasyPipelineForInpainting(AutoPipelineForInpainting):
1427
1766
  Examples:
1428
1767
 
1429
1768
  ```py
1430
- >>> from diffusers import AutoPipelineForText2Image
1769
+ >>> from auto_diffusers import EasyPipelineForInpainting
1431
1770
 
1432
- >>> pipeline = AutoPipelineForText2Image.from_huggingface("stable-diffusion-v1-5")
1433
- >>> image = pipeline(prompt).images[0]
1771
+ >>> pipeline = EasyPipelineForInpainting.from_huggingface("stable-diffusion-2-inpainting")
1772
+ >>> image = pipeline(prompt, image=init_image, mask_image=mask_image).images[0]
1434
1773
  ```
1435
1774
  """
1436
1775
  # Update kwargs to ensure the model is downloaded and parameters are included
@@ -1443,21 +1782,21 @@ class EasyPipelineForInpainting(AutoPipelineForInpainting):
1443
1782
  kwargs.update(_status)
1444
1783
 
1445
1784
  # Search for the model on Hugging Face and get the model status
1446
- model_status = search_huggingface(pretrained_model_link_or_path, **kwargs)
1447
- logger.warning(f"checkpoint_path: {model_status.model_status.download_url}")
1448
- checkpoint_path = model_status.model_path
1449
-
1785
+ hf_checkpoint_status = search_huggingface(pretrained_model_link_or_path, **kwargs)
1786
+ logger.warning(f"checkpoint_path: {hf_checkpoint_status.model_status.download_url}")
1787
+ checkpoint_path = hf_checkpoint_status.model_path
1788
+
1450
1789
  # Check the format of the model checkpoint
1451
- if model_status.checkpoint_format == "single_file":
1790
+ if hf_checkpoint_status.loading_method == "from_single_file":
1452
1791
  # Load the pipeline from a single file checkpoint
1453
1792
  return load_pipeline_from_single_file(
1454
1793
  pretrained_model_or_path=checkpoint_path,
1455
1794
  pipeline_mapping=SINGLE_FILE_CHECKPOINT_INPAINT_PIPELINE_MAPPING,
1456
- **kwargs
1795
+ **kwargs,
1457
1796
  )
1458
1797
  else:
1459
1798
  return cls.from_pretrained(checkpoint_path, **kwargs)
1460
-
1799
+
1461
1800
  @classmethod
1462
1801
  def from_civitai(cls, pretrained_model_link_or_path, **kwargs):
1463
1802
  r"""
@@ -1535,10 +1874,10 @@ class EasyPipelineForInpainting(AutoPipelineForInpainting):
1535
1874
  Examples:
1536
1875
 
1537
1876
  ```py
1538
- >>> from diffusers import AutoPipelineForText2Image
1877
+ >>> from auto_diffusers import EasyPipelineForInpainting
1539
1878
 
1540
- >>> pipeline = AutoPipelineForText2Image.from_huggingface("stable-diffusion-v1-5")
1541
- >>> image = pipeline(prompt).images[0]
1879
+ >>> pipeline = EasyPipelineForInpainting.from_huggingface("stable-diffusion-2-inpainting")
1880
+ >>> image = pipeline(prompt, image=init_image, mask_image=mask_image).images[0]
1542
1881
  ```
1543
1882
  """
1544
1883
  # Update kwargs to ensure the model is downloaded and parameters are included
@@ -1551,13 +1890,13 @@ class EasyPipelineForInpainting(AutoPipelineForInpainting):
1551
1890
  kwargs.update(_status)
1552
1891
 
1553
1892
  # Search for the model on Civitai and get the model status
1554
- model_status = search_civitai(pretrained_model_link_or_path, **kwargs)
1555
- logger.warning(f"checkpoint_path: {model_status.model_status.download_url}")
1556
- checkpoint_path = model_status.model_path
1893
+ checkpoint_status = search_civitai(pretrained_model_link_or_path, **kwargs)
1894
+ logger.warning(f"checkpoint_path: {checkpoint_status.model_status.site_url}")
1895
+ checkpoint_path = checkpoint_status.model_path
1557
1896
 
1558
1897
  # Load the pipeline from a single file checkpoint
1559
1898
  return load_pipeline_from_single_file(
1560
1899
  pretrained_model_or_path=checkpoint_path,
1561
1900
  pipeline_mapping=SINGLE_FILE_CHECKPOINT_INPAINT_PIPELINE_MAPPING,
1562
- **kwargs
1563
- )
1901
+ **kwargs,
1902
+ )