CoolFace
Apppublic

currupio/Tune-A-Video-Training-UI

sourceHugging Facemitupdated 3y agoView on Hugging Face
0likes
utils.py66 linesDownload Raw Back to root
1from __future__ import annotations2 3import pathlib4 5 6def find_exp_dirs() -> list[str]:7    repo_dir = pathlib.Path(__file__).parent8    exp_root_dir = repo_dir / 'experiments'9    if not exp_root_dir.exists():10        return []11    exp_dirs = sorted(exp_root_dir.glob('*'))12    exp_dirs = [13        exp_dir for exp_dir in exp_dirs14        if (exp_dir / 'model_index.json').exists()15    ]16    return [path.relative_to(repo_dir).as_posix() for path in exp_dirs]17 18 19def save_model_card(20    save_dir: pathlib.Path,21    base_model: str,22    training_prompt: str,23    test_prompt: str = '',24    test_image_dir: str = '',25) -> None:26    image_str = ''27    if test_prompt and test_image_dir:28        image_paths = sorted((save_dir / test_image_dir).glob('*.gif'))29        if image_paths:30            image_path = image_paths[-1]31            rel_path = image_path.relative_to(save_dir)32            image_str = f'''## Samples33Test prompt: {test_prompt}34 35![{image_path.stem}]({rel_path})'''36 37    model_card = f'''---38license: creativeml-openrail-m39base_model: {base_model}40training_prompt: {training_prompt}41tags:42- stable-diffusion43- stable-diffusion-diffusers44- text-to-image45- diffusers46- text-to-video47- tune-a-video48inference: false49---50 51# Tune-A-Video - {save_dir.name}52 53## Model description54- Base model: [{base_model}](https://huggingface.co/{base_model})55- Training prompt: {training_prompt}56 57{image_str}58 59## Related papers:60- [Tune-A-Video](https://arxiv.org/abs/2212.11565): One-Shot Tuning of Image Diffusion Models for Text-to-Video Generation61- [Stable-Diffusion](https://arxiv.org/abs/2112.10752): High-Resolution Image Synthesis with Latent Diffusion Models62'''63 64    with open(save_dir / 'README.md', 'w') as f:65        f.write(model_card)66