mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 17:24:32 +02:00
fix prompt enhance api with vision
Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
@@ -144,6 +144,12 @@ class Options:
|
||||
Keep the result faithful to the original prompt and the intended image.
|
||||
Do not add unrelated concepts, non-visual commentary, or fluff.
|
||||
''')
|
||||
t2i_noprompt: str = textwrap.dedent('''\
|
||||
You are an expert AI image prompt engineer.
|
||||
Create an original, imaginative and visually rich prompt for image generation.
|
||||
Be Creative!
|
||||
Use concrete, image-generation language and avoid unrelated fluff or commentary.
|
||||
''')
|
||||
i2i_prompt: str = textwrap.dedent('''\
|
||||
You are an expert AI image prompt engineer.
|
||||
You will receive an image and a user prompt for editing or refinement.
|
||||
@@ -159,6 +165,7 @@ class Options:
|
||||
Base the prompt on what is present in the image, its style, and its atmosphere.
|
||||
Use concrete, image-generation language and avoid unrelated fluff or commentary.
|
||||
''')
|
||||
|
||||
t2v_prompt: str = textwrap.dedent('''\
|
||||
You are an expert AI video prompt engineer.
|
||||
You will receive a user prompt for video generation.
|
||||
@@ -185,6 +192,7 @@ class Options:
|
||||
Specify subject and camera movement, scene transitions, and temporal dynamics.
|
||||
Use concrete, video-generation language and avoid unrelated fluff or commentary.
|
||||
''')
|
||||
|
||||
nsfw_ok: str = textwrap.dedent('''\
|
||||
NSFW, nudity and explicit content and language are allowed.
|
||||
''')
|
||||
|
||||
@@ -85,15 +85,16 @@ def set_template(
|
||||
has_image = image is not None and isinstance(image, Image.Image)
|
||||
is_video = module == 'video'
|
||||
|
||||
debug_log(f'Prompt enhance template: module={module} prompt={has_prompt} image={has_image} video={is_video} model="{model}" nsfw={nsfw} processor={has_processor}')
|
||||
debug_log(f'Prompt enhance template: module={module} prompt={has_prompt} image={has_image} video={is_video} model="{model}" nsfw={nsfw} processor={has_processor} cloud={is_cloud_model(model)}')
|
||||
|
||||
"""
|
||||
if has_image:
|
||||
if is_cloud_model(model):
|
||||
pass
|
||||
elif options.processor is None:
|
||||
elif not has_processor:
|
||||
log.error('Prompt enhance: image not supported by model')
|
||||
return prompt if prompt is not None else '' # Return original text part if image cannot be processed
|
||||
|
||||
"""
|
||||
if has_image:
|
||||
chat_template = get_image_template(system, prompt, options, nsfw, has_prompt, has_processor, is_video, image)
|
||||
else:
|
||||
|
||||
@@ -325,11 +325,8 @@ class PromptEnhanceScript(scripts_manager.Script):
|
||||
# Strip symbols from model name if present
|
||||
model = get_model_repo_from_display(model) if model else self.options.default
|
||||
prompt = prompt or (self.prompt.value if self.prompt else "") # Check if self.prompt is None
|
||||
image = None
|
||||
if use_vision and is_vision_model(model): # handle vision toggle
|
||||
image = image or self.image
|
||||
if image is None:
|
||||
use_vision = False
|
||||
prefix = prefix or ''
|
||||
suffix = suffix or ''
|
||||
min_tokens = min_tokens or self.options.min_tokens
|
||||
@@ -363,7 +360,9 @@ class PromptEnhanceScript(scripts_manager.Script):
|
||||
# Only process images if vision is enabled and model supports it
|
||||
if use_vision and is_vision_model(model):
|
||||
current_image = self.get_image(image)
|
||||
debug_log(f'Prompt enhance: image={current_image}')
|
||||
if current_image is None:
|
||||
use_vision = False
|
||||
debug_log(f'Prompt enhance: image={current_image} use_vision={use_vision}')
|
||||
|
||||
# Check if vision was requested but no image is available
|
||||
if use_vision and is_vision_model(model) and current_image is None:
|
||||
|
||||
Reference in New Issue
Block a user