-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[API] Add image gen v4 preview and remove tests for image gen v1
- Loading branch information
Showing
7 changed files
with
219 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
""" | ||
{filename} | ||
============================================================================== | ||
| Example of how to generate an image | ||
| | ||
| The resulting images will be placed in a folder named "results" | ||
""" | ||
|
||
import asyncio | ||
from pathlib import Path | ||
|
||
from example.boilerplate import API | ||
from novelai_api.ImagePreset import ImageModel, ImagePreset, UCPreset | ||
|
||
|
||
async def main(): | ||
d = Path("results") | ||
d.mkdir(exist_ok=True) | ||
|
||
async with API() as api_handler: | ||
api = api_handler.api | ||
|
||
model = ImageModel.Anime_v4_preview | ||
preset = ImagePreset.from_default_config(model) | ||
preset.seed = 42 | ||
preset.uc_preset = UCPreset.Preset_Heavy | ||
preset.quality_toggle = False | ||
|
||
# even though we give positions, the model can ignore them | ||
preset.characters = [ | ||
# prompt, uc, position | ||
{"prompt": "1girl", "position": "A3"}, | ||
{"prompt": "1boy"}, # default position is "C3" | ||
] | ||
|
||
# "1girl, 1boy" + quality tags without "rating:general" | ||
prompt = "1girl, 1boy, best quality, very aesthetic, absurdres" | ||
async for _, img in api.high_level.generate_image(prompt, model, preset): | ||
(d / f"image_v4.png").write_bytes(img) | ||
|
||
|
||
if __name__ == "__main__": | ||
asyncio.run(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"resolution": "Normal_Portrait_v3", | ||
"scale": 6, | ||
"sampler": "k_euler_ancestral", | ||
"steps": 23, | ||
"n_samples": 1, | ||
"strength": 0.7, | ||
"noise": 0, | ||
"uc_preset": "Preset_Heavy", | ||
"quality_toggle": true, | ||
"smea": false, | ||
"smea_dyn": false, | ||
"decrisper": false, | ||
"controlnet_strength": 1, | ||
"legacy": false, | ||
"add_original_image": true, | ||
"uncond_scale": 1, | ||
"cfg_rescale": 0, | ||
"noise_schedule": "karras", | ||
"reference_image_multiple": [], | ||
"reference_information_extracted_multiple": [], | ||
"reference_strength_multiple": [], | ||
"use_coords": true, | ||
"legacy_v3_extend": false, | ||
"deliberate_euler_ancestral_bug": false, | ||
"prefer_brownian": true, | ||
"params_version": 3, | ||
|
||
"seed": 0, | ||
"uc": "" | ||
} |
Oops, something went wrong.