load_file_from_url() downloads the model from HF_ENDPOINT if it is set
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:
set
HF_ENDPOINT=https://hf-mirror.com
Checklist:
- [x] I have read contributing wiki page
- [x] I have performed a self-review of my own code
- [x] My code follows the style guidelines
- [x] My code passes tests
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 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 alright, I just misunderstood the code then.