Skip to content

load_file_from_url() downloads the model from HF_ENDPOINT if it is set #16911

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

licyk
Copy link

@licyk licyk commented Mar 22, 2025

Description

When HF_ENDPOINT is set, load_file_from_url() downloads models from it. Extensions like sd-webui-controlnet that rely on this function will now also use HF_ENDPOINT.

Screenshots/videos:

屏幕截图 2025-03-22 161843

set HF_ENDPOINT=https://hf-mirror.com

Checklist:

@a-holm
Copy link

a-holm commented Apr 1, 2025

Thanks for this contribution! Adding support for HF_ENDPOINT in load_file_from_url is a useful feature, especially for users behind mirrors or in restricted environments.

The core change in modules/util.py correctly implements the intended functionality by replacing the Hugging Face domain based on shared.hf_endpoint. The refinement in modules/shared.py also looks good.

However, the changes included in the diff for modules/dat_model.py, modules/models/sd3/sd3_cond.py, modules/sd_disable_initialization.py, and modules/sd_models.py seem counter-productive to the goal of this PR. They appear to remove dynamic usage of shared.hf_endpoint and replace it with hardcoded https://huggingface.co URLs. This contradicts the intent of allowing an override via HF_ENDPOINT.

Could you please revise the PR to only include the necessary changes in modules/util.py and modules/shared.py? The other modifications seem unrelated or incorrect for this feature.

@licyk
Copy link
Author

licyk commented Apr 2, 2025

@a-holm In the four files including modules/dat_model.py and modules/models/sd3/sd3_cond.py, all URLs are downloaded via load_file_from_url(). Therefore, removing the hardcoded shared.hf_endpoint in these files is the correct optimization, it eliminates redundant replacement logic while ensuring that HF_ENDPOINT remains effective after the modification.

@a-holm
Copy link

a-holm commented Apr 2, 2025

@licyk alright, I just misunderstood the code then.

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.

2 participants