auto-diffusers 1.6.0__tar.gz → 1.8.0__tar.gz

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.
Files changed (39) hide show
  1. {auto_diffusers-1.6.0/src/auto_diffusers.egg-info → auto_diffusers-1.8.0}/PKG-INFO +4 -3
  2. {auto_diffusers-1.6.0 → auto_diffusers-1.8.0}/README.md +3 -2
  3. auto_diffusers-1.8.0/Version.txt +1 -0
  4. {auto_diffusers-1.6.0 → auto_diffusers-1.8.0}/src/auto_diffusers/__init__.py +1 -1
  5. {auto_diffusers-1.6.0 → auto_diffusers-1.8.0}/src/auto_diffusers/checker/memorize_config.py +39 -51
  6. {auto_diffusers-1.6.0 → auto_diffusers-1.8.0}/src/auto_diffusers/model_path/mix_class.py +0 -2
  7. {auto_diffusers-1.6.0 → auto_diffusers-1.8.0}/src/auto_diffusers/model_path/perform_path_search.py +55 -60
  8. {auto_diffusers-1.6.0 → auto_diffusers-1.8.0}/src/auto_diffusers/model_path/search_civitai.py +205 -168
  9. {auto_diffusers-1.6.0 → auto_diffusers-1.8.0}/src/auto_diffusers/model_path/search_hugface.py +304 -150
  10. {auto_diffusers-1.6.0 → auto_diffusers-1.8.0}/src/auto_diffusers/setup/base_config.py +7 -4
  11. {auto_diffusers-1.6.0 → auto_diffusers-1.8.0}/src/auto_diffusers/setup/data_class.py +3 -1
  12. {auto_diffusers-1.6.0 → auto_diffusers-1.8.0}/src/auto_diffusers/setup/device_config.py +0 -6
  13. {auto_diffusers-1.6.0 → auto_diffusers-1.8.0}/src/auto_diffusers/setup/runtime_config.py +4 -7
  14. {auto_diffusers-1.6.0 → auto_diffusers-1.8.0}/src/auto_diffusers/utils/hide_warning.py +1 -1
  15. {auto_diffusers-1.6.0 → auto_diffusers-1.8.0}/src/auto_diffusers/utils/process_bar.py +0 -4
  16. {auto_diffusers-1.6.0 → auto_diffusers-1.8.0}/src/auto_diffusers/utils/run_download.py +14 -18
  17. {auto_diffusers-1.6.0 → auto_diffusers-1.8.0/src/auto_diffusers.egg-info}/PKG-INFO +4 -3
  18. {auto_diffusers-1.6.0 → auto_diffusers-1.8.0}/src/auto_diffusers.egg-info/SOURCES.txt +0 -7
  19. auto_diffusers-1.6.0/Version.txt +0 -1
  20. auto_diffusers-1.6.0/src/auto_diffusers/auto_pipe/__init__.py +0 -1
  21. auto_diffusers-1.6.0/src/auto_diffusers/auto_pipe/auto_pipe_cls.py +0 -91
  22. auto_diffusers-1.6.0/src/auto_diffusers/checker/checkpoint_type.py +0 -1856
  23. auto_diffusers-1.6.0/src/auto_diffusers/checker/get_checkpoint_type.py +0 -140
  24. auto_diffusers-1.6.0/src/auto_diffusers/model_path/create_pipeline.py +0 -256
  25. auto_diffusers-1.6.0/src/auto_diffusers/model_path/flax_config.py +0 -70
  26. auto_diffusers-1.6.0/src/auto_diffusers/utils/device_config.py +0 -40
  27. {auto_diffusers-1.6.0 → auto_diffusers-1.8.0}/LICENSE +0 -0
  28. {auto_diffusers-1.6.0 → auto_diffusers-1.8.0}/MANIFEST.in +0 -0
  29. {auto_diffusers-1.6.0 → auto_diffusers-1.8.0}/setup.cfg +0 -0
  30. {auto_diffusers-1.6.0 → auto_diffusers-1.8.0}/setup.py +0 -0
  31. {auto_diffusers-1.6.0 → auto_diffusers-1.8.0}/src/auto_diffusers/checker/__init__.py +0 -0
  32. {auto_diffusers-1.6.0 → auto_diffusers-1.8.0}/src/auto_diffusers/model_path/__init__.py +0 -0
  33. {auto_diffusers-1.6.0 → auto_diffusers-1.8.0}/src/auto_diffusers/py.typed +0 -0
  34. {auto_diffusers-1.6.0 → auto_diffusers-1.8.0}/src/auto_diffusers/setup/__init__.py +0 -0
  35. {auto_diffusers-1.6.0 → auto_diffusers-1.8.0}/src/auto_diffusers/utils/__init__.py +0 -0
  36. {auto_diffusers-1.6.0 → auto_diffusers-1.8.0}/src/auto_diffusers/utils/get_custom_logger.py +0 -0
  37. {auto_diffusers-1.6.0 → auto_diffusers-1.8.0}/src/auto_diffusers.egg-info/dependency_links.txt +0 -0
  38. {auto_diffusers-1.6.0 → auto_diffusers-1.8.0}/src/auto_diffusers.egg-info/requires.txt +0 -0
  39. {auto_diffusers-1.6.0 → auto_diffusers-1.8.0}/src/auto_diffusers.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: auto_diffusers
