Spaces:
Sleeping
Sleeping
added table beautification
Browse files- 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 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
218 |
col1, col2 = st.columns([0.4,0.6])
|
219 |
with col1:
|
220 |
st.write("**Top** "+str(topX-1)+" **Detected Objects**")
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
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 |
-
|
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 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
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)
|