Skip to content

Instantly share code, notes, and snippets.

@rameerez
Created February 15, 2024 02:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rameerez/ee014f28b6f4ed8d294fa3497a9a9ec8 to your computer and use it in GitHub Desktop.
Save rameerez/ee014f28b6f4ed8d294fa3497a9a9ec8 to your computer and use it in GitHub Desktop.
Download all CrontrolNet models to Automatic1111
# Meant to be ran inside a `download.ipynb` notebook inside
# the `/workspace/stable-diffusion-webui/extensions/sd-webui-controlnet/models/` folder
# of an Automatic1111 installation
# !pip install requests
import requests
import os
# List of file names to download
file_names = [
"control_v11e_sd15_ip2p.pth",
"control_v11e_sd15_ip2p.yaml",
"control_v11e_sd15_shuffle.pth",
"control_v11e_sd15_shuffle.yaml",
"control_v11f1e_sd15_tile.pth",
"control_v11f1e_sd15_tile.yaml",
"control_v11f1p_sd15_depth.pth",
"control_v11f1p_sd15_depth.yaml",
"control_v11p_sd15_canny.pth",
"control_v11p_sd15_canny.yaml",
"control_v11p_sd15_inpaint.pth",
"control_v11p_sd15_inpaint.yaml",
"control_v11p_sd15_lineart.pth",
"control_v11p_sd15_lineart.yaml",
"control_v11p_sd15_mlsd.pth",
"control_v11p_sd15_mlsd.yaml",
"control_v11p_sd15_normalbae.pth",
"control_v11p_sd15_normalbae.yaml",
"control_v11p_sd15_openpose.pth",
"control_v11p_sd15_openpose.yaml",
"control_v11p_sd15_scribble.pth",
"control_v11p_sd15_scribble.yaml",
"control_v11p_sd15_seg.pth",
"control_v11p_sd15_seg.yaml",
"control_v11p_sd15_softedge.pth",
"control_v11p_sd15_softedge.yaml",
"control_v11p_sd15s2_lineart_anime.pth",
"control_v11p_sd15s2_lineart_anime.yaml"
]
# Base URL for downloading the files
base_url = "https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/{FILE_NAME}?download=true"
for file_name in file_names:
# Construct the full URL for each file
url = base_url.format(FILE_NAME=file_name)
print(f"Downloading {file_name} from {url}")
# Send a GET request to the URL
response = requests.get(url)
# Check if the request was successful
if response.status_code == 200:
# Define the path where to save the file (same as notebook path)
path_to_save = os.path.join(os.getcwd(), file_name)
# Write the content of the response to a file
with open(path_to_save, 'wb') as file:
file.write(response.content)
print(f"Downloaded {file_name}")
else:
print(f"Failed to download {file_name}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment