|  | 
| 22 | 22 | import sys | 
| 23 | 23 | from dataclasses import dataclass | 
| 24 | 24 | from pathlib import Path | 
| 25 |  | -from typing import (Any, Callable, Dict, List, Optional, Union, get_args, | 
| 26 |  | -                    get_origin) | 
|  | 25 | +from typing import Any, Callable, Dict, List, Optional, Union, get_args, get_origin | 
| 27 | 26 | 
 | 
| 28 | 27 | import numpy as np | 
| 29 | 28 | import PIL.Image | 
| 30 | 29 | import requests | 
| 31 | 30 | import torch | 
| 32 |  | -from huggingface_hub import (DDUFEntry, ModelCard, create_repo, | 
| 33 |  | -                             hf_hub_download, model_info, read_dduf_file, | 
| 34 |  | -                             snapshot_download) | 
|  | 31 | +from huggingface_hub import ( | 
|  | 32 | +    DDUFEntry, | 
|  | 33 | +    ModelCard, | 
|  | 34 | +    create_repo, | 
|  | 35 | +    hf_hub_download, | 
|  | 36 | +    model_info, | 
|  | 37 | +    read_dduf_file, | 
|  | 38 | +    snapshot_download, | 
|  | 39 | +) | 
| 35 | 40 | from huggingface_hub.utils import OfflineModeIsEnabled, validate_hf_hub_args | 
| 36 | 41 | from packaging import version | 
| 37 | 42 | from requests.exceptions import HTTPError | 
|  | 
| 45 | 50 | from ..models.modeling_utils import _LOW_CPU_MEM_USAGE_DEFAULT, ModelMixin | 
| 46 | 51 | from ..quantizers.bitsandbytes.utils import _check_bnb_status | 
| 47 | 52 | from ..schedulers.scheduling_utils import SCHEDULER_CONFIG_NAME | 
| 48 |  | -from ..utils import (CONFIG_NAME, DEPRECATED_REVISION_ARGS, BaseOutput, | 
| 49 |  | -                     PushToHubMixin, is_accelerate_available, | 
| 50 |  | -                     is_accelerate_version, is_torch_npu_available, | 
| 51 |  | -                     is_torch_version, is_transformers_version, logging, | 
| 52 |  | -                     numpy_to_pil) | 
| 53 |  | -from ..utils.hub_utils import (_check_legacy_sharding_variant_format, | 
| 54 |  | -                               load_or_create_model_card, populate_model_card) | 
|  | 53 | +from ..utils import ( | 
|  | 54 | +    CONFIG_NAME, | 
|  | 55 | +    DEPRECATED_REVISION_ARGS, | 
|  | 56 | +    BaseOutput, | 
|  | 57 | +    PushToHubMixin, | 
|  | 58 | +    is_accelerate_available, | 
|  | 59 | +    is_accelerate_version, | 
|  | 60 | +    is_torch_npu_available, | 
|  | 61 | +    is_torch_version, | 
|  | 62 | +    is_transformers_version, | 
|  | 63 | +    logging, | 
|  | 64 | +    numpy_to_pil, | 
|  | 65 | +) | 
|  | 66 | +from ..utils.hub_utils import _check_legacy_sharding_variant_format, load_or_create_model_card, populate_model_card | 
| 55 | 67 | from ..utils.torch_utils import is_compiled_module | 
| 56 | 68 | 
 | 
|  | 69 | + | 
| 57 | 70 | if is_torch_npu_available(): | 
| 58 | 71 |     import torch_npu  # noqa: F401 | 
| 59 | 72 | 
 | 
| 60 | 73 | from .pipeline_loading_utils import ( | 
| 61 |  | -    ALL_IMPORTABLE_CLASSES, CONNECTED_PIPES_KEYS, CUSTOM_PIPELINE_FILE_NAME, | 
| 62 |  | -    LOADABLE_CLASSES, _download_dduf_file, _fetch_class_library_tuple, | 
| 63 |  | -    _get_custom_components_and_folders, _get_custom_pipeline_class, | 
| 64 |  | -    _get_final_device_map, _get_ignore_patterns, _get_pipeline_class, | 
| 65 |  | -    _identify_model_variants, _maybe_raise_error_for_incorrect_transformers, | 
| 66 |  | -    _maybe_raise_warning_for_inpainting, _resolve_custom_pipeline_and_cls, | 
| 67 |  | -    _unwrap_model, _update_init_kwargs_with_connected_pipeline, | 
| 68 |  | -    filter_model_files, load_sub_model, maybe_raise_or_warn, | 
| 69 |  | -    variant_compatible_siblings, warn_deprecated_model_variant) | 
|  | 74 | +    ALL_IMPORTABLE_CLASSES, | 
|  | 75 | +    CONNECTED_PIPES_KEYS, | 
|  | 76 | +    CUSTOM_PIPELINE_FILE_NAME, | 
|  | 77 | +    LOADABLE_CLASSES, | 
|  | 78 | +    _download_dduf_file, | 
|  | 79 | +    _fetch_class_library_tuple, | 
|  | 80 | +    _get_custom_components_and_folders, | 
|  | 81 | +    _get_custom_pipeline_class, | 
|  | 82 | +    _get_final_device_map, | 
|  | 83 | +    _get_ignore_patterns, | 
|  | 84 | +    _get_pipeline_class, | 
|  | 85 | +    _identify_model_variants, | 
|  | 86 | +    _maybe_raise_error_for_incorrect_transformers, | 
|  | 87 | +    _maybe_raise_warning_for_inpainting, | 
|  | 88 | +    _resolve_custom_pipeline_and_cls, | 
|  | 89 | +    _unwrap_model, | 
|  | 90 | +    _update_init_kwargs_with_connected_pipeline, | 
|  | 91 | +    filter_model_files, | 
|  | 92 | +    load_sub_model, | 
|  | 93 | +    maybe_raise_or_warn, | 
|  | 94 | +    variant_compatible_siblings, | 
|  | 95 | +    warn_deprecated_model_variant, | 
|  | 96 | +) | 
|  | 97 | + | 
| 70 | 98 | 
 | 
| 71 | 99 | if is_accelerate_available(): | 
| 72 | 100 |     import accelerate | 
|  | 
0 commit comments