JVice commited on
Commit
3844170
1 Parent(s): f6a6455

added table beautification

Browse files
Files changed (1) hide show
  1. general_bias_measurement.py +22 -19
general_bias_measurement.py CHANGED
@@ -211,37 +211,40 @@ def evaluate_t2i_model_images(images, prompts, progressBar, debugging, evalType)
211
  return (sortedDistributionBiasDict, normalisedDistribution, B_D, hallucinationBiases, CLIPMissRates, CLIPErrors)
212
  def output_eval_results(metrics, topX, evalType):
213
  sortedDistributionBiasList = list(metrics[0].items())
214
- # st.write(list(sortedDistributionBiasDict.values()))
215
-
216
-
217
- # sortedDistributionBiasList.insert(0, ('object', 'occurrences'))
 
 
 
 
 
 
 
 
 
218
  col1, col2 = st.columns([0.4,0.6])
219
  with col1:
220
  st.write("**Top** "+str(topX-1)+" **Detected Objects**")
221
- sortedDistributionBiasList.insert(0, ('object', 'occurrences'))
222
- st.table(sortedDistributionBiasList[:topX])
223
- # st.write("**Generative Error** $\\varepsilon$")
224
- # st.line_chart(sorted(metrics[5], reverse=True))
225
  with col2:
226
  st.write("**Distribution of Generated Objects (RAW)** - $B_D$")
227
  st.bar_chart(metrics[0].values(),color='#1D7AE2')
228
  st.write("**Distribution of Generated Objects (Normalised)** - $B_D$")
229
  st.bar_chart(metrics[1],color='#04FB97')
230
- # st.write("**Hallucination Bias** - $B_H$")
231
- # st.line_chart(sorted(metrics[3], reverse=True))
232
- # st.write("**Generative Miss Rate** $M_G$")
233
- # st.line_chart(sorted(metrics[4], reverse=True))
234
  if evalType == 'general':
235
  st.header("\U0001F30E General Bias Evaluation Results")
236
  else:
237
  st.header("\U0001F3AF Task-Oriented Bias Evaluation Results")
238
- st.table([["Distribution Bias",metrics[2]],["Jaccard Hallucination", np.mean(metrics[3])],
239
- ["Generative Miss Rate", np.mean(metrics[4])]])
240
- # st.write("Distribution Bias $B_D$ = ", B_D)
241
- # st.write("Jaccard Hallucination $H_J$ = ", np.mean(hallucinationBiases))
242
- # st.write("Generative Miss Rate $M_G$ = ", np.mean(CLIPMissRates))
243
- # st.write("Generative Error $\\varepsilon$ = ", np.mean(CLIPErrors))
244
- # progressBar.empty()
245
  def BLIP_captioning_single(image, gen_kwargs):
246
  caption = None
247
  inputs = BLIP_processor(image, return_tensors="pt").to(device)
 
211
  return (sortedDistributionBiasDict, normalisedDistribution, B_D, hallucinationBiases, CLIPMissRates, CLIPErrors)
212
  def output_eval_results(metrics, topX, evalType):
213
  sortedDistributionBiasList = list(metrics[0].items())
214
+ th_props = [
215
+ ('font-size', '16px'),
216
+ ('font-weight', 'bold'),
217
+ ('color', '#ffffff'),
218
+ ]
219
+ td_props = [
220
+ ('font-size', '14px')
221
+ ]
222
+
223
+ styles = [
224
+ dict(selector="th", props=th_props),
225
+ dict(selector="td", props=td_props)
226
+ ]
227
  col1, col2 = st.columns([0.4,0.6])
228
  with col1:
229
  st.write("**Top** "+str(topX-1)+" **Detected Objects**")
230
+ st.table(pd.DataFrame(sortedDistributionBiasList[:topX],
231
+ columns=['object', 'occurences'], index=[i+1 for i in range(topX)]
232
+ ).style.set_properties().set_table_styles(styles))
233
+
234
  with col2:
235
  st.write("**Distribution of Generated Objects (RAW)** - $B_D$")
236
  st.bar_chart(metrics[0].values(),color='#1D7AE2')
237
  st.write("**Distribution of Generated Objects (Normalised)** - $B_D$")
238
  st.bar_chart(metrics[1],color='#04FB97')
239
+
 
 
 
240
  if evalType == 'general':
241
  st.header("\U0001F30E General Bias Evaluation Results")
242
  else:
243
  st.header("\U0001F3AF Task-Oriented Bias Evaluation Results")
244
+
245
+ st.table(pd.DataFrame([["Distribution Bias",metrics[2]],["Jaccard Hallucination", np.mean(metrics[3])],
246
+ ["Generative Miss Rate", np.mean(metrics[4])]],
247
+ columns=['metric','value'], index=[' ' for i in range(3)]))
 
 
 
248
  def BLIP_captioning_single(image, gen_kwargs):
249
  caption = None
250
  inputs = BLIP_processor(image, return_tensors="pt").to(device)