Skip to content
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

Add optional parameters to "from_pretrained()", so that downloading preprocessors can use proxies. #71

Open
icarried opened this issue Aug 28, 2023 · 1 comment

Comments

@icarried
Copy link

icarried commented Aug 28, 2023

Due to network issues, I hope to be able to increase the use of proxies when downloading models, so that downloading models with diffusers and downloading preprocessors with controlnet_aux can go through the same proxy. For example, using a method similar "to _get_model_file()" in Diffusers where more parameters can be passed to "hf_hub_download()" when "from_pretrained()" needs to download in the preprocessor, or just add parameters for using "proxies" is more simple.

Such like:
(controlnet_aux/midas/init.py)

def from_pretrained(cls, pretrained_model_or_path, model_type="dpt_hybrid", filename=None, cache_dir=None, proxies=None):
    if pretrained_model_or_path == "lllyasviel/ControlNet":
        filename = filename or "annotator/ckpts/dpt_hybrid-midas-501f0c75.pt"
    else:
        filename = filename or "dpt_hybrid-midas-501f0c75.pt"

    if os.path.isdir(pretrained_model_or_path):
        model_path = os.path.join(pretrained_model_or_path, filename)
    else:
        model_path = hf_hub_download(pretrained_model_or_path, filename, cache_dir=cache_dir, proxies=proxies)

    model = MiDaSInference(model_type=model_type, model_path=model_path)

    return cls(model)

I am willing to open a PR.

@patrickvonplaten
Copy link
Contributor

Makes sense to me - happy to review a PR

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

No branches or pull requests

2 participants