lllyasviel / lllyasviel/stable-diffusion-webui-forge

[Feature Request]: 加快在国内下载模型的速度,同时兼容Windows加速下载

Open
#700 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
13k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues and checked the recent builds/commits

### What would your feature do ?

替换所有download_url_to_file

```
def download_url_to_file(url, local_filename, progress=True):
"""
Download a file from a given URL and saves it to a specified local path.
:param progress: print download progress
:param url: The URL of the file to download
:param local_filename: The local path to save the file
"""
print("Downloading file from URL: %s" % url)
url = url.replace('huggingface.co', 'hf-mirror.com')
with requests.get(url, stream=True) as response:
total_size = int(response.headers.get('content-length', 0))
response.raise_for_status()
if total_size == 0:
print("Unable to retrieve the file size.")
downloaded_size = 0
# Send a GET request and retrieve the content
with requests.get(url, stream=True) as r:
r.raise_for_status() # Check the response status code, if the status code indicates an error, it throws an exception
with open(local_filename, 'wb') as f:
for chunk in r.iter_content(chunk_size=8192):
f.write(chunk)
if progress:
downloaded_size += len(chunk)
# Print progress information
progress_percentage = (downloaded_size / total_size) * 100
# Use carriage return to overwrite the content in the same line and print download progress
print(f"Download progress: {downloaded_size} / {total_size} "
f"({progress_percentage:.2f}%)", end='\r')
```

### Proposed workflow

加快在国内下载模型的速度,同时兼容Windows加速下载

### Additional information

加快在国内下载模型的速度,同时兼容Windows加速下载

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by searching the repository for every use of `download_url_to_file` and inspect the requests-based implementation shown in the issue. Determine how model downloads are currently routed, then verify that all relevant downloads use the intended faster route and remain compatible with Windows; the issue is done when every call site is covered and downloads complete successfully on both environments.

Written by the indexing model from the issue text.

Assessment

Tech stack
huggingface, python
Domain
machine-learning
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.