Update app.py
Browse files17 unmodified lines1819202122231 unmodified line25262728293017 unmodified linessd_cfg.json'''if not os.path.exists("sd-ggml-cpp-dp"):os.system("git clone https://huggingface.co/svjack/sd-ggml-cpp-dp")else:1 unmodified lineos.system("git clone https://huggingface.co/svjack/sd-ggml-cpp-dp")assert os.path.exists("sd-ggml-cpp-dp")os.chdir("sd-ggml-cpp-dp")assert os.path.exists("stable-diffusion.cpp")os.system("cmake stable-diffusion.cpp")os.system("cmake --build . --config Release")17 unmodified lines181920212223241 unmodified line26272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757617 unmodified linessd_cfg.json''''''if not os.path.exists("sd-ggml-cpp-dp"):os.system("git clone https://huggingface.co/svjack/sd-ggml-cpp-dp")else:1 unmodified lineos.system("git clone https://huggingface.co/svjack/sd-ggml-cpp-dp")assert os.path.exists("sd-ggml-cpp-dp")os.chdir("sd-ggml-cpp-dp")'''os.system("pip install huggingface_hub")#### https://huggingface.co/svjack/sd-ggml-cpp-dp/resolve/main/models/Cyberpunk_Anime_Diffusion-ggml-model_q4_0.bindef make_and_download_clean_dir(repo_name = "svjack/sd-ggml",rp_tgt_tail_dict = {"models": "wget https://huggingface.co/{}/resolve/main/{}/{}"}):import shutilimport osfrom tqdm import tqdmfrom huggingface_hub import HfFileSystemfs = HfFileSystem()req_dir = repo_name.split("/")[-1]if os.path.exists(req_dir):shutil.rmtree(req_dir)os.mkdir(req_dir)os.chdir(req_dir)fd_list = fs.ls(repo_name, detail = False)fd_clean_list = list(filter(lambda x: not x.split("/")[-1].startswith("."), fd_list))for path in tqdm(fd_clean_list):src = pathtgt = src.split("/")[-1]print("downloading {} to {}".format(src, tgt))if tgt not in rp_tgt_tail_dict:fs.download(src, tgt, recursive = True)else:tgt_cmd_format = rp_tgt_tail_dict[tgt]os.mkdir(tgt)os.chdir(tgt)sub_fd_list = fs.ls(src, detail = False)for sub_file in tqdm(sub_fd_list):tgt_cmd = tgt_cmd_format.format(repo_name, tgt, sub_file.split("/")[-1])print("run {}".format(tgt_cmd))os.system(tgt_cmd)os.chdir("..")os.chdir("..")make_and_download_clean_dir("svjack/sd-ggml")os.chdir("sd-ggml")assert os.path.exists("stable-diffusion.cpp")os.system("cmake stable-diffusion.cpp")os.system("cmake --build . --config Release")
app.py+46