brianjking commited on
Commit
d538145
1 Parent(s): cfcf949

update theme, fix percentages for dataframe test display, update test statements

Browse files
Files changed (1) hide show
  1. app.py +16 -13
app.py CHANGED
@@ -39,25 +39,25 @@ def compute_textual_similarity(caption, statement):
39
 
40
  # List of statements for Image-Text Matching
41
  statements = [
42
- "contains a cartoon, figurine, or toy",
43
- "is for children",
44
- "children",
45
  "sexual",
46
- "depicts a child or portrays objects, images, or cartoon figures that primarily appeal to persons below the legal purchase age of alcohol",
47
- "uses the name of or displays Santa Claus",
 
48
  'promotes alcohol use as a "rite of passage" to adulthood',
49
- "uses brand identification—including logos, trademarks, or names—on clothing, toys, games, game equipment, or other items intended for use primarily by persons below the legal purchase age of alcohol",
50
  "portrays persons in a state of intoxication or in any way suggests that intoxication is socially acceptable conduct",
51
- "makes curative or therapeutic claims",
52
  "makes claims or representations that individuals can attain social, professional, educational, or athletic success or status due to beverage alcohol consumption",
53
  "degrades the image, form, or status of women, men, or of any ethnic group, minority, sexual orientation, religious affiliation, or other such group?",
54
  "uses lewd or indecent images or language",
55
- "employs religion or religious themes",
56
  "relies upon sexual prowess or sexual success as a selling point for the brand",
57
  "uses graphic or gratuitous nudity, overt sexual activity, promiscuity, or sexually lewd or indecent images or language",
58
  "associates with anti-social or dangerous behavior",
59
- "depicts illegal activity of any kind?",
60
- "illegal activity",
61
  'uses the term "spring break" or sponsors events or activities that use the term "spring break," unless those events or activities are located at a licensed retail establishment',
62
  ]
63
 
@@ -104,13 +104,15 @@ def process_images_and_statements(image):
104
  itm_score_statement = compute_itm_score(image, statement)
105
 
106
  # Combine the two scores using a weighted average
107
- final_score = (weight_textual_similarity * textual_similarity_score) + (weight_statement * itm_score_statement)
 
 
108
 
109
  # Append the result to the DataFrame
110
  results_df = results_df.append({
111
  'Statement': statement,
112
- 'Textual Similarity Score': textual_similarity_score,
113
- 'ITM Score': itm_score_statement,
114
  'Final Combined Score': final_score
115
  }, ignore_index=True)
116
 
@@ -128,6 +130,7 @@ iface = gr.Interface(
128
  inputs=image_input,
129
  outputs=output,
130
  title="Image Captioning and Image-Text Matching",
 
131
  css=".output { flex-direction: column; } .output .outputs { width: 100%; }" # Custom CSS
132
  )
133
 
 
39
 
40
  # List of statements for Image-Text Matching
41
  statements = [
42
+ "contains or features a cartoon, figurine, or toy",
43
+ "appears to be for children",
44
+ "includes children",
45
  "sexual",
46
+ "nudity",
47
+ "depicts a child or portrays objects, images, or cartoon figures that primarily appeal to persons below the legal purchase age",
48
+ "uses the name of or depicts Santa Claus",
49
  'promotes alcohol use as a "rite of passage" to adulthood',
50
+ "uses brand identification—including logos, trademarks, or names—on clothing, toys, games, game equipment, or other items intended for use primarily by persons below the legal purchase age",
51
  "portrays persons in a state of intoxication or in any way suggests that intoxication is socially acceptable conduct",
52
+ "makes curative or therapeutic claims, except as permitted by law",
53
  "makes claims or representations that individuals can attain social, professional, educational, or athletic success or status due to beverage alcohol consumption",
54
  "degrades the image, form, or status of women, men, or of any ethnic group, minority, sexual orientation, religious affiliation, or other such group?",
55
  "uses lewd or indecent images or language",
56
+ "employs religion or religious themes?",
57
  "relies upon sexual prowess or sexual success as a selling point for the brand",
58
  "uses graphic or gratuitous nudity, overt sexual activity, promiscuity, or sexually lewd or indecent images or language",
59
  "associates with anti-social or dangerous behavior",
60
+ "depicts illegal activity",
 
61
  'uses the term "spring break" or sponsors events or activities that use the term "spring break," unless those events or activities are located at a licensed retail establishment',
62
  ]
63
 
 
104
  itm_score_statement = compute_itm_score(image, statement)
105
 
106
  # Combine the two scores using a weighted average
107
+ #final_score = (weight_textual_similarity * textual_similarity_score) + (weight_statement * itm_score_statement)
108
+ final_score = ((weight_textual_similarity * textual_similarity_score) +
109
+ (weight_statement * itm_score_statement)) * 100 # Multiply by 100
110
 
111
  # Append the result to the DataFrame
112
  results_df = results_df.append({
113
  'Statement': statement,
114
+ 'Textual Similarity Score': textual_similarity_score * 100, # Multiply by 100
115
+ 'ITM Score': itm_score_statement * 100, # Multiply by 100
116
  'Final Combined Score': final_score
117
  }, ignore_index=True)
118
 
 
130
  inputs=image_input,
131
  outputs=output,
132
  title="Image Captioning and Image-Text Matching",
133
+ theme='sudeepshouche/minimalist',
134
  css=".output { flex-direction: column; } .output .outputs { width: 100%; }" # Custom CSS
135
  )
136