Spaces:
Running
on
Zero
Running
on
Zero
import os | |
import time | |
import torch | |
#os.environ['HF_ENDPOINT']="https://hf-mirror.com" | |
from huggingface_hub import hf_hub_download | |
class OMG_download(): | |
def __init__(self) -> None: | |
self.download_model_sam() | |
print("download efficientvit sam") | |
self.download_model_yoloworld() | |
print("download yoloworld") | |
self.download_controlNet() | |
print("download controlNet") | |
self.download_styles() | |
print("download styles") | |
self.download_antelopev2() | |
print("download antelopev2") | |
self.download_instantid() | |
print("download instantid") | |
def download_model_sam(self): | |
REPO_ID = 'han-cai/efficientvit-sam' | |
filename_list = ['xl1.pt'] | |
if not os.path.exists('/home/user/app/checkpoint/sam/'): | |
os.makedirs('/home/user/app/checkpoint/sam/') | |
for filename in filename_list: | |
local_file = os.path.join('/home/user/app/checkpoint/sam/', filename) | |
if not os.path.exists(local_file): | |
hf_hub_download(repo_id=REPO_ID, filename=filename, local_dir='/home/user/app/checkpoint/sam/', local_dir_use_symlinks=False) | |
def download_model_yoloworld(self): | |
REPO_ID = 'Fucius/OMG' | |
filename_list = ['yolo-world.pt'] | |
if not os.path.exists('/tmp/cache/yolo_world/l/'): | |
os.makedirs('/tmp/cache/yolo_world/l/') | |
for filename in filename_list: | |
local_file = os.path.join('/tmp/cache/yolo_world/l/', filename) | |
if not os.path.exists(local_file): | |
hf_hub_download(repo_id=REPO_ID, filename=filename, local_dir='/tmp/cache/yolo_world/l/', local_dir_use_symlinks=False) | |
def download_controlNet(self): | |
REPO_ID = 'lllyasviel/ControlNet' | |
filename_list = ['annotator/ckpts/body_pose_model.pth'] | |
if not os.path.exists('/home/user/app/checkpoint/ControlNet/'): | |
os.makedirs('/home/user/app/checkpoint/ControlNet/') | |
for filename in filename_list: | |
local_file = os.path.join('/home/user/app/checkpoint/ControlNet/', filename) | |
if not os.path.exists(local_file): | |
hf_hub_download(repo_id=REPO_ID, filename=filename, local_dir='/home/user/app/checkpoint/ControlNet/', | |
local_dir_use_symlinks=False) | |
def download_styles(self): | |
REPO_ID = 'Fucius/OMG' | |
filename_list = ['style/EldritchPaletteKnife.safetensors', 'style/Cinematic Hollywood Film.safetensors', 'style/Anime_Sketch_SDXL.safetensors'] | |
if not os.path.exists('/home/user/app/checkpoint/'): | |
os.makedirs('/home/user/app/checkpoint/') | |
for filename in filename_list: | |
local_file = os.path.join('/home/user/app/checkpoint/', filename) | |
if not os.path.exists(local_file): | |
hf_hub_download(repo_id=REPO_ID, filename=filename, local_dir='/home/user/app/checkpoint/', | |
local_dir_use_symlinks=False) | |
def download_antelopev2(self): | |
REPO_ID = 'Fucius/OMG' | |
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'] | |
if not os.path.exists('/home/user/app/checkpoint/'): | |
os.makedirs('/home/user/app/checkpoint/') | |
for filename in filename_list: | |
local_file = os.path.join('/home/user/app/checkpoint/', filename) | |
if not os.path.exists(local_file): | |
hf_hub_download(repo_id=REPO_ID, filename=filename, local_dir='/home/user/app/checkpoint/', | |
local_dir_use_symlinks=False) | |
def download_instantid(self): | |
REPO_ID = 'InstantX/InstantID' | |
filename_list = ['ip-adapter.bin', 'ControlNetModel/config.json', 'ControlNetModel/diffusion_pytorch_model.safetensors'] | |
if not os.path.exists('/home/user/app/checkpoint/InstantID'): | |
os.makedirs('/home/user/app/checkpoint/InstantID') | |
for filename in filename_list: | |
local_file = os.path.join('/home/user/app/checkpoint/InstantID', filename) | |
if not os.path.exists(local_file): | |
hf_hub_download(repo_id=REPO_ID, filename=filename, local_dir='/home/user/app/checkpoint/InstantID', | |
local_dir_use_symlinks=False) | |
if __name__ == '__main__': | |
down = OMG_download() | |
print("finished download") |