update message
Browse files- app.py +10 -3
- library/utils_prompt.py +5 -1
app.py
CHANGED
|
@@ -55,7 +55,7 @@ additional_models = [
|
|
| 55 |
# Calculate all models once
|
| 56 |
all_models_list = preferred_models_auth + additional_models
|
| 57 |
|
| 58 |
-
def get_sys_prompt(length="medium", photograph=False):
|
| 59 |
extra_prompt = ""
|
| 60 |
|
| 61 |
if photograph:
|
|
@@ -160,7 +160,7 @@ def create_demo():
|
|
| 160 |
default_model = "meta-llama/llama-4-maverick:free"#preferred_models[0][1] # get free model
|
| 161 |
text = f"""**Current Model**: Llama 4 Maverick (free)
|
| 162 |
**Estimated cost per 100 Images**: {MODEL_PRICING["meta-llama/llama-4-maverick:free"]}"""
|
| 163 |
-
return gr.update(choices=preferred_models, label="Select Model",value=default_model),text,""
|
| 164 |
|
| 165 |
is_authorized = profile.username in AUTHORIZED_USER_IDS
|
| 166 |
if is_authorized:
|
|
@@ -216,6 +216,12 @@ def create_demo():
|
|
| 216 |
value="Museum Object"
|
| 217 |
)
|
| 218 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 219 |
#markdown for current model costings
|
| 220 |
model_info = gr.Markdown("",
|
| 221 |
elem_id="model-info-display"
|
|
@@ -351,7 +357,8 @@ def create_demo():
|
|
| 351 |
image_id = filenames[i] if i < len(filenames) and filenames[i] else f"Image_{i+1}_{os.path.basename(image_path)}"
|
| 352 |
try:
|
| 353 |
img = Image.open(image_path)
|
| 354 |
-
|
|
|
|
| 355 |
model_name = model_choice
|
| 356 |
client_to_use = OR # Default client
|
| 357 |
|
|
|
|
| 55 |
# Calculate all models once
|
| 56 |
all_models_list = preferred_models_auth + additional_models
|
| 57 |
|
| 58 |
+
def get_sys_prompt(length="medium", photograph=False,filename=""):
|
| 59 |
extra_prompt = ""
|
| 60 |
|
| 61 |
if photograph:
|
|
|
|
| 160 |
default_model = "meta-llama/llama-4-maverick:free"#preferred_models[0][1] # get free model
|
| 161 |
text = f"""**Current Model**: Llama 4 Maverick (free)
|
| 162 |
**Estimated cost per 100 Images**: {MODEL_PRICING["meta-llama/llama-4-maverick:free"]}"""
|
| 163 |
+
return gr.update(choices=preferred_models, label="Select Model",value=default_model),text,"Free version - please email chris.addis@nhm.ac.uk about full access."""
|
| 164 |
|
| 165 |
is_authorized = profile.username in AUTHORIZED_USER_IDS
|
| 166 |
if is_authorized:
|
|
|
|
| 216 |
value="Museum Object"
|
| 217 |
)
|
| 218 |
|
| 219 |
+
use_filename_in_prompt = gr.Checkbox(
|
| 220 |
+
label="Include filename in user prompt",
|
| 221 |
+
value=False,
|
| 222 |
+
info="Include the image's filename as metadata"
|
| 223 |
+
)
|
| 224 |
+
|
| 225 |
#markdown for current model costings
|
| 226 |
model_info = gr.Markdown("",
|
| 227 |
elem_id="model-info-display"
|
|
|
|
| 357 |
image_id = filenames[i] if i < len(filenames) and filenames[i] else f"Image_{i+1}_{os.path.basename(image_path)}"
|
| 358 |
try:
|
| 359 |
img = Image.open(image_path)
|
| 360 |
+
user_prompt_filename = image_id if use_filename_in_prompt else None
|
| 361 |
+
prompt0 = prompt_new(user_prompt_filename)
|
| 362 |
model_name = model_choice
|
| 363 |
client_to_use = OR # Default client
|
| 364 |
|
library/utils_prompt.py
CHANGED
|
@@ -6,11 +6,15 @@ def get_sys_prompt(length="medium"):
|
|
| 6 |
else:
|
| 7 |
dev_prompt = """You are a museum curator tasked with generating long descriptions (as defined in WCAG 2.1) of museum objects for visually impaired and blind users from images. Use British English and follow museum accessibility best practices. Do not start with phrases like 'The image shows' or 'This is an image of'. Be precise, concise and avoid filler and subjective statements. Repsonses should be a maxium of 450 characters."""
|
| 8 |
|
| 9 |
-
def prompt_new(title=None):
|
| 10 |
if title == None:
|
| 11 |
title_info = {}
|
| 12 |
else:
|
| 13 |
title_info = f"(titled: {title})"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
return f"Return text description for this image {title_info}:"
|
| 15 |
|
| 16 |
def prompt_1(title=None):
|
|
|
|
| 6 |
else:
|
| 7 |
dev_prompt = """You are a museum curator tasked with generating long descriptions (as defined in WCAG 2.1) of museum objects for visually impaired and blind users from images. Use British English and follow museum accessibility best practices. Do not start with phrases like 'The image shows' or 'This is an image of'. Be precise, concise and avoid filler and subjective statements. Repsonses should be a maxium of 450 characters."""
|
| 8 |
|
| 9 |
+
def prompt_new(title=None,filename=None):
|
| 10 |
if title == None:
|
| 11 |
title_info = {}
|
| 12 |
else:
|
| 13 |
title_info = f"(titled: {title})"
|
| 14 |
+
if filename:
|
| 15 |
+
title_info = f"(filename metadata: {filename})"
|
| 16 |
+
|
| 17 |
+
|
| 18 |
return f"Return text description for this image {title_info}:"
|
| 19 |
|
| 20 |
def prompt_1(title=None):
|