Skip to content

Conversation

@oOraph
Copy link
Contributor

@oOraph oOraph commented May 24, 2024

What does this PR do?

Fixes # (issue)
fix model load in offline mode

Who can review?

@ArthurZucker
@Wauplin

Reproduce:

  1. download a private model from hub
  2. script:
import os

os.environ['TRANSFORMERS_OFFLINE'] = "true"

from transformers.models.auto.modeling_auto import AutoModelForImageClassification

model_id = "Narsil/private"
revision = "main"
kwargs = {'use_auth_token': None}


model = AutoModelForImageClassification.from_pretrained(model_id, revision=revision, **kwargs)

@oOraph oOraph requested a review from Wauplin May 24, 2024 10:42
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Collaborator

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Can you add this example by using HF hub to downlaod snapshot of a .bin file in a temp repo? and test both the flag to go offline and the local_files_only in from pretrained? 🤗

Copy link
Contributor

@Wauplin Wauplin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @oOraph!

@oOraph oOraph force-pushed the dev/offline_mode_fix branch from 58cc68a to 257e639 Compare May 27, 2024 09:20
@oOraph
Copy link
Contributor Author

oOraph commented May 27, 2024

Thanks! Can you add this example by using HF hub to downlaod snapshot of a .bin file in a temp repo? and test both the flag to go offline and the local_files_only in from pretrained? 🤗

Done @ArthurZucker , added some unit test -> fails before fix, succeeds after
test is ugly but I could not find any cleaner way to do it...

Signed-off-by: Raphael Glon <[email protected]>
@oOraph oOraph force-pushed the dev/offline_mode_fix branch from 8035e72 to 2eefca1 Compare May 27, 2024 09:25
@oOraph oOraph requested a review from ArthurZucker May 27, 2024 12:05
Copy link
Member

@LysandreJik LysandreJik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@LysandreJik LysandreJik merged commit 936ab7b into huggingface:main May 28, 2024
Copy link
Collaborator

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://huggingface.co/hf-internal-testing/tiny-random-SiglipForImageClassification/tree/main does not have a bin file, so we are not testing the case we solved before. Otherwise LGTM

ArthurZucker pushed a commit that referenced this pull request May 30, 2024
…31010)

* Unit test to verify fix

Signed-off-by: Raphael Glon <[email protected]>

* fix from_pretrained in offline mode when model is preloaded in cache

Signed-off-by: Raphael Glon <[email protected]>

* minor: fmt

Signed-off-by: Raphael Glon <[email protected]>

---------

Signed-off-by: Raphael Glon <[email protected]>
Co-authored-by: Raphael Glon <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants