Optimized the prompts for the stable-diffusion style, and now the style selection results are more in line with expectations.

This commit is contained in:
fiatrete
2023-06-08 10:53:55 +08:00
parent 5bce5ed526
commit ceb6915f31
2 changed files with 16 additions and 6 deletions
@@ -118,13 +118,23 @@ Sometimes you maybe asked to generate a pic of myself. That means you MUST add '
{OTHER_SD_PARAMS_NAME: "If all above does not match, it should be this"}) {OTHER_SD_PARAMS_NAME: "If all above does not match, it should be this"})
async def determine_style(prompt: str): async def determine_style(prompt: str):
gpt_system_prompt = "You are an AI designed to determine a 'style' of a sentence. I will give you a sentence," \ # Replace 'style' with 'fact' when talking to GPT, since it may be confused by the word 'style'
" you should reply the which of the 'style' matches the sentence, all candidate of your " \ gpt_system_prompt = "You are an AI designed to determine a 'fact' of a sentence. " \
"I will give you a sentence, you should reply the which 'fact' matches the sentence. " \
"You MUST reply ONLY the fact name with nothing else. All candidate of your " \
"answer are defined as following:\n'''\n" "answer are defined as following:\n'''\n"
for style, definition in stable_diffusion_all_style_definitions.items(): for fact, definition in stable_diffusion_all_style_definitions.items():
gpt_system_prompt += f"{style}: {definition}.\n" gpt_system_prompt += f"<{fact}>: <{definition}>.\n"
gpt_system_prompt += "'''\n" gpt_system_prompt += "'''\n"
gpt_system_prompt += "NOTE: You MUST reply ONLY the 'style name'." gpt_system_prompt += f"""The following is the matching rule:
f'''
1. Checking fact from the first to the last.
2. Once all features described in a fact are satisfied by the sentence, this fact is considered 'match'.
3. Reply the first match.
4. If no fact match, reply '{OTHER_SD_PARAMS_NAME}'
'''
NOTE: Just reply using these information, don't ask me anything.
"""
sys_prompt = {'role': 'system', 'content': gpt_system_prompt} sys_prompt = {'role': 'system', 'content': gpt_system_prompt}
messages = [sys_prompt, {'role': 'user', 'content': prompt}] messages = [sys_prompt, {'role': 'user', 'content': prompt}]
@@ -22,7 +22,7 @@
"override_settings_restore_afterwards": false "override_settings_restore_afterwards": false
}, },
"girl drinking coffee": { "girl drinking coffee": {
"DEFINITION": "Required features: A young female, she is drinking coffee", "DEFINITION": "Required features: A young female. she is drinking coffee. the beverage MUST be coffee",
"prompt": "photorealistic, (photorealistic:1.4), best quality, ultra detailed, ultra high res, masterpiece, realistic, 1girl, solo, full body, long_hair, looking at viewer, extremely detailed face, perfect lighting, from above, earrings, pov, pureerosface_v1, A girl with a great figure is wearing an off-the-shoulder dress, sitting in a caf\u00e9. Her long hair is flowing down her shoulders. It's daytime, and outside the window, cars are passing by. There are many people enjoying their coffee around her", "prompt": "photorealistic, (photorealistic:1.4), best quality, ultra detailed, ultra high res, masterpiece, realistic, 1girl, solo, full body, long_hair, looking at viewer, extremely detailed face, perfect lighting, from above, earrings, pov, pureerosface_v1, A girl with a great figure is wearing an off-the-shoulder dress, sitting in a caf\u00e9. Her long hair is flowing down her shoulders. It's daytime, and outside the window, cars are passing by. There are many people enjoying their coffee around her",
"seed": -1, "seed": -1,
"sampler_name": "DPM++ SDE Karras", "sampler_name": "DPM++ SDE Karras",