Loading test/sd/test_nai.py +71 −0 Original line number Diff line number Diff line Loading @@ -79,6 +79,45 @@ def nai3_meta_without_title(): }) @pytest.fixture() def nai3_meta(): return NAIMetadata( software='NovelAI', source='Stable Diffusion XL C1E1DE52', title='This is title', generation_time=7.801080600824207, description='mudrock (arknights),nsfw,nude,nipple,pussy,1girl, {{small breast}}, artist:as109, ' 'artist:sigm@, [artist:neko_(yanshoujie), artist:marumoru, artist:yoneyama_mai], ' 'year 2023, solo, midriff, thigh cutout, hair ornament, looking at viewer, navel, ' 'floating ink brush background, jewelry, collarbone, tassel, bangs, talisman, cowboy shot, ' 'gold stripes, floating ink around, high contrast background, beautiful detailed eyes,', parameters={ 'prompt': 'mudrock (arknights),nsfw,nude,nipple,pussy,1girl, {{small breast}}, artist:as109, ' 'artist:sigm@, [artist:neko_(yanshoujie), artist:marumoru, artist:yoneyama_mai], ' 'year 2023, solo, midriff, thigh cutout, hair ornament, looking at viewer, navel, ' 'floating ink brush background, jewelry, collarbone, tassel, bangs, talisman, cowboy shot, ' 'gold stripes, floating ink around, high contrast background, beautiful detailed eyes,', 'steps': 28, 'height': 1216, 'width': 832, 'scale': 5.0, 'uncond_scale': 0.0, 'cfg_rescale': 0.0, 'seed': 1016281108, 'n_samples': 1, 'hide_debug_overlay': False, 'noise_schedule': 'karras', 'legacy_v3_extend': False, 'reference_information_extracted_multiple': [], 'reference_strength_multiple': [], 'sampler': 'k_dpmpp_2s_ancestral', 'controlnet_strength': 1.0, 'controlnet_model': None, 'dynamic_thresholding': False, 'dynamic_thresholding_percentile': 0.999, 'dynamic_thresholding_mimic_scale': 10.0, 'sm': True, 'sm_dyn': False, 'skip_cfg_above_sigma': None, 'skip_cfg_below_sigma': 0.0, 'lora_unet_weights': None, 'lora_clip_weights': None, 'deliberate_euler_ancestral_bug': True, 'prefer_brownian': False, 'cfg_sched_eligibility': 'enable_for_post_summer_samplers', 'explike_fine_detail': False, 'minimize_sigma_inf': False, 'uncond_per_vibe': True, 'wonky_vibe_correlation': True, 'version': 1, 'uc': 'lowres, {bad}, error, fewer, extra, missing, worst quality, jpeg artifacts, bad quality, ' 'watermark, unfinished, displeasing, chromatic aberration, signature, extra digits, ' 'artistic error, username, scan, [abstract], loli, blush, man, skindentation,ribs, ' 'pubic hair, lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, ' 'fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, ' 'signature, watermark, username', 'request_type': 'PromptGenerateRequest', 'signed_hash': 'BdmflmfBoxELpIxO2FP7WiRNM08uqcRDeO0HcWbHReQrP8UZq4LkZkaV09BpsXY3UfyGJ1tSX1JRyCedJFu3CQ==' }) @pytest.mark.unittest class TestSDNai: def test_get_naimeta_from_image(self, nai3_file, nai3_meta_without_title): Loading Loading @@ -134,3 +173,35 @@ class TestSDNai: save_pnginfo=False, add_lsb_meta=False, ) assert get_naimeta_from_image('image.png') is None def test_save_image_with_naimeta_with_title(self, nai3_clear_file, nai3_meta): with isolated_directory(): save_image_with_naimeta(nai3_clear_file, 'image.png', metadata=nai3_meta) assert get_naimeta_from_image('image.png') == pytest.approx(nai3_meta) def test_save_image_with_naimeta_rgba_with_title(self, nai3_clear_rgba_file, nai3_meta): with isolated_directory(): save_image_with_naimeta(nai3_clear_rgba_file, 'image.png', metadata=nai3_meta) assert get_naimeta_from_image('image.png') == pytest.approx(nai3_meta) def test_save_image_with_naimeta_pnginfo_only_with_title(self, nai3_clear_file, nai3_meta): with isolated_directory(): save_image_with_naimeta(nai3_clear_file, 'image.png', metadata=nai3_meta, add_lsb_meta=False) assert get_naimeta_from_image('image.png') == pytest.approx(nai3_meta) def test_save_image_with_naimeta_lsbmeta_only_with_title(self, nai3_clear_file, nai3_meta): with isolated_directory(): save_image_with_naimeta(nai3_clear_file, 'image.png', metadata=nai3_meta, save_pnginfo=False) assert get_naimeta_from_image('image.png') == pytest.approx(nai3_meta) def test_save_image_with_naimeta_both_no_with_title(self, nai3_clear_file, nai3_meta): with isolated_directory(): with pytest.warns(Warning): save_image_with_naimeta( nai3_clear_file, 'image.png', metadata=nai3_meta, save_pnginfo=False, add_lsb_meta=False, ) assert get_naimeta_from_image('image.png') is None Loading
test/sd/test_nai.py +71 −0 Original line number Diff line number Diff line Loading @@ -79,6 +79,45 @@ def nai3_meta_without_title(): }) @pytest.fixture() def nai3_meta(): return NAIMetadata( software='NovelAI', source='Stable Diffusion XL C1E1DE52', title='This is title', generation_time=7.801080600824207, description='mudrock (arknights),nsfw,nude,nipple,pussy,1girl, {{small breast}}, artist:as109, ' 'artist:sigm@, [artist:neko_(yanshoujie), artist:marumoru, artist:yoneyama_mai], ' 'year 2023, solo, midriff, thigh cutout, hair ornament, looking at viewer, navel, ' 'floating ink brush background, jewelry, collarbone, tassel, bangs, talisman, cowboy shot, ' 'gold stripes, floating ink around, high contrast background, beautiful detailed eyes,', parameters={ 'prompt': 'mudrock (arknights),nsfw,nude,nipple,pussy,1girl, {{small breast}}, artist:as109, ' 'artist:sigm@, [artist:neko_(yanshoujie), artist:marumoru, artist:yoneyama_mai], ' 'year 2023, solo, midriff, thigh cutout, hair ornament, looking at viewer, navel, ' 'floating ink brush background, jewelry, collarbone, tassel, bangs, talisman, cowboy shot, ' 'gold stripes, floating ink around, high contrast background, beautiful detailed eyes,', 'steps': 28, 'height': 1216, 'width': 832, 'scale': 5.0, 'uncond_scale': 0.0, 'cfg_rescale': 0.0, 'seed': 1016281108, 'n_samples': 1, 'hide_debug_overlay': False, 'noise_schedule': 'karras', 'legacy_v3_extend': False, 'reference_information_extracted_multiple': [], 'reference_strength_multiple': [], 'sampler': 'k_dpmpp_2s_ancestral', 'controlnet_strength': 1.0, 'controlnet_model': None, 'dynamic_thresholding': False, 'dynamic_thresholding_percentile': 0.999, 'dynamic_thresholding_mimic_scale': 10.0, 'sm': True, 'sm_dyn': False, 'skip_cfg_above_sigma': None, 'skip_cfg_below_sigma': 0.0, 'lora_unet_weights': None, 'lora_clip_weights': None, 'deliberate_euler_ancestral_bug': True, 'prefer_brownian': False, 'cfg_sched_eligibility': 'enable_for_post_summer_samplers', 'explike_fine_detail': False, 'minimize_sigma_inf': False, 'uncond_per_vibe': True, 'wonky_vibe_correlation': True, 'version': 1, 'uc': 'lowres, {bad}, error, fewer, extra, missing, worst quality, jpeg artifacts, bad quality, ' 'watermark, unfinished, displeasing, chromatic aberration, signature, extra digits, ' 'artistic error, username, scan, [abstract], loli, blush, man, skindentation,ribs, ' 'pubic hair, lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, ' 'fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, ' 'signature, watermark, username', 'request_type': 'PromptGenerateRequest', 'signed_hash': 'BdmflmfBoxELpIxO2FP7WiRNM08uqcRDeO0HcWbHReQrP8UZq4LkZkaV09BpsXY3UfyGJ1tSX1JRyCedJFu3CQ==' }) @pytest.mark.unittest class TestSDNai: def test_get_naimeta_from_image(self, nai3_file, nai3_meta_without_title): Loading Loading @@ -134,3 +173,35 @@ class TestSDNai: save_pnginfo=False, add_lsb_meta=False, ) assert get_naimeta_from_image('image.png') is None def test_save_image_with_naimeta_with_title(self, nai3_clear_file, nai3_meta): with isolated_directory(): save_image_with_naimeta(nai3_clear_file, 'image.png', metadata=nai3_meta) assert get_naimeta_from_image('image.png') == pytest.approx(nai3_meta) def test_save_image_with_naimeta_rgba_with_title(self, nai3_clear_rgba_file, nai3_meta): with isolated_directory(): save_image_with_naimeta(nai3_clear_rgba_file, 'image.png', metadata=nai3_meta) assert get_naimeta_from_image('image.png') == pytest.approx(nai3_meta) def test_save_image_with_naimeta_pnginfo_only_with_title(self, nai3_clear_file, nai3_meta): with isolated_directory(): save_image_with_naimeta(nai3_clear_file, 'image.png', metadata=nai3_meta, add_lsb_meta=False) assert get_naimeta_from_image('image.png') == pytest.approx(nai3_meta) def test_save_image_with_naimeta_lsbmeta_only_with_title(self, nai3_clear_file, nai3_meta): with isolated_directory(): save_image_with_naimeta(nai3_clear_file, 'image.png', metadata=nai3_meta, save_pnginfo=False) assert get_naimeta_from_image('image.png') == pytest.approx(nai3_meta) def test_save_image_with_naimeta_both_no_with_title(self, nai3_clear_file, nai3_meta): with isolated_directory(): with pytest.warns(Warning): save_image_with_naimeta( nai3_clear_file, 'image.png', metadata=nai3_meta, save_pnginfo=False, add_lsb_meta=False, ) assert get_naimeta_from_image('image.png') is None