2022-09-11 06:27:22 +00:00
|
|
|
from imaginairy.api import imagine_images, imagine_image_files
|
|
|
|
from imaginairy.schema import ImaginePrompt
|
2022-09-10 05:14:04 +00:00
|
|
|
from . import TESTS_FOLDER
|
|
|
|
|
|
|
|
|
|
|
|
def test_imagine():
|
2022-09-10 07:32:31 +00:00
|
|
|
prompt = ImaginePrompt(
|
|
|
|
"a scenic landscape", width=512, height=256, steps=20, seed=1
|
|
|
|
)
|
2022-09-10 05:14:04 +00:00
|
|
|
result = next(imagine_images(prompt))
|
2022-09-10 07:32:31 +00:00
|
|
|
assert result.md5() == "4c5957c498881d365cfcf13014812af0"
|
2022-09-10 05:14:04 +00:00
|
|
|
result.img.save(f"{TESTS_FOLDER}/test_output/scenic_landscape.png")
|
|
|
|
|
|
|
|
|
|
|
|
def test_img_to_img():
|
|
|
|
prompt = ImaginePrompt(
|
|
|
|
"a photo of a beach",
|
|
|
|
init_image=f"{TESTS_FOLDER}/data/beach_at_sainte_adresse.jpg",
|
|
|
|
init_image_strength=0.5,
|
|
|
|
width=512,
|
|
|
|
height=512,
|
|
|
|
steps=50,
|
|
|
|
seed=1,
|
|
|
|
sampler_type="DDIM",
|
|
|
|
)
|
|
|
|
out_folder = f"{TESTS_FOLDER}/test_output"
|
|
|
|
imagine_image_files(prompt, outdir=out_folder)
|
|
|
|
|
|
|
|
|
|
|
|
def test_img_to_file():
|
|
|
|
prompt = ImaginePrompt(
|
2022-09-11 06:27:22 +00:00
|
|
|
"an old growth forest, diffuse light poking through the canopy. high-resolution, nature photography, nat geo photo",
|
2022-09-10 07:32:31 +00:00
|
|
|
width=512 + 64,
|
|
|
|
height=512 - 64,
|
2022-09-10 05:14:04 +00:00
|
|
|
steps=50,
|
2022-09-11 06:27:22 +00:00
|
|
|
seed=2,
|
2022-09-10 05:14:04 +00:00
|
|
|
sampler_type="PLMS",
|
2022-09-10 07:32:31 +00:00
|
|
|
upscale=True,
|
2022-09-10 05:14:04 +00:00
|
|
|
)
|
|
|
|
out_folder = f"{TESTS_FOLDER}/test_output"
|
|
|
|
imagine_image_files(prompt, outdir=out_folder)
|