* add new testing method * add testing readme * style: make linter happy * update * update * chore: do some cleanings * update * update * update * update * style: make linter happy * update * finished the first test * update * debugging * update * update * update * update * update * style: make the linter happy * update * finished a case * style: make linter happy * new to figure out how to run mulitiple tests * make linter happy * update * update * add nunchaku-flux.1-depth-lora * rename images to inputs * update * update a dedicated folder for the test workflows * update * update * fix the test scores * style: make linter happy * update upscaler * style: make linter happy * add pulid * add lora * make linter happy * update * update * finished flux fill * style: make linter happy * finished removal * style: make linter happy * add kontext * add kontext turbo * style: make linter happy * add flux.1-schnell tests * finished redux * add qwen-image tests * update * update * style: make linter happy * update * add test results for 5090 * update * update
44 lines
1.4 KiB
Python
44 lines
1.4 KiB
Python
import os
|
|
from pathlib import Path
|
|
|
|
import yaml
|
|
from huggingface_hub import hf_hub_download
|
|
|
|
from nunchaku.utils import get_precision
|
|
|
|
|
|
def load_yaml(path: str | Path) -> dict:
|
|
with open(path, "r", encoding="utf-8") as file:
|
|
data = yaml.safe_load(file)
|
|
return data
|
|
|
|
|
|
def download_file(
|
|
repo_id: str,
|
|
filename: str,
|
|
sub_folder: str,
|
|
new_filename: str | None = None,
|
|
) -> str:
|
|
os.makedirs(os.path.join("models", sub_folder), exist_ok=True)
|
|
target_folder = os.path.join("models", sub_folder)
|
|
target_file = os.path.join(target_folder, filename if new_filename is None else new_filename)
|
|
if not os.path.exists(target_file):
|
|
hf_hub_download(repo_id=repo_id, filename=filename, local_dir=target_folder)
|
|
if new_filename is not None:
|
|
os.rename(os.path.join(target_folder, filename), os.path.join(target_folder, new_filename))
|
|
return target_file
|
|
|
|
|
|
def download_from_yaml():
|
|
data = load_yaml(Path(__file__).resolve().parent.parent / "test_data" / "models.yaml")
|
|
for model_info in data["models"]:
|
|
repo_id = model_info["repo_id"]
|
|
filename = model_info["filename"].format(precision=get_precision())
|
|
sub_folder = model_info["sub_folder"]
|
|
new_filename = model_info.get("new_filename", None)
|
|
download_file(repo_id=repo_id, filename=filename, sub_folder=sub_folder, new_filename=new_filename)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
download_from_yaml()
|