Skip to content

Commit d2cb0b9

Browse files
authored
Merge pull request #107 from LlmKira/dev
✨ feat(ai): enhance image generation with model updates
2 parents 373c7e0 + 5448a12 commit d2cb0b9

File tree

6 files changed

+281
-116
lines changed

6 files changed

+281
-116
lines changed

pdm.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

playground/generate_image.py

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,17 @@
1515
from novelai_python import GenerateImageInfer, ImageGenerateResp, ApiCredential
1616
from novelai_python.sdk.ai.generate_image import Action, Model, Sampler, Character, UCPreset, Params
1717
from novelai_python.sdk.ai.generate_image.schema import PositionMap
18+
from novelai_python.tool.random_prompt import RandomPromptGenerator
1819
from novelai_python.utils.useful import enum_to_list
1920

2021

2122
async def generate(
22-
prompt="2girls, fisheye, closeup, from above"
23+
prompt=None,
2324
):
2425
jwt = os.getenv("NOVELAI_JWT", None)
2526
if jwt is None:
2627
raise ValueError("NOVELAI_JWT is not set in `.env` file, please create one and set it")
28+
2729
credential = ApiCredential(api_token=SecretStr(jwt))
2830
"""Or you can use the login credential to get the renewable jwt token"""
2931
_login_credential = LoginCredential(
@@ -43,24 +45,29 @@ async def generate(
4345
A5 B5 C5 D5 E5
4446
"""
4547
)
48+
49+
# Randomly generate a scene
50+
prompt_generator = RandomPromptGenerator()
51+
scene = prompt_generator.generate_scene_composition()
52+
if prompt is None:
53+
prompt = scene.pop(0) + ','.join([
54+
'muelsyse (arknights) '
55+
])
56+
character = [
57+
Character(
58+
prompt=c_prompt,
59+
uc="red hair",
60+
center=PositionMap.B2
61+
) for c_prompt in scene
62+
]
63+
4664
try:
4765
agent = GenerateImageInfer.build_generate(
4866
prompt=prompt,
49-
width=1216,
50-
height=832,
51-
model=Model.NAI_DIFFUSION_4_CURATED_PREVIEW,
52-
character_prompts=[
53-
Character(
54-
prompt="1girl, head tilt, short hair, black hair, grey eyes, small breasts, looking at viewer",
55-
uc="red hair",
56-
center=PositionMap.B2
57-
),
58-
Character(
59-
prompt="1girl, fox ears, fox tail, white hair, white tail, white ears",
60-
uc="black hair",
61-
center=PositionMap.D2
62-
)
63-
],
67+
width=832,
68+
height=1216,
69+
model=Model.NAI_DIFFUSION_4_FULL,
70+
character_prompts=character,
6471
sampler=Sampler.K_EULER_ANCESTRAL,
6572
ucPreset=UCPreset.TYPE0,
6673
# Recommended, using preset negative_prompt depends on selected model

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "novelai-python"
3-
version = "0.7.5"
3+
version = "0.7.6"
44
description = "NovelAI Python Binding With Pydantic"
55
authors = [
66
{ name = "sudoskys", email = "[email protected]" },

0 commit comments

Comments
 (0)