File size: 1,006 Bytes
38d7f79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"""
Minimal smoke test / usage demo for the packaged SkeletonGif model.

Run:
    python -m skeleton_gif_model.example
"""

from pathlib import Path

from skeleton_gif_model import SkeletonGif


def main() -> None:
    here = Path(__file__).resolve().parent

    # Load from local dir (same surface as loading from the Hub).
    model = SkeletonGif.from_pretrained(here)
    print(model)

    prompts = [
        "a sad man reading a book in a bedroom",
        "happy skeleton playing football on a soccer field",
        "tired woman cleaning the living room",
    ]

    out_dir = here.parent / "outputs" / "hf_demo"
    out_dir.mkdir(parents=True, exist_ok=True)

    for p in prompts:
        result = model(p)
        path = out_dir / f"{result.action}-{result.emotion}-{result.scene}.gif"
        result.save(path)
        print(f"{p!r:70s} -> {result.action}/{result.emotion}/{result.scene} "
              f"({len(result.gif_bytes)} bytes) -> {path.name}")


if __name__ == "__main__":
    main()