auto-diffusers 1.5.0__tar.gz → 1.7.7__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.
- {auto_diffusers-1.5.0/src/auto_diffusers.egg-info → auto_diffusers-1.7.7}/PKG-INFO +4 -3
- {auto_diffusers-1.5.0 → auto_diffusers-1.7.7}/README.md +3 -2
- auto_diffusers-1.7.7/Version.txt +1 -0
- {auto_diffusers-1.5.0 → auto_diffusers-1.7.7}/src/auto_diffusers/__init__.py +1 -1
- {auto_diffusers-1.5.0 → auto_diffusers-1.7.7}/src/auto_diffusers/checker/memorize_config.py +39 -51
- {auto_diffusers-1.5.0 → auto_diffusers-1.7.7}/src/auto_diffusers/model_path/mix_class.py +0 -2
- {auto_diffusers-1.5.0 → auto_diffusers-1.7.7}/src/auto_diffusers/model_path/perform_path_search.py +132 -135
- {auto_diffusers-1.5.0 → auto_diffusers-1.7.7}/src/auto_diffusers/model_path/search_civitai.py +241 -160
- {auto_diffusers-1.5.0 → auto_diffusers-1.7.7}/src/auto_diffusers/model_path/search_hugface.py +301 -153
- {auto_diffusers-1.5.0 → auto_diffusers-1.7.7}/src/auto_diffusers/setup/base_config.py +7 -43
- {auto_diffusers-1.5.0 → auto_diffusers-1.7.7}/src/auto_diffusers/setup/data_class.py +23 -1
- {auto_diffusers-1.5.0 → auto_diffusers-1.7.7}/src/auto_diffusers/setup/device_config.py +0 -6
- {auto_diffusers-1.5.0 → auto_diffusers-1.7.7}/src/auto_diffusers/setup/runtime_config.py +4 -7
- {auto_diffusers-1.5.0 → auto_diffusers-1.7.7}/src/auto_diffusers/utils/hide_warning.py +1 -1
- {auto_diffusers-1.5.0 → auto_diffusers-1.7.7}/src/auto_diffusers/utils/process_bar.py +0 -4
- {auto_diffusers-1.5.0 → auto_diffusers-1.7.7}/src/auto_diffusers/utils/run_download.py +14 -18
- {auto_diffusers-1.5.0 → auto_diffusers-1.7.7/src/auto_diffusers.egg-info}/PKG-INFO +4 -3
- {auto_diffusers-1.5.0 → auto_diffusers-1.7.7}/src/auto_diffusers.egg-info/SOURCES.txt +0 -7
- auto_diffusers-1.5.0/Version.txt +0 -1
- auto_diffusers-1.5.0/src/auto_diffusers/auto_pipe/__init__.py +0 -1
- auto_diffusers-1.5.0/src/auto_diffusers/auto_pipe/auto_pipe_cls.py +0 -91
- auto_diffusers-1.5.0/src/auto_diffusers/checker/checkpoint_type.py +0 -1856
- auto_diffusers-1.5.0/src/auto_diffusers/checker/get_checkpoint_type.py +0 -140
- auto_diffusers-1.5.0/src/auto_diffusers/model_path/create_pipeline.py +0 -256
- auto_diffusers-1.5.0/src/auto_diffusers/model_path/flax_config.py +0 -70
- auto_diffusers-1.5.0/src/auto_diffusers/utils/device_config.py +0 -40
- {auto_diffusers-1.5.0 → auto_diffusers-1.7.7}/LICENSE +0 -0
- {auto_diffusers-1.5.0 → auto_diffusers-1.7.7}/MANIFEST.in +0 -0
- {auto_diffusers-1.5.0 → auto_diffusers-1.7.7}/setup.cfg +0 -0
- {auto_diffusers-1.5.0 → auto_diffusers-1.7.7}/setup.py +0 -0
- {auto_diffusers-1.5.0 → auto_diffusers-1.7.7}/src/auto_diffusers/checker/__init__.py +0 -0
- {auto_diffusers-1.5.0 → auto_diffusers-1.7.7}/src/auto_diffusers/model_path/__init__.py +0 -0
- {auto_diffusers-1.5.0 → auto_diffusers-1.7.7}/src/auto_diffusers/py.typed +0 -0
- {auto_diffusers-1.5.0 → auto_diffusers-1.7.7}/src/auto_diffusers/setup/__init__.py +0 -0
- {auto_diffusers-1.5.0 → auto_diffusers-1.7.7}/src/auto_diffusers/utils/__init__.py +0 -0
- {auto_diffusers-1.5.0 → auto_diffusers-1.7.7}/src/auto_diffusers/utils/get_custom_logger.py +0 -0
- {auto_diffusers-1.5.0 → auto_diffusers-1.7.7}/src/auto_diffusers.egg-info/dependency_links.txt +0 -0
- {auto_diffusers-1.5.0 → auto_diffusers-1.7.7}/src/auto_diffusers.egg-info/requires.txt +0 -0
- {auto_diffusers-1.5.0 → auto_diffusers-1.7.7}/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.
|
|
3
|
+
Version: 1.7.7
|
|
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
|
-
|
|
|
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
|
-
|
|
|
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.7.7
|
|
@@ -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
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
if kwargs
|
|
50
|
-
|
|
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
|
|
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
|
{auto_diffusers-1.5.0 → auto_diffusers-1.7.7}/src/auto_diffusers/model_path/perform_path_search.py
RENAMED
|
@@ -7,45 +7,47 @@ from .mix_class import Config_Mix
|
|
|
7
7
|
class Search_cls(Config_Mix):
|
|
8
8
|
def __init__(self):
|
|
9
9
|
super().__init__()
|
|
10
|
-
self.return_dict = {
|
|
11
|
-
"search_word" : "",
|
|
12
|
-
"url_or_path" : "",
|
|
13
|
-
"load_type" : "",# "" or "from_single_file" or "from_pretrained"
|
|
14
|
-
"single_file" : False,
|
|
15
|
-
"local" : False,
|
|
16
|
-
}
|
|
17
10
|
|
|
18
11
|
|
|
19
12
|
def __call__(
|
|
20
13
|
self,
|
|
21
|
-
|
|
14
|
+
search_word,
|
|
22
15
|
auto=True,
|
|
23
16
|
download=False,
|
|
24
17
|
model_type="Checkpoint",
|
|
25
18
|
model_format = "single_file",
|
|
26
19
|
branch = "main",
|
|
27
|
-
|
|
20
|
+
priority_hub = "hugface",
|
|
28
21
|
local_file_only = False,
|
|
29
|
-
|
|
22
|
+
hf_token = None,
|
|
23
|
+
civitai_token = None,
|
|
24
|
+
include_params = False,
|
|
30
25
|
):
|
|
31
|
-
|
|
26
|
+
|
|
32
27
|
self.auto = auto
|
|
33
28
|
self.download = download
|
|
34
29
|
self.model_type = model_type
|
|
35
30
|
self.branch = branch
|
|
36
31
|
self.local_file_only=local_file_only
|
|
37
|
-
self.model_format =model_format
|
|
38
|
-
self.
|
|
32
|
+
self.model_format = model_format
|
|
33
|
+
self.single_file_only = True if "single_file" == model_format else False
|
|
34
|
+
|
|
35
|
+
self.return_dict["model_status"]["search_word"] = seach_word
|
|
36
|
+
self.return_dict["model_status"]["local"] = True if download or local_file_only else False
|
|
37
|
+
|
|
38
|
+
self.hf_login(hf_token)
|
|
39
|
+
|
|
39
40
|
result = self.model_set(
|
|
40
|
-
model_select =
|
|
41
|
-
auto =
|
|
42
|
-
download =
|
|
43
|
-
model_format=model_format,
|
|
44
|
-
model_type =
|
|
45
|
-
branch =
|
|
46
|
-
|
|
47
|
-
local_file_only =
|
|
48
|
-
|
|
41
|
+
model_select = search_word,
|
|
42
|
+
auto = auto,
|
|
43
|
+
download = download,
|
|
44
|
+
model_format = model_format,
|
|
45
|
+
model_type = model_type,
|
|
46
|
+
branch = branch,
|
|
47
|
+
priority_hub = priority_hub,
|
|
48
|
+
local_file_only = local_file_only,
|
|
49
|
+
civitai_token = civitai_token,
|
|
50
|
+
include_params = include_params
|
|
49
51
|
)
|
|
50
52
|
return result
|
|
51
53
|
|
|
@@ -86,6 +88,58 @@ class Search_cls(Config_Mix):
|
|
|
86
88
|
search_list = paths
|
|
87
89
|
)
|
|
88
90
|
return search_path
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def hf_model_set(
|
|
94
|
+
self,
|
|
95
|
+
model_select,
|
|
96
|
+
auto,
|
|
97
|
+
model_format,
|
|
98
|
+
model_type,
|
|
99
|
+
download,
|
|
100
|
+
include_civitai=True
|
|
101
|
+
):
|
|
102
|
+
model_path = ""
|
|
103
|
+
model_name = self.model_name_search(
|
|
104
|
+
model_name=model_select,
|
|
105
|
+
auto_set=auto,
|
|
106
|
+
model_format=model_format,
|
|
107
|
+
include_civitai=include_civitai
|
|
108
|
+
)
|
|
109
|
+
#hf->civit
|
|
110
|
+
if not model_name == "_hf_no_model":
|
|
111
|
+
file_path = self.file_name_set(
|
|
112
|
+
model_select=model_name,
|
|
113
|
+
auto=auto,
|
|
114
|
+
model_format=model_format,
|
|
115
|
+
model_type=model_type
|
|
116
|
+
)
|
|
117
|
+
if file_path == "_DFmodel":
|
|
118
|
+
if download:
|
|
119
|
+
model_path = self.run_hf_download(
|
|
120
|
+
model_name,
|
|
121
|
+
branch=self.branch
|
|
122
|
+
)
|
|
123
|
+
else:
|
|
124
|
+
model_path = model_name
|
|
125
|
+
self.return_dict["model_path"] = model_path
|
|
126
|
+
self.return_dict["model_status"]["single_file"] = False
|
|
127
|
+
self.return_dict["load_type"] = "from_pretrained"
|
|
128
|
+
|
|
129
|
+
else:
|
|
130
|
+
hf_model_path = f"https://huggingface.co/{model_name}/blob/{self.branch}/{file_path}"
|
|
131
|
+
if download:
|
|
132
|
+
model_path = self.run_hf_download(hf_model_path)
|
|
133
|
+
else:
|
|
134
|
+
model_path = hf_model_path
|
|
135
|
+
self.return_dict["model_status"]["single_file"] = True
|
|
136
|
+
self.return_dict["load_type"] = "from_single_file"
|
|
137
|
+
self.return_dict["model_status"]["filename"] = file_path
|
|
138
|
+
|
|
139
|
+
return model_path
|
|
140
|
+
else:
|
|
141
|
+
return "_hf_no_model"
|
|
142
|
+
|
|
89
143
|
|
|
90
144
|
|
|
91
145
|
def model_set(
|
|
@@ -96,9 +150,10 @@ class Search_cls(Config_Mix):
|
|
|
96
150
|
model_format = "single_file",
|
|
97
151
|
model_type = "Checkpoint",
|
|
98
152
|
branch = "main",
|
|
99
|
-
|
|
153
|
+
priority_hub = "hugface",
|
|
100
154
|
local_file_only = False,
|
|
101
|
-
|
|
155
|
+
civitai_token = None,
|
|
156
|
+
include_params = False
|
|
102
157
|
):
|
|
103
158
|
"""
|
|
104
159
|
parameter:
|
|
@@ -114,15 +169,7 @@ class Search_cls(Config_Mix):
|
|
|
114
169
|
|
|
115
170
|
if not model_format in ["all","diffusers","single_file"]:
|
|
116
171
|
raise TypeError('The model_format is valid only for one of the following: "all","diffusers","single_file"')
|
|
117
|
-
|
|
118
|
-
self.return_dict = {
|
|
119
|
-
"search_word":model_select,
|
|
120
|
-
"url_or_path":"",
|
|
121
|
-
"load_type":"",# "" or "from_single_file" or "from_pretrained"
|
|
122
|
-
"single_file":False,
|
|
123
|
-
"local":True if download or local_file_only else False,
|
|
124
|
-
}
|
|
125
|
-
|
|
172
|
+
|
|
126
173
|
model_path = model_select
|
|
127
174
|
file_path = ""
|
|
128
175
|
if model_select in self.model_dict:
|
|
@@ -130,7 +177,7 @@ class Search_cls(Config_Mix):
|
|
|
130
177
|
_check_url = f"https://huggingface.co/{model_path_to_check}"
|
|
131
178
|
if self.is_url_valid(_check_url):
|
|
132
179
|
model_select = model_path_to_check
|
|
133
|
-
self.return_dict["
|
|
180
|
+
self.return_dict["model_path"] = _check_url
|
|
134
181
|
|
|
135
182
|
|
|
136
183
|
if local_file_only:
|
|
@@ -138,8 +185,8 @@ class Search_cls(Config_Mix):
|
|
|
138
185
|
search_word = model_select,
|
|
139
186
|
auto = auto
|
|
140
187
|
)
|
|
141
|
-
self.return_dict["single_file"] = True
|
|
142
|
-
self.return_dict["
|
|
188
|
+
self.return_dict["model_status"]["single_file"] = True
|
|
189
|
+
self.return_dict["model_path"] = model_path
|
|
143
190
|
self.return_dict["load_type"] = "from_single_file"
|
|
144
191
|
|
|
145
192
|
elif model_select.startswith("https://huggingface.co/"):
|
|
@@ -151,51 +198,57 @@ class Search_cls(Config_Mix):
|
|
|
151
198
|
else:
|
|
152
199
|
model_path = model_select
|
|
153
200
|
|
|
154
|
-
self.return_dict["single_file"] = True
|
|
155
|
-
self.return_dict["
|
|
201
|
+
self.return_dict["model_status"]["single_file"] = True
|
|
202
|
+
self.return_dict["model_path"] = model_path
|
|
156
203
|
repo,file_name = self.repo_name_or_path(model_select)
|
|
157
204
|
if file_name:
|
|
158
|
-
self.return_dict["
|
|
205
|
+
self.return_dict["model_status"]["filename"] = file_name
|
|
206
|
+
self.return_dict["model_status"]["single_file"] = True
|
|
159
207
|
self.return_dict["load_type"] = "from_single_file"
|
|
160
208
|
else:
|
|
161
|
-
self.return_dict["single_file"] = False
|
|
209
|
+
self.return_dict["model_status"]["single_file"] = False
|
|
162
210
|
self.return_dict["load_type"] = "from_pretrained"
|
|
163
211
|
|
|
164
212
|
|
|
165
213
|
elif model_select.startswith("https://civitai.com/"):
|
|
166
214
|
model_path = self.civitai_model_set(
|
|
167
|
-
|
|
215
|
+
search_word=model_select,
|
|
168
216
|
auto=auto,
|
|
169
217
|
model_type=model_type,
|
|
170
|
-
download=download
|
|
218
|
+
download=download,
|
|
219
|
+
civitai_token=civitai_token,
|
|
220
|
+
skip_error=False
|
|
171
221
|
)
|
|
222
|
+
|
|
172
223
|
|
|
173
224
|
elif os.path.isfile(model_select):
|
|
174
225
|
model_path = model_select
|
|
175
|
-
self.return_dict["
|
|
176
|
-
self.return_dict["single_file"] = True
|
|
226
|
+
self.return_dict["model_path"] = model_select
|
|
227
|
+
self.return_dict["model_status"]["single_file"] = True
|
|
177
228
|
self.return_dict["load_type"] = "from_single_file"
|
|
178
|
-
self.return_dict["local"] = True
|
|
229
|
+
self.return_dict["model_status"]["local"] = True
|
|
179
230
|
|
|
180
231
|
|
|
181
232
|
elif os.path.isdir(model_select):
|
|
182
233
|
if os.path.exists(os.path.join(model_select,self.Config_file)):
|
|
183
234
|
model_path = model_select
|
|
184
|
-
self.return_dict["
|
|
185
|
-
self.return_dict["single_file"] = False
|
|
235
|
+
self.return_dict["model_path"] = model_select
|
|
236
|
+
self.return_dict["model_status"]["single_file"] = False
|
|
186
237
|
self.return_dict["load_type"] = "from_pretrained"
|
|
187
|
-
self.return_dict["local"] = True
|
|
238
|
+
self.return_dict["model_status"]["local"] = True
|
|
188
239
|
else:
|
|
189
240
|
raise FileNotFoundError(f"model_index.json not found in {model_select}")
|
|
190
241
|
|
|
191
242
|
elif model_select.count("/") == 1:
|
|
243
|
+
creator_name, repo_name = model_select.split("/")
|
|
244
|
+
|
|
192
245
|
if auto and self.diffusers_model_check(model_select):
|
|
193
246
|
if download:
|
|
194
247
|
model_path = self.run_hf_download(model_select)
|
|
195
|
-
self.return_dict["single_file"] = False
|
|
248
|
+
self.return_dict["model_status"]["single_file"] = False
|
|
196
249
|
else:
|
|
197
250
|
model_path = model_select
|
|
198
|
-
self.return_dict["single_file"] = False
|
|
251
|
+
self.return_dict["model_status"]["single_file"] = False
|
|
199
252
|
self.return_dict["load_type"] = "from_pretrained"
|
|
200
253
|
|
|
201
254
|
elif auto and (not self.hf_model_check(model_select)):
|
|
@@ -210,8 +263,7 @@ class Search_cls(Config_Mix):
|
|
|
210
263
|
else:
|
|
211
264
|
model_path = model_select
|
|
212
265
|
|
|
213
|
-
self.return_dict["
|
|
214
|
-
self.return_dict["single_file"] = False
|
|
266
|
+
self.return_dict["model_status"]["single_file"] = False
|
|
215
267
|
self.return_dict["load_type"] = "from_pretrained"
|
|
216
268
|
|
|
217
269
|
else:
|
|
@@ -221,117 +273,62 @@ class Search_cls(Config_Mix):
|
|
|
221
273
|
model_path = self.run_hf_download(hf_model_path)
|
|
222
274
|
else:
|
|
223
275
|
model_path = hf_model_path
|
|
224
|
-
|
|
225
|
-
self.return_dict["
|
|
276
|
+
|
|
277
|
+
self.return_dict["model_status"]["filename"] = file_path
|
|
278
|
+
self.return_dict["model_status"]["single_file"] = True
|
|
226
279
|
self.return_dict["load_type"] = "from_single_file"
|
|
227
|
-
|
|
280
|
+
|
|
281
|
+
self.return_dict["repo_status"]["repo_name"] = repo_name
|
|
282
|
+
|
|
228
283
|
else:
|
|
229
|
-
if
|
|
284
|
+
if priority_hub == "hugface":
|
|
230
285
|
model_path = self.hf_model_set(
|
|
231
286
|
model_select=model_select,
|
|
232
287
|
auto=auto,
|
|
233
288
|
model_format=model_format,
|
|
234
289
|
model_type=model_type,
|
|
235
|
-
download=download
|
|
290
|
+
download=download,
|
|
291
|
+
include_civitai=True
|
|
236
292
|
)
|
|
237
293
|
if model_path == "_hf_no_model":
|
|
238
294
|
model_path = self.civitai_model_set(
|
|
239
|
-
|
|
295
|
+
search_word=model_select,
|
|
240
296
|
auto=auto,
|
|
241
297
|
model_type=model_type,
|
|
242
|
-
download=download
|
|
298
|
+
download=download,
|
|
299
|
+
civitai_token=civitai_token,
|
|
300
|
+
include_hugface=False
|
|
243
301
|
)
|
|
244
|
-
if model_path
|
|
302
|
+
if not model_path:
|
|
245
303
|
raise ValueError("No models matching the criteria were found.")
|
|
246
304
|
|
|
247
305
|
else:
|
|
248
306
|
model_path = self.civitai_model_set(
|
|
249
|
-
|
|
307
|
+
search_word=model_select,
|
|
250
308
|
auto=auto,
|
|
251
309
|
model_type=model_type,
|
|
252
|
-
download=download
|
|
310
|
+
download=download,
|
|
311
|
+
civitai_token=civitai_token,
|
|
312
|
+
include_hugface=True
|
|
253
313
|
)
|
|
254
|
-
if model_path
|
|
314
|
+
if not model_path:
|
|
255
315
|
model_path = self.hf_model_set(
|
|
256
316
|
model_select = model_select,
|
|
257
317
|
auto = auto,
|
|
258
318
|
model_format=model_format,
|
|
259
319
|
model_type=model_type,
|
|
260
|
-
download=download
|
|
320
|
+
download=download,
|
|
321
|
+
include_civitai=False
|
|
261
322
|
)
|
|
262
323
|
if model_path == "_hf_no_model":
|
|
263
324
|
raise ValueError("No models matching the criteria were found.")
|
|
264
325
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
326
|
+
self.return_dict["model_path"] = 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
|
|
269
333
|
else:
|
|
270
|
-
return [model_path, self.return_dict]
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
def hf_model_set(
|
|
274
|
-
self,
|
|
275
|
-
model_select,
|
|
276
|
-
auto,
|
|
277
|
-
model_format,
|
|
278
|
-
model_type,
|
|
279
|
-
download
|
|
280
|
-
):
|
|
281
|
-
model_path = ""
|
|
282
|
-
model_name = self.model_name_search(
|
|
283
|
-
model_name=model_select,
|
|
284
|
-
auto_set=auto,
|
|
285
|
-
model_format=model_format)
|
|
286
|
-
#hf->civit
|
|
287
|
-
if not model_name == "_hf_no_model":
|
|
288
|
-
file_path = self.file_name_set(
|
|
289
|
-
model_select=model_name,
|
|
290
|
-
auto=auto,
|
|
291
|
-
model_format=model_format,
|
|
292
|
-
model_type=model_type)
|
|
293
|
-
if file_path == "_DFmodel":
|
|
294
|
-
if download:
|
|
295
|
-
model_path = self.run_hf_download(model_name,branch=self.branch)
|
|
296
|
-
else:
|
|
297
|
-
model_path = model_name
|
|
298
|
-
self.return_dict["single_file"] = False
|
|
299
|
-
self.return_dict["load_type"] = "from_pretrained"
|
|
300
|
-
|
|
301
|
-
else:
|
|
302
|
-
hf_model_path = f"https://huggingface.co/{model_name}/blob/{self.branch}/{file_path}"
|
|
303
|
-
if download:
|
|
304
|
-
model_path = self.run_hf_download(hf_model_path)
|
|
305
|
-
else:
|
|
306
|
-
model_path = hf_model_path
|
|
307
|
-
self.return_dict["single_file"] = True
|
|
308
|
-
self.return_dict["load_type"] = "from_single_file"
|
|
309
|
-
|
|
310
334
|
return model_path
|
|
311
|
-
else:
|
|
312
|
-
return "_hf_no_model"
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
def civitai_model_set(
|
|
316
|
-
self,
|
|
317
|
-
model_select,
|
|
318
|
-
auto,
|
|
319
|
-
model_type,
|
|
320
|
-
download
|
|
321
|
-
):
|
|
322
|
-
|
|
323
|
-
model_url, model_path = self.civitai_download(
|
|
324
|
-
model_select,
|
|
325
|
-
auto,
|
|
326
|
-
model_type,
|
|
327
|
-
download=download)
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
self.return_dict["single_file"] = True
|
|
331
|
-
self.return_dict["url_or_path"] = model_url
|
|
332
|
-
|
|
333
|
-
if download:
|
|
334
|
-
self.return_dict["load_type"] = "from_single_file"
|
|
335
|
-
else:
|
|
336
|
-
self.return_dict["load_type"] = ""
|
|
337
|
-
return model_path
|