stable-diffusion-webui icon indicating copy to clipboard operation
stable-diffusion-webui copied to clipboard

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

Open licyk opened this issue 9 months ago • 3 comments

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:

licyk avatar Mar 22 '25 08:03 licyk

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.

a-holm avatar Apr 01 '25 12:04 a-holm

@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.

licyk avatar Apr 02 '25 12:04 licyk

@licyk alright, I just misunderstood the code then.

a-holm avatar Apr 02 '25 12:04 a-holm