diffusers
Respect offline mode when loading pipeline
#6456
Merged

Respect offline mode when loading pipeline #6456

Wauplin merged 2 commits into main from respect-offline-mode
Wauplin
Wauplin1 year ago (edited 1 year ago)

Should close #6168.

This PR adds two behaviors:

  • if offline mode is activated (i.e. HF_HUB_OFFLINE=1), we catch the error raised by huggingface_hub and default back to using the local files.
  • if a ConnectionError happens while fetching model info, we catch the error and also default back to local files

In both cases, if local files don't exist an error will be raised later in the code (as we can't load the pipeline).

This PR should definitely settle the problems for users with slow/low connections. cc @sayakpaul with whom we discussed it at some point.

Wauplin Respect offline mode when loading model
b5812fe6
Wauplin default to local entry if connectionerror
1c462ab8
Wauplin Wauplin requested a review from sayakpaul sayakpaul 1 year ago
Wauplin Wauplin requested a review from patrickvonplaten patrickvonplaten 1 year ago
sayakpaul
sayakpaul approved these changes on 2024-01-04
sayakpaul1 year ago

🫶

HuggingFaceDocBuilderDev
HuggingFaceDocBuilderDev1 year ago

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.

Wauplin
Wauplin1 year ago

Thanks for the review :)

Wauplin Wauplin merged 691d8d3e into main 1 year ago
voytez
voytez1 year ago

Broke my build with error:

cannot import name 'OfflineModeIsEnabled' from 'huggingface_hub.utils' (/opt/conda/lib/python3.8/site-packages/huggingface_hub/utils/init.py)

Was working fine before the commit

voytez
voytez1 year ago

perhaps because im running huggingface_hub-0.19.4 instead of 0.20.1?

Wauplin
Wauplin1 year ago

Thanks for reporting @voytez! I overlooked this part but indeed, we need to update the huggingface_hub dependency to benefit from the offline mode here. I opened a PR to fix this: #6467.

sayakpaul sayakpaul deleted the respect-offline-mode branch 1 year ago

Login to write a write a comment.

Login via GitHub

Assignees
No one assigned
Labels
Milestone