Spaces:
Sleeping
Sleeping
Update my_model/results/demo.py
Browse files- my_model/results/demo.py +9 -2
my_model/results/demo.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import os
|
|
|
2 |
import altair as alt
|
3 |
from my_model.config import evaluation_config as config
|
4 |
import streamlit as st
|
@@ -40,6 +41,7 @@ class ResultDemonstrator:
|
|
40 |
"""
|
41 |
st.dataframe(data)
|
42 |
|
|
|
43 |
def calculate_and_append_data(self, data_list: list, score_column: str, model_config: str) -> None:
|
44 |
"""
|
45 |
Calculates mean scores by category and appends them to the data list.
|
@@ -57,7 +59,8 @@ class ResultDemonstrator:
|
|
57 |
"Configuration": model_config,
|
58 |
"Mean Value": round(mean_value * 100, 2)
|
59 |
})
|
60 |
-
|
|
|
61 |
def display_ablation_results_per_question_category(self) -> None:
|
62 |
"""Displays ablation results per question category for each model configuration."""
|
63 |
|
@@ -86,7 +89,8 @@ class ResultDemonstrator:
|
|
86 |
|
87 |
with st.expander(f"{score_type.upper()} Scores per Question Category and Model Configuration"):
|
88 |
self.display_table(results_df)
|
89 |
-
|
|
|
90 |
def display_main_results(self) -> None:
|
91 |
"""Displays the main model results from the Scores sheet, these are displayed from the file directly."""
|
92 |
main_scores = pd.read_excel(config.EVALUATION_DATA_PATH, sheet_name="Scores", index_col=0)
|
@@ -94,6 +98,7 @@ class ResultDemonstrator:
|
|
94 |
main_scores.reset_index()
|
95 |
self.display_table(main_scores)
|
96 |
|
|
|
97 |
def plot_token_count_vs_scores(self, conf: str, model_name: str, score_name: str = 'VQA Score') -> None:
|
98 |
"""
|
99 |
Plots an interactive scatter plot comparing token count to VQA or EM scores using Altair.
|
@@ -188,6 +193,8 @@ class ResultDemonstrator:
|
|
188 |
return 'color: orange;'
|
189 |
return 'color: black;'
|
190 |
|
|
|
|
|
191 |
def show_samples(self, num_samples: int = 3) -> None:
|
192 |
"""
|
193 |
Displays random sample images and their associated models answers and evaluations.
|
|
|
1 |
import os
|
2 |
+
from my_model.utilities.gen_utilities import log_function_call
|
3 |
import altair as alt
|
4 |
from my_model.config import evaluation_config as config
|
5 |
import streamlit as st
|
|
|
41 |
"""
|
42 |
st.dataframe(data)
|
43 |
|
44 |
+
@log_function_call
|
45 |
def calculate_and_append_data(self, data_list: list, score_column: str, model_config: str) -> None:
|
46 |
"""
|
47 |
Calculates mean scores by category and appends them to the data list.
|
|
|
59 |
"Configuration": model_config,
|
60 |
"Mean Value": round(mean_value * 100, 2)
|
61 |
})
|
62 |
+
|
63 |
+
@log_function_call
|
64 |
def display_ablation_results_per_question_category(self) -> None:
|
65 |
"""Displays ablation results per question category for each model configuration."""
|
66 |
|
|
|
89 |
|
90 |
with st.expander(f"{score_type.upper()} Scores per Question Category and Model Configuration"):
|
91 |
self.display_table(results_df)
|
92 |
+
|
93 |
+
@log_function_call
|
94 |
def display_main_results(self) -> None:
|
95 |
"""Displays the main model results from the Scores sheet, these are displayed from the file directly."""
|
96 |
main_scores = pd.read_excel(config.EVALUATION_DATA_PATH, sheet_name="Scores", index_col=0)
|
|
|
98 |
main_scores.reset_index()
|
99 |
self.display_table(main_scores)
|
100 |
|
101 |
+
@log_function_call
|
102 |
def plot_token_count_vs_scores(self, conf: str, model_name: str, score_name: str = 'VQA Score') -> None:
|
103 |
"""
|
104 |
Plots an interactive scatter plot comparing token count to VQA or EM scores using Altair.
|
|
|
193 |
return 'color: orange;'
|
194 |
return 'color: black;'
|
195 |
|
196 |
+
|
197 |
+
@log_function_call
|
198 |
def show_samples(self, num_samples: int = 3) -> None:
|
199 |
"""
|
200 |
Displays random sample images and their associated models answers and evaluations.
|