3
- Version: 1.6.0
3
+ Version: 1.8.0
4
4
  Summary: Customized diffusers with model search and other functions.
5
5
  Home-page: https://github.com/suzukimain/auto_diffusers
6
6
  Author: suzukimain
@@ -119,10 +119,11 @@ display(image)
119
119
  | download | bool | False | ー | Returns the path where the file was downloaded. |
120
120
  | model_format | string | "single_file" | `all`,<br> `diffusers`,<br> `single_file`| Specifies the format of the model. [Details](#model_format) |
121
121
  | model_type | string | "Checkpoint"| `Checkpoint`,<br>`TextualInversion`,<br>`Hypernetwork`,<br>`AestheticGradient`,<br>`LORA`,<br>`Controlnet`,<br>`Poses` | Valid only in Civitai. |
122
- | return_path | bool | True | ー | Returns only the path or `[model_path, status_dict]`. |
122
+ | include_params | bool | False | ー | Returns the model path or a dictionary with parameters. |
123
123
  | branch | string | "main" | ー | Specify the branches of huggingface and civitai. |
124
124
  | local_file_only| bool | False | ー | Search local folders only.<br>**In the case of `auto`, files with names similar to `search_word` will be given priority.** |
125
-
125
+ | hf_token | string | None | ー | Token used for authentication with Hugging Face. |
126
+ | civitai_token | string | None | ー | Token used for authentication with Civitai. |
126
127
 
127
128
 
128
129
  <a id="search-word"></a>
@@ -88,10 +88,11 @@ display(image)
88
88
  | download | bool | False | ー | Returns the path where the file was downloaded. |
89
89
  | model_format | string | "single_file" | `all`,<br> `diffusers`,<br> `single_file`| Specifies the format of the model. [Details](#model_format) |
90
90
  | model_type | string | "Checkpoint"| `Checkpoint`,<br>`TextualInversion`,<br>`Hypernetwork`,<br>`AestheticGradient`,<br>`LORA`,<br>`Controlnet`,<br>`Poses` | Valid only in Civitai. |
91
- | return_path | bool | True | ー | Returns only the path or `[model_path, status_dict]`. |
91
+ | include_params | bool | False | ー | Returns the model path or a dictionary with parameters. |
92
92
  | branch | string | "main" | ー | Specify the branches of huggingface and civitai. |
93
93
  | local_file_only| bool | False | ー | Search local folders only.<br>**In the case of `auto`, files with names similar to `search_word` will be given priority.** |
94
-
94
+ | hf_token | string | None | ー | Token used for authentication with Hugging Face. |
95
+ | civitai_token | string | None | ー | Token used for authentication with Civitai. |
95
96
 
96
97
 
97
98
  <a id="search-word"></a>
@@ -0,0 +1 @@
1
+ 1.8.0
@@ -1,6 +1,6 @@
1
1
  from .setup.base_config import Basic_config
2
2
  from .utils.run_download import download
3
- from .checker.get_checkpoint_type import checkpoint_type
4
3
  from .model_path.perform_path_search import Search_cls
5
4
 
5
+ # `run_search` is obsolete. Please use `model_search` instead.
6
6
  model_search = Search_cls()
@@ -8,73 +8,61 @@ class config_check:
8
8
  pass
9
9
 
10
10
 
11
- def get_json_dict(self):
12
- """Retrieve the JSON dictionary from the config file."""
13
- config_dict = {}
14
- if os.path.isfile(self.base_config_json):
15
- try:
16
- with open(self.base_config_json, "r") as basic_json:
17
- config_dict = json.load(basic_json)
18
- except json.JSONDecodeError:
19
- pass
20
- return config_dict
21
-
22
-
23
- def update_json_dict(self, key, value):
24
- """Update the JSON dictionary with a new key-value pair."""
25
- basic_json_dict = self.get_json_dict()
26
- basic_json_dict[key] = value
27
- with open(self.base_config_json, "w") as json_file:
28
- json.dump(basic_json_dict, json_file, indent=4)
29
-
30
-
31
- def check_func_hist(self,*return_key, **kwargs):
11
+ def check_func_hist(
12
+ self,
13
+ key,
14
+ **kwargs
15
+ ):
32
16
  """
33
17
  Check and optionally update the history of a given element.
34
18
 
35
19
  Args:
36
- *return_key (str): Variable for which to get the history.
20
+ key (str): Specific key to look up in the dictionary.
37
21
  **kwargs: Keyword arguments for additional options.
38
22
  - update (bool): Whether to update the dictionary. Default is True.
39
23
  - return_value (bool): Whether to return the element value. Default is False.
40
- - key (str): Specific key to look up in the dictionary.
41
24
  - value (Any): Value to be matched or updated in the dictionary.
25
+ - missing_value (Any): Returns the value if it does not exist.
42
26
 
43
27
  Returns:
44
28
  Any: The historical value if `return_value` is True, or a boolean indicating
45
29
  if the value matches the historical value.
46
30
  """
47
- update = kwargs.pop("update", True)
48
- return_value = kwargs.pop("return_value", False)
49
- if kwargs:
50
- if "key" in kwargs:
51
- key = kwargs["key"]
52
- if "value" in kwargs:
53
- value = kwargs["value"]
54
- else:
55
- value = None
56
- update = False
57
- return_value = True
58
- else:
59
- key, value = next(iter(kwargs.items()))
60
- elif return_key:
61
- key, value = return_key[0], None
62
- update = False
63
- return_value = True
64
- else:
65
- raise TypeError("Missing 'key' argument.")
66
-
67
- basic_json_dict = self.get_json_dict()
68
- hist_value = basic_json_dict.get(key)
69
- if hist_value == value:
70
- value_match = True
71
- else:
72
- value_match = False
31
+ value = kwargs.pop("value",None)
32
+ update = kwargs.pop("update", False if value is None else True)
33
+ return_value = kwargs.pop("return_value", True if "value" in kwargs else False)
34
+ missing_value = kwargs.pop("missing_value", None)
73
35
 
36
+ hist_value = self.get_json_dict().get(key,None)
74
37
  if update:
75
38
  self.update_json_dict(key, value)
76
39
 
77
40
  if return_value:
78
- return hist_value
41
+ return hist_value or missing_value
79
42
  else:
80
- return value_match
43
+ return hist_value == value
44
+
45
+
46
+ def get_json_dict(self) -> dict:
47
+ """
48
+ Retrieve the JSON dictionary from the config file.
49
+ """
50
+ config_dict = {}
51
+ if os.path.isfile(self.base_config_json):
52
+ try:
53
+ with open(self.base_config_json, "r") as basic_json:
54
+ config_dict = json.load(basic_json)
55
+ except json.JSONDecodeError:
56
+ pass
57
+ return config_dict
58
+
59
+
60
+ def update_json_dict(self, key, value):
61
+ """Update the JSON dictionary with a new key-value pair."""
62
+ basic_json_dict = self.get_json_dict()
63
+ basic_json_dict[key] = value
64
+ with open(self.base_config_json, "w") as json_file:
65
+ json.dump(basic_json_dict, json_file, indent=4)
66
+
67
+
68
+
@@ -1,13 +1,11 @@
1
1
  from .search_hugface import Huggingface
2
2
  from .search_civitai import Civitai
3
- from .flax_config import With_Flax
4
3
  from ..setup.base_config import Basic_config
5
4
 
6
5
 
7
6
  class Config_Mix(
8
7
  Huggingface,
9
8
  Civitai,
10
- With_Flax,
11
9
  Basic_config
12
10
  ):
13
11
  #fix MMO error
@@ -11,40 +11,43 @@ class Search_cls(Config_Mix):
11
11
 
12
12
  def __call__(
13
13
  self,
14
- seach_word,
14
+ search_word,
15
15
  auto=True,
16
16
  download=False,
17
17
  model_type="Checkpoint",
18
18
  model_format = "single_file",
19
19
  branch = "main",
20
- priority = "hugface",
20
+ priority_hub = "hugface",
21
21
  local_file_only = False,
22
- return_path = True,
23
- exclude_untested_model = False
22
+ hf_token = None,
23
+ civitai_token = None,
24
+ include_params = False,
24
25
  ):
25
- self.seach_word = seach_word
26
+
26
27
  self.auto = auto
27
28
  self.download = download
28
29
  self.model_type = model_type
29
30
  self.branch = branch
30
31
  self.local_file_only=local_file_only
31
- self.model_format =model_format
32
- self.return_path = return_path
33
- self.exclude_untested_model = exclude_untested_model
32
+ self.model_format = model_format
33
+ self.single_file_only = True if "single_file" == model_format else False
34
34
 
35
- self.return_dict["model_status"]["search_word"] = seach_word
35
+ self.return_dict["model_status"]["search_word"] = search_word
36
36
  self.return_dict["model_status"]["local"] = True if download or local_file_only else False
37
37
 
38
+ self.hf_login(hf_token)
39
+
38
40
  result = self.model_set(
39
- model_select = seach_word,
41
+ model_select = search_word,
40
42
  auto = auto,
41
43
  download = download,
42
44
  model_format = model_format,
43
45
  model_type = model_type,
44
46
  branch = branch,
45
- priority = priority,
47
+ priority_hub = priority_hub,
46
48
  local_file_only = local_file_only,
47
- return_path = return_path
49
+ civitai_token = civitai_token,
50
+ include_params = include_params
48
51
  )
49
52
  return result
50
53
 
@@ -86,29 +89,37 @@ class Search_cls(Config_Mix):
86
89
  )
87
90
  return search_path
88
91
 
92
+
89
93
  def hf_model_set(
90
94
  self,
91
95
  model_select,
92
96
  auto,
93
97
  model_format,
94
98
  model_type,
95
- download
99
+ download,
100
+ include_civitai=True
96
101
  ):
97
102
  model_path = ""
98
103
  model_name = self.model_name_search(
99
104
  model_name=model_select,
100
105
  auto_set=auto,
101
- model_format=model_format)
106
+ model_format=model_format,
107
+ include_civitai=include_civitai
108
+ )
102
109
  #hf->civit
