Upload ui custom.txt
Browse files- ui custom.txt +123 -0
ui custom.txt
ADDED
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# @title ## **Custom Download Corner**
|
2 |
+
import os
|
3 |
+
import shutil
|
4 |
+
|
5 |
+
%store -r
|
6 |
+
|
7 |
+
# @markdown Fill in the URL fields with the links to the files you want to download. Separate multiple URLs with a comma.
|
8 |
+
# @markdown Example: `url1, url2, url3`
|
9 |
+
os.chdir(root_dir)
|
10 |
+
|
11 |
+
custom_download_list = []
|
12 |
+
|
13 |
+
custom_model_url = "https://civitai.com/api/download/models/7425,https://civitai.com/api/download/models/11745,https://civitai.com/api/download/models/40248" # @param {'type': 'string'}
|
14 |
+
custom_vae_url = "https://huggingface.co/WarriorMama777/OrangeMixs/blob/main/VAEs/orangemix.vae.pt,https://huggingface.co/hakurei/waifu-diffusion-v1-4/blob/main/vae/kl-f8-anime2.ckpt" # @param {'type': 'string'}
|
15 |
+
custom_embedding_url = "https://huggingface.co/yesyeahvh/bad-hands-5/blob/main/bad-hands-5.pt,https://huggingface.co/datasets/Nerfgun3/bad_prompt/blob/main/bad_prompt_version2.pt,https://huggingface.co/embed/EasyNegative/blob/main/EasyNegative.safetensors,https://huggingface.co/nick-x-hacker/bad-artist/resolve/main/bad-artist-anime.pt, https://huggingface.co/nick-x-hacker/bad-artist/resolve/main/bad-artist.pt, " # @param {'type': 'string'}
|
16 |
+
custom_LoRA_url = "https://huggingface.co/suppcuti/riven/blob/main/Sigma99-Magallan.safetensors,https://huggingface.co/suppcuti/riven/blob/main/Kindred.safetensors,https://huggingface.co/suppcuti/riven/blob/main/riven-v1.2.safetensors" # @param {'type': 'string'}
|
17 |
+
custom_hypernetwork_url = "" # @param {'type': 'string'}
|
18 |
+
custom_control_url = "" # @param {'type': 'string'}
|
19 |
+
custom_extensions_url = "" # @param {'type': 'string'}
|
20 |
+
custom_components_url = "" # @param {'type': 'string'}
|
21 |
+
custom_upscaler_url = "" # @param {'type': 'string'}
|
22 |
+
|
23 |
+
|
24 |
+
def extract(url, dst):
|
25 |
+
if not url.startswith("/content/"):
|
26 |
+
filename = os.path.basename(url)
|
27 |
+
zipfile = os.path.join(dst, filename)
|
28 |
+
else:
|
29 |
+
zipfile = url
|
30 |
+
|
31 |
+
if url.endswith(".zip"):
|
32 |
+
if os.path.exists(zipfile):
|
33 |
+
!unzip -j -o {zipfile} -d "{dst}"
|
34 |
+
os.remove(zipfile)
|
35 |
+
elif url.endswith(".tar.lz4"):
|
36 |
+
if os.path.exists(zipfile):
|
37 |
+
!tar -xI lz4 -f {zipfile} --directory={dst}
|
38 |
+
os.remove(zipfile)
|
39 |
+
else:
|
40 |
+
pass
|
41 |
+
|
42 |
+
|
43 |
+
def download(url_list, dst_dir, download_list, is_extensions):
|
44 |
+
downloaded = []
|
45 |
+
for url in tqdm(url_list, desc="[1;32mDownloading Custom URLs"):
|
46 |
+
if url:
|
47 |
+
url = url.strip()
|
48 |
+
download_list.append(url)
|
49 |
+
basename = os.path.basename(url)
|
50 |
+
|
51 |
+
with capture.capture_output() as cap:
|
52 |
+
if is_extensions:
|
53 |
+
os.chdir(extensions_dir)
|
54 |
+
!git clone {url}
|
55 |
+
elif url.startswith("/content/drive/MyDrive/"):
|
56 |
+
shutil.copy(url, dst_dir)
|
57 |
+
elif url.startswith("https://drive.google.com"):
|
58 |
+
if "folders" in url:
|
59 |
+
!gdown --folder "{url}" -O {dst_dir} --fuzzy -c
|
60 |
+
else:
|
61 |
+
!gdown "{url}" -O {dst_dir} --fuzzy -c
|
62 |
+
elif url.startswith("https://huggingface.co/"):
|
63 |
+
if "/blob/" in url:
|
64 |
+
url = url.replace("/blob/", "/resolve/")
|
65 |
+
hf_token = "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"
|
66 |
+
user_header = f'"Authorization: Bearer {hf_token}"'
|
67 |
+
!aria2c --console-log-level=error --summary-interval=10 --header={user_header} -c -x 16 -k 1M -s 16 -d {dst_dir} -o {basename} {url}
|
68 |
+
else:
|
69 |
+
!aria2c --console-log-level=error --summary-interval=10 -c -x 16 -k 1M -s 16 -d {dst_dir} {url}
|
70 |
+
|
71 |
+
extract(url, dst_dir)
|
72 |
+
|
73 |
+
del cap
|
74 |
+
downloaded.append((basename, dst_dir))
|
75 |
+
|
76 |
+
|
77 |
+
custom_download_list = []
|
78 |
+
|
79 |
+
custom_dirs = {
|
80 |
+
custom_model_url: models_dir,
|
81 |
+
custom_vae_url: vaes_dir,
|
82 |
+
custom_embedding_url: embeddings_dir,
|
83 |
+
custom_LoRA_url: lora_dir,
|
84 |
+
custom_hypernetwork_url: hypernetworks_dir,
|
85 |
+
custom_control_url: control_dir,
|
86 |
+
custom_extensions_url: extensions_dir,
|
87 |
+
custom_components_url: components_dir,
|
88 |
+
custom_upscaler_url: esrgan_dir,
|
89 |
+
}
|
90 |
+
|
91 |
+
print(f"[1;32mDownloading...")
|
92 |
+
start_time = time.time()
|
93 |
+
|
94 |
+
for custom_url in [
|
95 |
+
custom_model_url,
|
96 |
+
custom_vae_url,
|
97 |
+
custom_embedding_url,
|
98 |
+
custom_LoRA_url,
|
99 |
+
custom_hypernetwork_url,
|
100 |
+
custom_control_url,
|
101 |
+
custom_extensions_url,
|
102 |
+
custom_components_url,
|
103 |
+
custom_upscaler_url,
|
104 |
+
]:
|
105 |
+
if custom_url:
|
106 |
+
urls = custom_url.split(",")
|
107 |
+
download(
|
108 |
+
urls,
|
109 |
+
custom_dirs[custom_url],
|
110 |
+
custom_download_list,
|
111 |
+
custom_url == custom_extensions_url,
|
112 |
+
)
|
113 |
+
|
114 |
+
end_time = time.time()
|
115 |
+
elapsed_time = int(end_time - start_time)
|
116 |
+
|
117 |
+
if elapsed_time < 60:
|
118 |
+
print(f"\n[1;32mDownload completed. Took {elapsed_time} sec")
|
119 |
+
else:
|
120 |
+
mins, secs = divmod(elapsed_time, 60)
|
121 |
+
print(f"\n[1;32mDownload completed. Took {mins} mins {secs} sec")
|
122 |
+
|
123 |
+
print("[1;32mAll is done! Go to the next step")
|