diff --git a/src/transformers/models/detr/configuration_detr.py b/src/transformers/models/detr/configuration_detr.py index b3da5f86b016..955b71de1ec5 100644 --- a/src/transformers/models/detr/configuration_detr.py +++ b/src/transformers/models/detr/configuration_detr.py @@ -239,6 +239,7 @@ def hidden_size(self) -> int: @classmethod def from_backbone_config(cls, backbone_config: PretrainedConfig, **kwargs): """Instantiate a [`DetrConfig`] (or a derived class) from a pre-trained backbone model configuration. + Args: backbone_config ([`PretrainedConfig`]): The backbone configuration. diff --git a/src/transformers/utils/hub.py b/src/transformers/utils/hub.py index 3403867eafe8..db00878c9ae4 100644 --- a/src/transformers/utils/hub.py +++ b/src/transformers/utils/hub.py @@ -390,7 +390,7 @@ def cached_file( if isinstance(cache_dir, Path): cache_dir = str(cache_dir) - if _commit_hash is not None: + if _commit_hash is not None and not force_download: # If the file is cached under that commit hash, we return it directly. resolved_file = try_to_load_from_cache( path_or_repo_id, full_filename, cache_dir=cache_dir, revision=_commit_hash @@ -913,7 +913,13 @@ def get_checkpoint_shard_files( # At this stage pretrained_model_name_or_path is a model identifier on the Hub cached_filenames = [] - for shard_filename in shard_filenames: + # Check if the model is already cached or not. We only try the last checkpoint, this should cover most cases of + # downloaded (if interrupted). + last_shard = try_to_load_from_cache( + pretrained_model_name_or_path, shard_filenames[-1], cache_dir=cache_dir, revision=_commit_hash + ) + show_progress_bar = last_shard is None or force_download + for shard_filename in tqdm(shard_filenames, desc="Downloading shards", disable=not show_progress_bar): try: # Load from URL cached_filename = cached_file(