103
110
  if not model_name == "_hf_no_model":
104
111
  file_path = self.file_name_set(
105
112
  model_select=model_name,
106
113
  auto=auto,
107
114
  model_format=model_format,
108
- model_type=model_type)
115
+ model_type=model_type
116
+ )
109
117
  if file_path == "_DFmodel":
110
118
  if download:
111
- model_path = self.run_hf_download(model_name,branch=self.branch)
119
+ model_path = self.run_hf_download(
120
+ model_name,
121
+ branch=self.branch
122
+ )
112
123
  else:
113
124
  model_path = model_name
114
125
  self.return_dict["model_path"] = model_path
@@ -128,32 +139,7 @@ class Search_cls(Config_Mix):
128
139
  return model_path
129
140
  else:
130
141
  return "_hf_no_model"
131
-
132
-
133
- def civitai_model_set(
134
- self,
135
- model_select,
136
- auto,
137
- model_type,
138
- download,
139
- skip_error=True
140
- ):
141
-
142
- model_path = self.civitai_download(
143
- model_select,
144
- auto,
145
- model_type,
146
- download=download)
147
-
148
-
149
- self.return_dict["model_status"]["single_file"] = True
150
- if (not skip_error) and (not model_path):
151
- raise ValueError("No models were found in civitai.")
152
- elif download:
153
- self.return_dict["load_type"] = "from_single_file"
154
- else:
155
- self.return_dict["load_type"] = ""
156
- return model_path
142
+
157
143
 
