-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathgenerate_image_v4.py
More file actions
46 lines (34 loc) · 1.3 KB
/
generate_image_v4.py
File metadata and controls
46 lines (34 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""
{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
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_Curated
# model = ImageModel.Anime_v4_Full
# model = ImageModel.Anime_v45_Full
# model = ImageModel.Anime_v45_Curated
preset = ImagePreset.from_default_config(model)
preset.seed = 42
# NOTE: Order matters! It will give slightly different results if you change the order of the characters.
# even though we give positions, the model can ignore them
preset.characters = [
# prompt, uc, position
{"prompt": "boy"}, # default position is "C3"
{"prompt": "girl", "position": "A3"},
]
prompt = "1girl, 1boy"
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())