Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #@markdown # Civitai Model Downloader
- #@markdown - Download model from Civitai directly to your Google Drive
- def add_files(btn):
- file_name = file_name_input.value
- file_url = file_url_input.value
- if file_name and file_url:
- file_names.append(file_name)
- file_urls.append(file_url)
- checkboxes.append(widgets.Checkbox(value=False, description=file_name))
- clear_output()
- display_files()
- file_name_input.value = ''
- file_url_input.value = ''
- def display_files():
- num_cols = 4
- num_rows = len(checkboxes) // num_cols + (len(checkboxes) % num_cols > 0)
- cols = [widgets.VBox(checkboxes[i*num_rows:(i+1)*num_rows]) for i in range(num_cols)]
- display(widgets.HBox(cols), file_name_input, file_url_input, add_file_button, download_button)
- def download_files(btn):
- file_list = []
- for i in range(len(checkboxes)):
- if checkboxes[i].value:
- file_list.append(file_urls[i])
- checkboxes[i].description = f"{file_names[i]} selected"
- checkboxes[i].disabled = True
- if len(file_list) > 0:
- output_path = "/content/gdrive/MyDrive/sd/stable-diffusion-webui/models/Stable-diffusion"
- os.makedirs(output_path, exist_ok=True)
- for file_url, file_name in zip(file_list, file_names):
- file_path = os.path.join(output_path, file_name)
- !wget -O "$file_path" "$file_url"
- clear_output()
- inf('Downloaded \u2714','success', '50px')
- # List of file URLs
- file_urls = [
- "https://civitai.com/api/download/models/15236",
- "https://civitai.com/api/download/models/24365",
- "https://civitai.com/api/download/models/34326"
- ]
- # List of file names
- file_names = [
- "Deliberate.safetensors",
- "DreamShaper.safetensors",
- "StyleJourney.safetensors"
- ]
- # Create the checkboxes
- checkboxes = [widgets.Checkbox(value=False, description=f) for f in file_names]
- # Create the input fields and buttons
- file_name_input = widgets.Text(description='Model Name:')
- file_url_input = widgets.Text(description='Model URL:')
- add_file_button = widgets.Button(description='Add Model')
- add_file_button.on_click(add_files)
- # Create the download button
- download_button = widgets.Button(description="Download Model (s)")
- download_button.on_click(download_files)
- # Display the checkboxes and the download button in four columns
- display_files()
Advertisement
Add Comment
Please, Sign In to add comment