|
| 1 | +import pytest |
| 2 | + |
| 3 | +from hydra import initialize, compose |
| 4 | +from loguru import logger |
| 5 | +from pytti.workhorse import _main as render_frames |
| 6 | +from omegaconf import OmegaConf, open_dict |
| 7 | + |
| 8 | + |
| 9 | +CONFIG_BASE_PATH = "config" |
| 10 | +CONFIG_DEFAULTS = "default.yaml" |
| 11 | + |
| 12 | + |
| 13 | +cfg_yaml_openai = """# @package _global_ |
| 14 | +scenes: a photograph of an apple |
| 15 | +use_mmc: true |
| 16 | +mmc_models: |
| 17 | +- architecture: clip |
| 18 | + publisher: openai |
| 19 | + id: RN50 |
| 20 | +- architecture: clip |
| 21 | + publisher: openai |
| 22 | + id: ViT-B/32 |
| 23 | +""" |
| 24 | + |
| 25 | + |
| 26 | +def test_mmc_openai_models(): |
| 27 | + |
| 28 | + with initialize(config_path=CONFIG_BASE_PATH): |
| 29 | + cfg_base = compose( |
| 30 | + config_name=CONFIG_DEFAULTS, |
| 31 | + overrides=[f"conf=_empty"], |
| 32 | + ) |
| 33 | + cfg_mmc = OmegaConf.create(cfg_yaml_openai) |
| 34 | + |
| 35 | + with open_dict(cfg_base) as cfg: |
| 36 | + cfg = OmegaConf.merge(cfg_base, cfg_mmc) |
| 37 | + render_frames(cfg) |
| 38 | + |
| 39 | + |
| 40 | +cfg_yaml_mlf = """# @package _global_ |
| 41 | +scenes: a photograph of an apple |
| 42 | +use_mmc: true |
| 43 | +mmc_models: |
| 44 | +- architecture: clip |
| 45 | + publisher: mlfoundations |
| 46 | + id: RN50--yfcc15m |
| 47 | +- architecture: clip |
| 48 | + publisher: mlfoundations |
| 49 | + id: ViT-B-32--laion400m_avg |
| 50 | +""" |
| 51 | + |
| 52 | + |
| 53 | +def test_mmc_mlf_models(): |
| 54 | + |
| 55 | + with initialize(config_path=CONFIG_BASE_PATH): |
| 56 | + cfg_base = compose( |
| 57 | + config_name=CONFIG_DEFAULTS, |
| 58 | + overrides=[f"conf=_empty"], |
| 59 | + ) |
| 60 | + cfg_mmc = OmegaConf.create(cfg_yaml_mlf) |
| 61 | + |
| 62 | + with open_dict(cfg_base) as cfg: |
| 63 | + cfg = OmegaConf.merge(cfg_base, cfg_mmc) |
| 64 | + render_frames(cfg) |
| 65 | + |
| 66 | + |
| 67 | +cfg_yaml_all_cloob = """# @package _global_ |
| 68 | +scenes: a photograph of an apple |
| 69 | +use_mmc: true |
| 70 | +mmc_models: |
| 71 | +- architecture: cloob |
| 72 | + id: cloob_laion_400m_vit_b_16_32_epochs |
| 73 | +""" |
| 74 | + |
| 75 | + |
| 76 | +def test_mmc_all_cloob_models(): |
| 77 | + |
| 78 | + with initialize(config_path=CONFIG_BASE_PATH): |
| 79 | + cfg_base = compose( |
| 80 | + config_name=CONFIG_DEFAULTS, |
| 81 | + overrides=[f"conf=_empty"], |
| 82 | + ) |
| 83 | + cfg_mmc = OmegaConf.create(cfg_yaml_all_cloob) |
| 84 | + |
| 85 | + with open_dict(cfg_base) as cfg: |
| 86 | + cfg = OmegaConf.merge(cfg_base, cfg_mmc) |
| 87 | + render_frames(cfg) |
0 commit comments