Spaces:
Running
on
Zero
Running
on
Zero
Create download.py
Browse files- download.py +100 -0
download.py
ADDED
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import time
|
3 |
+
import torch
|
4 |
+
#os.environ['HF_ENDPOINT']="https://hf-mirror.com"
|
5 |
+
from huggingface_hub import hf_hub_download
|
6 |
+
|
7 |
+
class OMG_download():
|
8 |
+
def __init__(self) -> None:
|
9 |
+
self.download_model_sam()
|
10 |
+
print("download efficientvit sam")
|
11 |
+
|
12 |
+
self.download_model_yoloworld()
|
13 |
+
print("download yoloworld")
|
14 |
+
|
15 |
+
self.download_controlNet()
|
16 |
+
print("download controlNet")
|
17 |
+
|
18 |
+
self.download_styles()
|
19 |
+
print("download styles")
|
20 |
+
|
21 |
+
self.download_antelopev2()
|
22 |
+
print("download antelopev2")
|
23 |
+
|
24 |
+
self.download_instantid()
|
25 |
+
print("download instantid")
|
26 |
+
|
27 |
+
|
28 |
+
def download_model_sam(self):
|
29 |
+
REPO_ID = 'han-cai/efficientvit-sam'
|
30 |
+
filename_list = ['xl1.pt']
|
31 |
+
if not os.path.exists('/home/user/app/checkpoint/sam/'):
|
32 |
+
os.makedirs('/home/user/app/checkpoint/sam/')
|
33 |
+
for filename in filename_list:
|
34 |
+
local_file = os.path.join('/home/user/app/checkpoint/sam/', filename)
|
35 |
+
|
36 |
+
if not os.path.exists(local_file):
|
37 |
+
hf_hub_download(repo_id=REPO_ID, filename=filename, local_dir='/home/user/app/checkpoint/sam/', local_dir_use_symlinks=False)
|
38 |
+
|
39 |
+
def download_model_yoloworld(self):
|
40 |
+
REPO_ID = 'Fucius/OMG'
|
41 |
+
filename_list = ['yolo-world.pt']
|
42 |
+
if not os.path.exists('/tmp/cache/yolo_world/l/'):
|
43 |
+
os.makedirs('/tmp/cache/yolo_world/l/')
|
44 |
+
for filename in filename_list:
|
45 |
+
local_file = os.path.join('/tmp/cache/yolo_world/l/', filename)
|
46 |
+
if not os.path.exists(local_file):
|
47 |
+
hf_hub_download(repo_id=REPO_ID, filename=filename, local_dir='/tmp/cache/yolo_world/l/', local_dir_use_symlinks=False)
|
48 |
+
|
49 |
+
def download_controlNet(self):
|
50 |
+
REPO_ID = 'lllyasviel/ControlNet'
|
51 |
+
filename_list = ['annotator/ckpts/body_pose_model.pth']
|
52 |
+
if not os.path.exists('/home/user/app/checkpoint/ControlNet/'):
|
53 |
+
os.makedirs('/home/user/app/checkpoint/ControlNet/')
|
54 |
+
for filename in filename_list:
|
55 |
+
local_file = os.path.join('/home/user/app/checkpoint/ControlNet/', filename)
|
56 |
+
|
57 |
+
if not os.path.exists(local_file):
|
58 |
+
hf_hub_download(repo_id=REPO_ID, filename=filename, local_dir='/home/user/app/checkpoint/ControlNet/',
|
59 |
+
local_dir_use_symlinks=False)
|
60 |
+
|
61 |
+
|
62 |
+
def download_styles(self):
|
63 |
+
REPO_ID = 'Fucius/OMG'
|
64 |
+
filename_list = ['style/EldritchPaletteKnife.safetensors', 'style/Cinematic Hollywood Film.safetensors', 'style/Anime_Sketch_SDXL.safetensors']
|
65 |
+
if not os.path.exists('/home/user/app/checkpoint/'):
|
66 |
+
os.makedirs('/home/user/app/checkpoint/')
|
67 |
+
for filename in filename_list:
|
68 |
+
local_file = os.path.join('/home/user/app/checkpoint/', filename)
|
69 |
+
|
70 |
+
if not os.path.exists(local_file):
|
71 |
+
hf_hub_download(repo_id=REPO_ID, filename=filename, local_dir='/home/user/app/checkpoint/',
|
72 |
+
local_dir_use_symlinks=False)
|
73 |
+
|
74 |
+
def download_antelopev2(self):
|
75 |
+
REPO_ID = 'Fucius/OMG'
|
76 |
+
filename_list = ['antelopev2/models/antelopev2/1k3d68.onnx', 'antelopev2/models/antelopev2/2d106det.onnx', 'antelopev2/models/antelopev2/genderage.onnx', 'antelopev2/models/antelopev2/glintr100.onnx', 'antelopev2/models/antelopev2/scrfd_10g_bnkps.onnx']
|
77 |
+
if not os.path.exists('/home/user/app/checkpoint/'):
|
78 |
+
os.makedirs('/home/user/app/checkpoint/')
|
79 |
+
for filename in filename_list:
|
80 |
+
local_file = os.path.join('/home/user/app/checkpoint/', filename)
|
81 |
+
|
82 |
+
if not os.path.exists(local_file):
|
83 |
+
hf_hub_download(repo_id=REPO_ID, filename=filename, local_dir='/home/user/app/checkpoint/',
|
84 |
+
local_dir_use_symlinks=False)
|
85 |
+
|
86 |
+
def download_instantid(self):
|
87 |
+
REPO_ID = 'InstantX/InstantID'
|
88 |
+
filename_list = ['ip-adapter.bin', 'ControlNetModel/config.json', 'ControlNetModel/diffusion_pytorch_model.safetensors']
|
89 |
+
if not os.path.exists('/home/user/app/checkpoint/InstantID'):
|
90 |
+
os.makedirs('/home/user/app/checkpoint/InstantID')
|
91 |
+
for filename in filename_list:
|
92 |
+
local_file = os.path.join('/home/user/app/checkpoint/InstantID', filename)
|
93 |
+
|
94 |
+
if not os.path.exists(local_file):
|
95 |
+
hf_hub_download(repo_id=REPO_ID, filename=filename, local_dir='/home/user/app/checkpoint/InstantID',
|
96 |
+
local_dir_use_symlinks=False)
|
97 |
+
|
98 |
+
if __name__ == '__main__':
|
99 |
+
down = OMG_download()
|
100 |
+
print("finished download")
|