158
144
 
159
145
  def model_set(
@@ -164,9 +150,10 @@ class Search_cls(Config_Mix):
164
150
  model_format = "single_file",
165
151
  model_type = "Checkpoint",
166
152
  branch = "main",
167
- priority = "hugface",
153
+ priority_hub = "hugface",
168
154
  local_file_only = False,
169
- return_path = True
155
+ civitai_token = None,
156
+ include_params = False
170
157
  ):
171
158
  """
172
159
  parameter:
@@ -182,9 +169,7 @@ class Search_cls(Config_Mix):
182
169
 
183
170
  if not model_format in ["all","diffusers","single_file"]:
184
171
  raise TypeError('The model_format is valid only for one of the following: "all","diffusers","single_file"')
185
-
186
-
187
-
172
+
188
173
  model_path = model_select
189
174
  file_path = ""
190
175
  if model_select in self.model_dict:
@@ -227,12 +212,14 @@ class Search_cls(Config_Mix):
227
212
 
228
213
  elif model_select.startswith("https://civitai.com/"):
229
214
  model_path = self.civitai_model_set(
230
- model_select=model_select,
215
+ search_word=model_select,
231
216
  auto=auto,
232
217
  model_type=model_type,
233
218
  download=download,
219
+ civitai_token=civitai_token,
234
220
  skip_error=False
235
221
  )
222
+
236
223
 
237
224
  elif os.path.isfile(model_select):
238
225
  model_path = model_select
@@ -294,30 +281,35 @@ class Search_cls(Config_Mix):
294
281
  self.return_dict["repo_status"]["repo_name"] = repo_name
295
282
 
296
283
  else:
297
- if priority == "hugface":
284
+ if priority_hub == "hugface":
298
285
  model_path = self.hf_model_set(
299
286
  model_select=model_select,
300
287
  auto=auto,
301
288
  model_format=model_format,
302
289
  model_type=model_type,
303
- download=download
290
+ download=download,
291
+ include_civitai=True
304
292
  )
305
293
  if model_path == "_hf_no_model":
306
294
  model_path = self.civitai_model_set(
307
- model_select=model_select,
295
+ search_word=model_select,
308
296
  auto=auto,
309
297
  model_type=model_type,
310
- download=download
298
+ download=download,
299
+ civitai_token=civitai_token,
300
+ include_hugface=False
311
301
  )
312
302
  if not model_path:
313
303
  raise ValueError("No models matching the criteria were found.")
314
304
 
315
305
  else:
316
306
  model_path = self.civitai_model_set(
317
- model_select=model_select,
307
+ search_word=model_select,
318
308
  auto=auto,
319
309
  model_type=model_type,
320
- download=download
310
+ download=download,
311
+ civitai_token=civitai_token,
312
+ include_hugface=True
321
313
  )
322
314
  if not model_path:
323
315
  model_path = self.hf_model_set(
@@ -325,15 +317,18 @@ class Search_cls(Config_Mix):
325
317
  auto = auto,
326
318
  model_format=model_format,
327
319
  model_type=model_type,
328
- download=download
320
+ download=download,
321
+ include_civitai=False
329
322
  )
330
323
  if model_path == "_hf_no_model":
331
324
  raise ValueError("No models matching the criteria were found.")
332
325
 
333
326
  self.return_dict["model_path"] = model_path
334
- #It is not called, but should not be deleted because it is updating the dictionary.
335
- update_model_path = self.check_func_hist(key="model_path",value=model_path)
336
- if return_path:
337
- return model_path
327
+ self.update_json_dict(
328
+ key = "model_path",
329
+ value = model_path
330
+ )
331
+ if include_params:
332
+ return self.return_dict
338
333
  else:
339
- return self.return_dict
334
+ return model_path