File size: 6,160 Bytes
612285f
 
 
 
 
 
 
 
055d5f4
9883bdb
 
 
 
055d5f4
 
 
 
754338e
9883bdb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
def get_sys_prompt(length="medium"):
    if length== "short":
        dev_prompt = """You are a museum curator tasked with generating alt-text (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 maximum of 130 characters."""
    elif length== "medium":
        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 between 250-300 characters in length."""
    else:
        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."""

def prompt_new(title=None,filename=None):
    if title == None:
        title_info = {}
    else:
        title_info = f"(titled: {title})"
        if filename:
            title_info = f"(filename metadata: {filename})"
    

    return f"Return text description for this image {title_info}:"
    
def prompt_1(title=None):
    if title == None:
        title_info = {}
    else:
        title_info = f"(titled: {title})"
    return f"The image {title_info} is part of a museum collection. Please give a short description of the museum object that will be used as alt-text. Do not discuss historical context other than what is included in the image. Don't mention the background, simply focus on describing the object in the image itself and try to avoid artistic interpretations and evaluative descriptions."

def context_prompt():

    prompt = """
    Additionally add a paragraph below starting with 'Additional context:' where you mention the broader context of the image. Mention additional information that will be useful when viewing this image considering race, sexuality, gender and class where relevant. This is a museum artifact and the description will be used for educational purposes.
    So it should have this format:
    main text

    Additional context: additional text

    The main text should be a maximum of 300 characters and the additional context should be a maximum of 120.
    """
    return prompt


def generate_prompt(title,category='Other',max_characters=450):
    pre_prompt = f"Keep language simple, plain and informative and limit responses to a maximum of {max_characters} characters. "

    def main_prompt(image='image',title=''):
        return f"This {image} (titled: {title}) is part of a museum collection. Please give a concise description of the {image} that will be used as alt-text for accessibility purposes. "
        #Please give a concise description of the garment that will be used as alt-text to make the museum more accessible to visually impaired people. Don't discuss historical context other than what is included in the image. Don't mention the background or setting, simply focus on describing the garment itself and try to avoid using artistic interpretations and evaluative descriptions.

    
    extra_prompt = "Do not explicitly state the title in the description. Do not discuss historical context other than what is included in the image. Avoid concluding statements. "
    extra_prompt2 = "Avoid artistic interpretations and evaluative descriptions. "
    background_prompt  = "Do not mention the background or setting, simply focus on describing the item itself. "
    bb = "keep the description clear, concise and direct to assist visually impaired users - avoid artistic interpretations and evaluative descriptions"
    
    if category == 'Clothing':
        prompt = main_prompt(image='garment',title=title)
        prompt += "Provide a concise, factual description of the garment, including its type, material, color, shape, notable design features, and any visible embellishments. "
        prompt += extra_prompt
        prompt += extra_prompt2
        
    elif category == 'Statue/Bust':
        prompt = main_prompt(image='sculpture',title=title)
        prompt += extra_prompt
        prompt += extra_prompt2
        prompt += background_prompt
        
    elif category == 'Painting/sketch':
        prompt = main_prompt(image='artwork',title=title)
        prompt += extra_prompt
        prompt += "Focus on providing a description of the artwork including its content and also briefly its style. "
        prompt += extra_prompt2

    elif category == 'Porcelain/Ceramic tableware':
        prompt = main_prompt(image='tablewear',title=title)
        prompt += "Describe its type (e.g., plate, bowl, teacup) and notable elements of it's appearance. "
        prompt += extra_prompt
        prompt += extra_prompt2
        prompt += background_prompt
       
    elif category == 'Text based document':
        prompt = main_prompt(image='image',title=title)
        prompt = "If the text is long do not include the whole text but summarise it. "
        prompt += extra_prompt
        prompt += extra_prompt2
    else:
        #prompt = main_prompt(image='image',title=title) + extra_prompt + extra_prompt2
        prompt = f"This image is titled: {title} and is part of a museum collection. Please give a concise description of the museum object that will be used as alt-text. Do not discuss historical context other than what is included in the image. Don't mention the background, simply focus on describing the object in the image itself and try to avoid artistic interpretations and evaluative descriptions."

    return pre_prompt + prompt