huggingface-hub 0.23.3__tar.gz → 0.23.4__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.
Potentially problematic release.
This version of huggingface-hub might be problematic. Click here for more details.
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/PKG-INFO +1 -1
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/__init__.py +1 -1
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/hub_mixin.py +92 -41
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/repocard_data.py +38 -26
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/utils/__init__.py +1 -1
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/utils/_typing.py +26 -1
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub.egg-info/PKG-INFO +1 -1
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/LICENSE +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/MANIFEST.in +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/README.md +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/pyproject.toml +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/setup.cfg +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/setup.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/_commit_api.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/_commit_scheduler.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/_inference_endpoints.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/_local_folder.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/_login.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/_multi_commits.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/_snapshot_download.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/_space_api.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/_tensorboard_logger.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/_webhooks_payload.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/_webhooks_server.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/commands/__init__.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/commands/_cli_utils.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/commands/delete_cache.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/commands/download.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/commands/env.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/commands/huggingface_cli.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/commands/lfs.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/commands/scan_cache.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/commands/tag.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/commands/upload.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/commands/user.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/community.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/constants.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/errors.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/fastai_utils.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/file_download.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/hf_api.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/hf_file_system.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/inference/__init__.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/inference/_client.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/inference/_common.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/inference/_generated/__init__.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/inference/_generated/_async_client.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/inference/_generated/types/__init__.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/inference/_generated/types/audio_classification.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/inference/_generated/types/audio_to_audio.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/inference/_generated/types/automatic_speech_recognition.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/inference/_generated/types/base.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/inference/_generated/types/chat_completion.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/inference/_generated/types/depth_estimation.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/inference/_generated/types/document_question_answering.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/inference/_generated/types/feature_extraction.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/inference/_generated/types/fill_mask.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/inference/_generated/types/image_classification.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/inference/_generated/types/image_segmentation.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/inference/_generated/types/image_to_image.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/inference/_generated/types/image_to_text.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/inference/_generated/types/object_detection.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/inference/_generated/types/question_answering.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/inference/_generated/types/sentence_similarity.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/inference/_generated/types/summarization.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/inference/_generated/types/table_question_answering.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/inference/_generated/types/text2text_generation.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/inference/_generated/types/text_classification.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/inference/_generated/types/text_generation.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/inference/_generated/types/text_to_audio.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/inference/_generated/types/text_to_image.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/inference/_generated/types/token_classification.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/inference/_generated/types/translation.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/inference/_generated/types/video_classification.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/inference/_generated/types/visual_question_answering.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/inference/_generated/types/zero_shot_classification.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/inference/_generated/types/zero_shot_image_classification.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/inference/_generated/types/zero_shot_object_detection.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/inference/_templating.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/inference/_types.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/inference_api.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/keras_mixin.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/lfs.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/repocard.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/repository.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/serialization/__init__.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/serialization/_base.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/serialization/_numpy.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/serialization/_tensorflow.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/serialization/_torch.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/templates/datasetcard_template.md +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/templates/modelcard_template.md +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/utils/_cache_assets.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/utils/_cache_manager.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/utils/_chunk_utils.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/utils/_datetime.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/utils/_deprecation.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/utils/_errors.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/utils/_experimental.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/utils/_fixes.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/utils/_git_credential.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/utils/_headers.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/utils/_hf_folder.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/utils/_http.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/utils/_pagination.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/utils/_paths.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/utils/_runtime.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/utils/_safetensors.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/utils/_subprocess.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/utils/_telemetry.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/utils/_token.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/utils/_validators.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/utils/endpoint_helpers.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/utils/insecure_hashlib.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/utils/logging.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/utils/sha.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/utils/tqdm.py +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub.egg-info/SOURCES.txt +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub.egg-info/dependency_links.txt +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub.egg-info/entry_points.txt +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub.egg-info/requires.txt +0 -0
- {huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: huggingface_hub
|
|
3
|
-
Version: 0.23.
|
|
3
|
+
Version: 0.23.4
|
|
4
4
|
Summary: Client library to download and publish models, datasets and other repos on the huggingface.co hub
|
|
5
5
|
Home-page: https://github.com/huggingface/huggingface_hub
|
|
6
6
|
Author: Hugging Face, Inc.
|
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
import inspect
|
|
2
2
|
import json
|
|
3
3
|
import os
|
|
4
|
+
import warnings
|
|
4
5
|
from dataclasses import asdict, dataclass, is_dataclass
|
|
5
6
|
from pathlib import Path
|
|
6
|
-
from typing import
|
|
7
|
+
from typing import (
|
|
8
|
+
TYPE_CHECKING,
|
|
9
|
+
Any,
|
|
10
|
+
Callable,
|
|
11
|
+
Dict,
|
|
12
|
+
List,
|
|
13
|
+
Optional,
|
|
14
|
+
Tuple,
|
|
15
|
+
Type,
|
|
16
|
+
TypeVar,
|
|
17
|
+
Union,
|
|
18
|
+
)
|
|
7
19
|
|
|
8
20
|
from .constants import CONFIG_NAME, PYTORCH_WEIGHTS_NAME, SAFETENSORS_SINGLE_FILE
|
|
9
21
|
from .file_download import hf_hub_download
|
|
@@ -15,8 +27,10 @@ from .utils import (
|
|
|
15
27
|
SoftTemporaryDirectory,
|
|
16
28
|
is_jsonable,
|
|
17
29
|
is_safetensors_available,
|
|
30
|
+
is_simple_optional_type,
|
|
18
31
|
is_torch_available,
|
|
19
32
|
logging,
|
|
33
|
+
unwrap_simple_optional_type,
|
|
20
34
|
validate_hf_hub_args,
|
|
21
35
|
)
|
|
22
36
|
|
|
@@ -85,8 +99,8 @@ class ModelHubMixin:
|
|
|
85
99
|
URL of the library documentation. Used to generate model card.
|
|
86
100
|
model_card_template (`str`, *optional*):
|
|
87
101
|
Template of the model card. Used to generate model card. Defaults to a generic template.
|
|
88
|
-
|
|
89
|
-
|
|
102
|
+
language (`str` or `List[str]`, *optional*):
|
|
103
|
+
Language supported by the library. Used to generate model card.
|
|
90
104
|
library_name (`str`, *optional*):
|
|
91
105
|
Name of the library integrating ModelHubMixin. Used to generate model card.
|
|
92
106
|
license (`str`, *optional*):
|
|
@@ -191,7 +205,7 @@ class ModelHubMixin:
|
|
|
191
205
|
# Model card template
|
|
192
206
|
model_card_template: str = DEFAULT_MODEL_CARD,
|
|
193
207
|
# Model card metadata
|
|
194
|
-
|
|
208
|
+
language: Optional[List[str]] = None,
|
|
195
209
|
library_name: Optional[str] = None,
|
|
196
210
|
license: Optional[str] = None,
|
|
197
211
|
license_name: Optional[str] = None,
|
|
@@ -205,6 +219,8 @@ class ModelHubMixin:
|
|
|
205
219
|
# Value is a tuple (encoder, decoder).
|
|
206
220
|
# Example: {MyCustomType: (lambda x: x.value, lambda data: MyCustomType(data))}
|
|
207
221
|
] = None,
|
|
222
|
+
# Deprecated arguments
|
|
223
|
+
languages: Optional[List[str]] = None,
|
|
208
224
|
) -> None:
|
|
209
225
|
"""Inspect __init__ signature only once when subclassing + handle modelcard."""
|
|
210
226
|
super().__init_subclass__()
|
|
@@ -212,20 +228,46 @@ class ModelHubMixin:
|
|
|
212
228
|
# Will be reused when creating modelcard
|
|
213
229
|
tags = tags or []
|
|
214
230
|
tags.append("model_hub_mixin")
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
231
|
+
|
|
232
|
+
# Initialize MixinInfo if not existent
|
|
233
|
+
if not hasattr(cls, "_hub_mixin_info"):
|
|
234
|
+
cls._hub_mixin_info = MixinInfo(
|
|
235
|
+
model_card_template=model_card_template,
|
|
236
|
+
model_card_data=ModelCardData(),
|
|
237
|
+
)
|
|
238
|
+
info = cls._hub_mixin_info
|
|
239
|
+
|
|
240
|
+
if languages is not None:
|
|
241
|
+
warnings.warn(
|
|
242
|
+
"The `languages` argument is deprecated. Use `language` instead. This will be removed in `huggingface_hub>=0.27.0`.",
|
|
243
|
+
DeprecationWarning,
|
|
244
|
+
)
|
|
245
|
+
language = languages
|
|
246
|
+
|
|
247
|
+
# Update MixinInfo with metadata
|
|
248
|
+
if model_card_template is not None and model_card_template != DEFAULT_MODEL_CARD:
|
|
249
|
+
info.model_card_template = model_card_template
|
|
250
|
+
if repo_url is not None:
|
|
251
|
+
info.repo_url = repo_url
|
|
252
|
+
if docs_url is not None:
|
|
253
|
+
info.docs_url = docs_url
|
|
254
|
+
if language is not None:
|
|
255
|
+
info.model_card_data.language = language
|
|
256
|
+
if library_name is not None:
|
|
257
|
+
info.model_card_data.library_name = library_name
|
|
258
|
+
if license is not None:
|
|
259
|
+
info.model_card_data.license = license
|
|
260
|
+
if license_name is not None:
|
|
261
|
+
info.model_card_data.license_name = license_name
|
|
262
|
+
if license_link is not None:
|
|
263
|
+
info.model_card_data.license_link = license_link
|
|
264
|
+
if pipeline_tag is not None:
|
|
265
|
+
info.model_card_data.pipeline_tag = pipeline_tag
|
|
266
|
+
if tags is not None:
|
|
267
|
+
if info.model_card_data.tags is not None:
|
|
268
|
+
info.model_card_data.tags.extend(tags)
|
|
269
|
+
else:
|
|
270
|
+
info.model_card_data.tags = tags
|
|
229
271
|
|
|
230
272
|
# Handle encoders/decoders for args
|
|
231
273
|
cls._hub_mixin_coders = coders or {}
|
|
@@ -283,12 +325,11 @@ class ModelHubMixin:
|
|
|
283
325
|
if instance._is_jsonable(value) # Only if jsonable or we have a custom encoder
|
|
284
326
|
},
|
|
285
327
|
}
|
|
286
|
-
init_config.pop("config", {})
|
|
328
|
+
passed_config = init_config.pop("config", {})
|
|
287
329
|
|
|
288
330
|
# Populate `init_config` with provided config
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
init_config.update(provided_config)
|
|
331
|
+
if isinstance(passed_config, dict):
|
|
332
|
+
init_config.update(passed_config)
|
|
292
333
|
|
|
293
334
|
# Set `config` attribute and return
|
|
294
335
|
if init_config != {}:
|
|
@@ -307,15 +348,26 @@ class ModelHubMixin:
|
|
|
307
348
|
"""Encode an argument into a JSON serializable format."""
|
|
308
349
|
for type_, (encoder, _) in cls._hub_mixin_coders.items():
|
|
309
350
|
if isinstance(arg, type_):
|
|
351
|
+
if arg is None:
|
|
352
|
+
return None
|
|
310
353
|
return encoder(arg)
|
|
311
354
|
return arg
|
|
312
355
|
|
|
313
356
|
@classmethod
|
|
314
|
-
def _decode_arg(cls, expected_type: Type[ARGS_T], value: Any) -> ARGS_T:
|
|
357
|
+
def _decode_arg(cls, expected_type: Type[ARGS_T], value: Any) -> Optional[ARGS_T]:
|
|
315
358
|
"""Decode a JSON serializable value into an argument."""
|
|
359
|
+
if is_simple_optional_type(expected_type):
|
|
360
|
+
if value is None:
|
|
361
|
+
return None
|
|
362
|
+
expected_type = unwrap_simple_optional_type(expected_type)
|
|
363
|
+
# Dataclass => handle it
|
|
364
|
+
if is_dataclass(expected_type):
|
|
365
|
+
return _load_dataclass(expected_type, value) # type: ignore[return-value]
|
|
366
|
+
# Otherwise => check custom decoders
|
|
316
367
|
for type_, (_, decoder) in cls._hub_mixin_coders.items():
|
|
317
|
-
if issubclass(expected_type, type_):
|
|
368
|
+
if inspect.isclass(expected_type) and issubclass(expected_type, type_):
|
|
318
369
|
return decoder(value)
|
|
370
|
+
# Otherwise => don't decode
|
|
319
371
|
return value
|
|
320
372
|
|
|
321
373
|
def save_pretrained(
|
|
@@ -325,6 +377,7 @@ class ModelHubMixin:
|
|
|
325
377
|
config: Optional[Union[dict, "DataclassInstance"]] = None,
|
|
326
378
|
repo_id: Optional[str] = None,
|
|
327
379
|
push_to_hub: bool = False,
|
|
380
|
+
model_card_kwargs: Optional[Dict[str, Any]] = None,
|
|
328
381
|
**push_to_hub_kwargs,
|
|
329
382
|
) -> Optional[str]:
|
|
330
383
|
"""
|
|
@@ -340,7 +393,9 @@ class ModelHubMixin:
|
|
|
340
393
|
repo_id (`str`, *optional*):
|
|
341
394
|
ID of your repository on the Hub. Used only if `push_to_hub=True`. Will default to the folder name if
|
|
342
395
|
not provided.
|
|
343
|
-
|
|
396
|
+
model_card_kwargs (`Dict[str, Any]`, *optional*):
|
|
397
|
+
Additional arguments passed to the model card template to customize the model card.
|
|
398
|
+
push_to_hub_kwargs:
|
|
344
399
|
Additional key word arguments passed along to the [`~ModelHubMixin.push_to_hub`] method.
|
|
345
400
|
Returns:
|
|
346
401
|
`str` or `None`: url of the commit on the Hub if `push_to_hub=True`, `None` otherwise.
|
|
@@ -369,8 +424,9 @@ class ModelHubMixin:
|
|
|
369
424
|
|
|
370
425
|
# save model card
|
|
371
426
|
model_card_path = save_directory / "README.md"
|
|
427
|
+
model_card_kwargs = model_card_kwargs if model_card_kwargs is not None else {}
|
|
372
428
|
if not model_card_path.exists(): # do not overwrite if already exists
|
|
373
|
-
self.generate_model_card().save(save_directory / "README.md")
|
|
429
|
+
self.generate_model_card(**model_card_kwargs).save(save_directory / "README.md")
|
|
374
430
|
|
|
375
431
|
# push to the Hub if required
|
|
376
432
|
if push_to_hub:
|
|
@@ -379,7 +435,7 @@ class ModelHubMixin:
|
|
|
379
435
|
kwargs["config"] = config
|
|
380
436
|
if repo_id is None:
|
|
381
437
|
repo_id = save_directory.name # Defaults to `save_directory` name
|
|
382
|
-
return self.push_to_hub(repo_id=repo_id, **kwargs)
|
|
438
|
+
return self.push_to_hub(repo_id=repo_id, model_card_kwargs=model_card_kwargs, **kwargs)
|
|
383
439
|
return None
|
|
384
440
|
|
|
385
441
|
def _save_pretrained(self, save_directory: Path) -> None:
|
|
@@ -477,19 +533,10 @@ class ModelHubMixin:
|
|
|
477
533
|
model_kwargs[param.name] = config[param.name]
|
|
478
534
|
|
|
479
535
|
# Check if `config` argument was passed at init
|
|
480
|
-
if "config" in cls._hub_mixin_init_parameters:
|
|
481
|
-
#
|
|
536
|
+
if "config" in cls._hub_mixin_init_parameters and "config" not in model_kwargs:
|
|
537
|
+
# Decode `config` argument if it was passed
|
|
482
538
|
config_annotation = cls._hub_mixin_init_parameters["config"].annotation
|
|
483
|
-
|
|
484
|
-
pass # no annotation
|
|
485
|
-
elif is_dataclass(config_annotation):
|
|
486
|
-
config = _load_dataclass(config_annotation, config)
|
|
487
|
-
else:
|
|
488
|
-
# if Optional/Union annotation => check if a dataclass is in the Union
|
|
489
|
-
for _sub_annotation in get_args(config_annotation):
|
|
490
|
-
if is_dataclass(_sub_annotation):
|
|
491
|
-
config = _load_dataclass(_sub_annotation, config)
|
|
492
|
-
break
|
|
539
|
+
config = cls._decode_arg(config_annotation, config)
|
|
493
540
|
|
|
494
541
|
# Forward config to model initialization
|
|
495
542
|
model_kwargs["config"] = config
|
|
@@ -505,7 +552,7 @@ class ModelHubMixin:
|
|
|
505
552
|
model_kwargs[key] = value
|
|
506
553
|
|
|
507
554
|
# Finally, also inject if `_from_pretrained` expects it
|
|
508
|
-
if cls._hub_mixin_inject_config:
|
|
555
|
+
if cls._hub_mixin_inject_config and "config" not in model_kwargs:
|
|
509
556
|
model_kwargs["config"] = config
|
|
510
557
|
|
|
511
558
|
instance = cls._from_pretrained(
|
|
@@ -588,6 +635,7 @@ class ModelHubMixin:
|
|
|
588
635
|
allow_patterns: Optional[Union[List[str], str]] = None,
|
|
589
636
|
ignore_patterns: Optional[Union[List[str], str]] = None,
|
|
590
637
|
delete_patterns: Optional[Union[List[str], str]] = None,
|
|
638
|
+
model_card_kwargs: Optional[Dict[str, Any]] = None,
|
|
591
639
|
) -> str:
|
|
592
640
|
"""
|
|
593
641
|
Upload model checkpoint to the Hub.
|
|
@@ -618,6 +666,8 @@ class ModelHubMixin:
|
|
|
618
666
|
If provided, files matching any of the patterns are not pushed.
|
|
619
667
|
delete_patterns (`List[str]` or `str`, *optional*):
|
|
620
668
|
If provided, remote files matching any of the patterns will be deleted from the repo.
|
|
669
|
+
model_card_kwargs (`Dict[str, Any]`, *optional*):
|
|
670
|
+
Additional arguments passed to the model card template to customize the model card.
|
|
621
671
|
|
|
622
672
|
Returns:
|
|
623
673
|
The url of the commit of your model in the given repository.
|
|
@@ -628,7 +678,7 @@ class ModelHubMixin:
|
|
|
628
678
|
# Push the files to the repo in a single commit
|
|
629
679
|
with SoftTemporaryDirectory() as tmp:
|
|
630
680
|
saved_path = Path(tmp) / repo_id
|
|
631
|
-
self.save_pretrained(saved_path, config=config)
|
|
681
|
+
self.save_pretrained(saved_path, config=config, model_card_kwargs=model_card_kwargs)
|
|
632
682
|
return api.upload_folder(
|
|
633
683
|
repo_id=repo_id,
|
|
634
684
|
repo_type="model",
|
|
@@ -647,6 +697,7 @@ class ModelHubMixin:
|
|
|
647
697
|
template_str=self._hub_mixin_info.model_card_template,
|
|
648
698
|
repo_url=self._hub_mixin_info.repo_url,
|
|
649
699
|
docs_url=self._hub_mixin_info.docs_url,
|
|
700
|
+
**kwargs,
|
|
650
701
|
)
|
|
651
702
|
return card
|
|
652
703
|
|
|
@@ -242,19 +242,6 @@ class ModelCardData(CardData):
|
|
|
242
242
|
"""Model Card Metadata that is used by Hugging Face Hub when included at the top of your README.md
|
|
243
243
|
|
|
244
244
|
Args:
|
|
245
|
-
language (`Union[str, List[str]]`, *optional*):
|
|
246
|
-
Language of model's training data or metadata. It must be an ISO 639-1, 639-2 or
|
|
247
|
-
639-3 code (two/three letters), or a special value like "code", "multilingual". Defaults to `None`.
|
|
248
|
-
license (`str`, *optional*):
|
|
249
|
-
License of this model. Example: apache-2.0 or any license from
|
|
250
|
-
https://huggingface.co/docs/hub/repositories-licenses. Defaults to None.
|
|
251
|
-
library_name (`str`, *optional*):
|
|
252
|
-
Name of library used by this model. Example: keras or any library from
|
|
253
|
-
https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/src/model-libraries.ts.
|
|
254
|
-
Defaults to None.
|
|
255
|
-
tags (`List[str]`, *optional*):
|
|
256
|
-
List of tags to add to your model that can be used when filtering on the Hugging
|
|
257
|
-
Face Hub. Defaults to None.
|
|
258
245
|
base_model (`str` or `List[str]`, *optional*):
|
|
259
246
|
The identifier of the base model from which the model derives. This is applicable for example if your model is a
|
|
260
247
|
fine-tune or adapter of an existing model. The value must be the ID of a model on the Hub (or a list of IDs
|
|
@@ -262,17 +249,36 @@ class ModelCardData(CardData):
|
|
|
262
249
|
datasets (`List[str]`, *optional*):
|
|
263
250
|
List of datasets that were used to train this model. Should be a dataset ID
|
|
264
251
|
found on https://hf.co/datasets. Defaults to None.
|
|
265
|
-
metrics (`List[str]`, *optional*):
|
|
266
|
-
List of metrics used to evaluate this model. Should be a metric name that can be found
|
|
267
|
-
at https://hf.co/metrics. Example: 'accuracy'. Defaults to None.
|
|
268
252
|
eval_results (`Union[List[EvalResult], EvalResult]`, *optional*):
|
|
269
253
|
List of `huggingface_hub.EvalResult` that define evaluation results of the model. If provided,
|
|
270
254
|
`model_name` is used to as a name on PapersWithCode's leaderboards. Defaults to `None`.
|
|
255
|
+
language (`Union[str, List[str]]`, *optional*):
|
|
256
|
+
Language of model's training data or metadata. It must be an ISO 639-1, 639-2 or
|
|
257
|
+
639-3 code (two/three letters), or a special value like "code", "multilingual". Defaults to `None`.
|
|
258
|
+
library_name (`str`, *optional*):
|
|
259
|
+
Name of library used by this model. Example: keras or any library from
|
|
260
|
+
https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/src/model-libraries.ts.
|
|
261
|
+
Defaults to None.
|
|
262
|
+
license (`str`, *optional*):
|
|
263
|
+
License of this model. Example: apache-2.0 or any license from
|
|
264
|
+
https://huggingface.co/docs/hub/repositories-licenses. Defaults to None.
|
|
265
|
+
license_name (`str`, *optional*):
|
|
266
|
+
Name of the license of this model. Defaults to None. To be used in conjunction with `license_link`.
|
|
267
|
+
Common licenses (Apache-2.0, MIT, CC-BY-SA-4.0) do not need a name. In that case, use `license` instead.
|
|
268
|
+
license_link (`str`, *optional*):
|
|
269
|
+
Link to the license of this model. Defaults to None. To be used in conjunction with `license_name`.
|
|
270
|
+
Common licenses (Apache-2.0, MIT, CC-BY-SA-4.0) do not need a link. In that case, use `license` instead.
|
|
271
|
+
metrics (`List[str]`, *optional*):
|
|
272
|
+
List of metrics used to evaluate this model. Should be a metric name that can be found
|
|
273
|
+
at https://hf.co/metrics. Example: 'accuracy'. Defaults to None.
|
|
271
274
|
model_name (`str`, *optional*):
|
|
272
275
|
A name for this model. It is used along with
|
|
273
276
|
`eval_results` to construct the `model-index` within the card's metadata. The name
|
|
274
277
|
you supply here is what will be used on PapersWithCode's leaderboards. If None is provided
|
|
275
278
|
then the repo name is used as a default. Defaults to None.
|
|
279
|
+
tags (`List[str]`, *optional*):
|
|
280
|
+
List of tags to add to your model that can be used when filtering on the Hugging
|
|
281
|
+
Face Hub. Defaults to None.
|
|
276
282
|
ignore_metadata_errors (`str`):
|
|
277
283
|
If True, errors while parsing the metadata section will be ignored. Some information might be lost during
|
|
278
284
|
the process. Use it at your own risk.
|
|
@@ -297,27 +303,33 @@ class ModelCardData(CardData):
|
|
|
297
303
|
def __init__(
|
|
298
304
|
self,
|
|
299
305
|
*,
|
|
300
|
-
language: Optional[Union[str, List[str]]] = None,
|
|
301
|
-
license: Optional[str] = None,
|
|
302
|
-
library_name: Optional[str] = None,
|
|
303
|
-
tags: Optional[List[str]] = None,
|
|
304
306
|
base_model: Optional[Union[str, List[str]]] = None,
|
|
305
307
|
datasets: Optional[List[str]] = None,
|
|
306
|
-
metrics: Optional[List[str]] = None,
|
|
307
308
|
eval_results: Optional[List[EvalResult]] = None,
|
|
309
|
+
language: Optional[Union[str, List[str]]] = None,
|
|
310
|
+
library_name: Optional[str] = None,
|
|
311
|
+
license: Optional[str] = None,
|
|
312
|
+
license_name: Optional[str] = None,
|
|
313
|
+
license_link: Optional[str] = None,
|
|
314
|
+
metrics: Optional[List[str]] = None,
|
|
308
315
|
model_name: Optional[str] = None,
|
|
316
|
+
pipeline_tag: Optional[str] = None,
|
|
317
|
+
tags: Optional[List[str]] = None,
|
|
309
318
|
ignore_metadata_errors: bool = False,
|
|
310
319
|
**kwargs,
|
|
311
320
|
):
|
|
312
|
-
self.language = language
|
|
313
|
-
self.license = license
|
|
314
|
-
self.library_name = library_name
|
|
315
|
-
self.tags = _to_unique_list(tags)
|
|
316
321
|
self.base_model = base_model
|
|
317
322
|
self.datasets = datasets
|
|
318
|
-
self.metrics = metrics
|
|
319
323
|
self.eval_results = eval_results
|
|
324
|
+
self.language = language
|
|
325
|
+
self.library_name = library_name
|
|
326
|
+
self.license = license
|
|
327
|
+
self.license_name = license_name
|
|
328
|
+
self.license_link = license_link
|
|
329
|
+
self.metrics = metrics
|
|
320
330
|
self.model_name = model_name
|
|
331
|
+
self.pipeline_tag = pipeline_tag
|
|
332
|
+
self.tags = _to_unique_list(tags)
|
|
321
333
|
|
|
322
334
|
model_index = kwargs.pop("model-index", None)
|
|
323
335
|
if model_index:
|
|
@@ -113,7 +113,7 @@ from ._safetensors import (
|
|
|
113
113
|
from ._subprocess import capture_output, run_interactive_subprocess, run_subprocess
|
|
114
114
|
from ._telemetry import send_telemetry
|
|
115
115
|
from ._token import get_token
|
|
116
|
-
from ._typing import is_jsonable
|
|
116
|
+
from ._typing import is_jsonable, is_simple_optional_type, unwrap_simple_optional_type
|
|
117
117
|
from ._validators import (
|
|
118
118
|
smoothly_deprecate_use_auth_token,
|
|
119
119
|
validate_hf_hub_args,
|
|
@@ -14,7 +14,15 @@
|
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
"""Handle typing imports based on system compatibility."""
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
import sys
|
|
18
|
+
from typing import Any, Callable, List, Literal, Type, TypeVar, Union, get_args, get_origin
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
UNION_TYPES: List[Any] = [Union]
|
|
22
|
+
if sys.version_info >= (3, 10):
|
|
23
|
+
from types import UnionType
|
|
24
|
+
|
|
25
|
+
UNION_TYPES += [UnionType]
|
|
18
26
|
|
|
19
27
|
|
|
20
28
|
HTTP_METHOD_T = Literal["GET", "OPTIONS", "HEAD", "POST", "PUT", "PATCH", "DELETE"]
|
|
@@ -48,3 +56,20 @@ def is_jsonable(obj: Any) -> bool:
|
|
|
48
56
|
return False
|
|
49
57
|
except RecursionError:
|
|
50
58
|
return False
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def is_simple_optional_type(type_: Type) -> bool:
|
|
62
|
+
"""Check if a type is optional, i.e. Optional[Type] or Union[Type, None] or Type | None, where Type is a non-composite type."""
|
|
63
|
+
if get_origin(type_) in UNION_TYPES:
|
|
64
|
+
union_args = get_args(type_)
|
|
65
|
+
if len(union_args) == 2 and type(None) in union_args:
|
|
66
|
+
return True
|
|
67
|
+
return False
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def unwrap_simple_optional_type(optional_type: Type) -> Type:
|
|
71
|
+
"""Unwraps a simple optional type, i.e. returns Type from Optional[Type]."""
|
|
72
|
+
for arg in get_args(optional_type):
|
|
73
|
+
if arg is not type(None):
|
|
74
|
+
return arg
|
|
75
|
+
raise ValueError(f"'{optional_type}' is not an optional type")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: huggingface-hub
|
|
3
|
-
Version: 0.23.
|
|
3
|
+
Version: 0.23.4
|
|
4
4
|
Summary: Client library to download and publish models, datasets and other repos on the huggingface.co hub
|
|
5
5
|
Home-page: https://github.com/huggingface/huggingface_hub
|
|
6
6
|
Author: Hugging Face, Inc.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/_inference_endpoints.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/_tensorboard_logger.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/commands/_cli_utils.py
RENAMED
|
File without changes
|
{huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/commands/delete_cache.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/commands/huggingface_cli.py
RENAMED
|
File without changes
|
|
File without changes
|
{huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/commands/scan_cache.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/inference/_templating.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/serialization/__init__.py
RENAMED
|
File without changes
|
{huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/serialization/_base.py
RENAMED
|
File without changes
|
{huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/serialization/_numpy.py
RENAMED
|
File without changes
|
{huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/serialization/_tensorflow.py
RENAMED
|
File without changes
|
{huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/serialization/_torch.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/utils/_cache_assets.py
RENAMED
|
File without changes
|
{huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/utils/_cache_manager.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/utils/_experimental.py
RENAMED
|
File without changes
|
|
File without changes
|
{huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/utils/_git_credential.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/utils/endpoint_helpers.py
RENAMED
|
File without changes
|
{huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub/utils/insecure_hashlib.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub.egg-info/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|
{huggingface_hub-0.23.3 → huggingface_hub-0.23.4}/src/huggingface_hub.egg-info/top_level.txt
RENAMED
|
File without changes
|