(url, local_path, chunk_size=1024)
| 28 | |
| 29 | |
| 30 | def download(url, local_path, chunk_size=1024): |
| 31 | os.makedirs(os.path.split(local_path)[0], exist_ok=True) |
| 32 | with requests.get(url, stream=True) as r: |
| 33 | total_size = int(r.headers.get("content-length", 0)) |
| 34 | with tqdm(total=total_size, unit="B", unit_scale=True, desc="Downloading LPIPS weights") as pbar: |
| 35 | with open(local_path, "wb") as f: |
| 36 | for data in r.iter_content(chunk_size=chunk_size): |
| 37 | if data: |
| 38 | f.write(data) |
| 39 | pbar.update(chunk_size) |
| 40 | |
| 41 | |
| 42 | def md5_hash(path): |