huggingface / huggingface/controlnet_aux

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

Open
#71 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
497
Forks
104
PR merge metrics
No merged PRs in 30d

Description

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)
```python
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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.