test_match_histograms.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import pytest
  2. import torch
  3. from sorawm.iopaint.model_manager import ModelManager
  4. from sorawm.iopaint.schema import HDStrategy, SDSampler
  5. from sorawm.iopaint.tests.utils import (
  6. assert_equal,
  7. check_device,
  8. current_dir,
  9. get_config,
  10. )
  11. @pytest.mark.parametrize("device", ["cuda", "mps"])
  12. @pytest.mark.parametrize("sampler", [SDSampler.ddim])
  13. def test_sd_match_histograms(device, sampler):
  14. sd_steps = check_device(device)
  15. model = ModelManager(
  16. name="runwayml/stable-diffusion-inpainting",
  17. device=torch.device(device),
  18. disable_nsfw=True,
  19. sd_cpu_textencoder=False,
  20. )
  21. cfg = get_config(
  22. strategy=HDStrategy.ORIGINAL,
  23. prompt="face of a fox, sitting on a bench",
  24. sd_steps=sd_steps,
  25. sd_guidance_scale=7.5,
  26. sd_lcm_lora=False,
  27. sd_match_histograms=True,
  28. sd_sampler=sampler,
  29. )
  30. assert_equal(
  31. model,
  32. cfg,
  33. f"runway_sd_1_5_device_{device}_match_histograms.png",
  34. img_p=current_dir / "overture-creations-5sI6fQgYIuo.png",
  35. mask_p=current_dir / "overture-creations-5sI6fQgYIuo_mask.png",
  36. )