MCPcopy Create free account
hub / github.com/TencentARC/BrushNet / get_cached_module_file

Function get_cached_module_file

src/diffusers/utils/dynamic_modules_utils.py:199–361  ·  view source on GitHub ↗

Prepares Downloads a module from a local folder or a distant repo and returns its path inside the cached Transformers module. Args: pretrained_model_name_or_path (`str` or `os.PathLike`): This can be either: - a string, the *model id* of a pretrained mo

(
    pretrained_model_name_or_path: Union[str, os.PathLike],
    module_file: str,
    cache_dir: Optional[Union[str, os.PathLike]] = None,
    force_download: bool = False,
    resume_download: bool = False,
    proxies: Optional[Dict[str, str]] = None,
    token: Optional[Union[bool, str]] = None,
    revision: Optional[str] = None,
    local_files_only: bool = False,
)

Source from the content-addressed store, hash-verified

197
198@validate_hf_hub_args
199def get_cached_module_file(
200 pretrained_model_name_or_path: Union[str, os.PathLike],
201 module_file: str,
202 cache_dir: Optional[Union[str, os.PathLike]] = None,
203 force_download: bool = False,
204 resume_download: bool = False,
205 proxies: Optional[Dict[str, str]] = None,
206 token: Optional[Union[bool, str]] = None,
207 revision: Optional[str] = None,
208 local_files_only: bool = False,
209):
210 """
211 Prepares Downloads a module from a local folder or a distant repo and returns its path inside the cached
212 Transformers module.
213
214 Args:
215 pretrained_model_name_or_path (`str` or `os.PathLike`):
216 This can be either:
217
218 - a string, the *model id* of a pretrained model configuration hosted inside a model repo on
219 huggingface.co. Valid model ids can be located at the root-level, like `bert-base-uncased`, or namespaced
220 under a user or organization name, like `dbmdz/bert-base-german-cased`.
221 - a path to a *directory* containing a configuration file saved using the
222 [`~PreTrainedTokenizer.save_pretrained`] method, e.g., `./my_model_directory/`.
223
224 module_file (`str`):
225 The name of the module file containing the class to look for.
226 cache_dir (`str` or `os.PathLike`, *optional*):
227 Path to a directory in which a downloaded pretrained model configuration should be cached if the standard
228 cache should not be used.
229 force_download (`bool`, *optional*, defaults to `False`):
230 Whether or not to force to (re-)download the configuration files and override the cached versions if they
231 exist.
232 resume_download (`bool`, *optional*, defaults to `False`):
233 Whether or not to delete incompletely received file. Attempts to resume the download if such a file exists.
234 proxies (`Dict[str, str]`, *optional*):
235 A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128',
236 'http://hostname': 'foo.bar:4012'}.` The proxies are used on each request.
237 token (`str` or *bool*, *optional*):
238 The token to use as HTTP bearer authorization for remote files. If `True`, will use the token generated
239 when running `transformers-cli login` (stored in `~/.huggingface`).
240 revision (`str`, *optional*, defaults to `"main"`):
241 The specific model version to use. It can be a branch name, a tag name, or a commit id, since we use a
242 git-based system for storing models and other artifacts on huggingface.co, so `revision` can be any
243 identifier allowed by git.
244 local_files_only (`bool`, *optional*, defaults to `False`):
245 If `True`, will only try to load the tokenizer configuration from local files.
246
247 <Tip>
248
249 You may pass a token in `token` if you are not logged in (`huggingface-cli login`) and want to use private
250 or [gated models](https://huggingface.co/docs/hub/models-gated#gated-models).
251
252 </Tip>
253
254 Returns:
255 `str`: The path to the module inside the cache.
256 """

Callers 1

Calls 4

get_diffusers_versionsFunction · 0.85
check_importsFunction · 0.85
create_dynamic_moduleFunction · 0.85
infoMethod · 0.80

Tested by

no test coverage detected