Spaces:
Running
Running
adding coloring but translucent
Browse files- __pycache__/about.cpython-310.pyc +0 -0
- about.py +9 -9
- app.py +36 -24
__pycache__/about.cpython-310.pyc
CHANGED
|
Binary files a/__pycache__/about.cpython-310.pyc and b/__pycache__/about.cpython-310.pyc differ
|
|
|
about.py
CHANGED
|
@@ -114,16 +114,16 @@ METRIC_GROUPS = {
|
|
| 114 |
],
|
| 115 |
}
|
| 116 |
|
| 117 |
-
# Color coding for metric families (background colors
|
| 118 |
METRIC_GROUP_COLORS = {
|
| 119 |
-
'Validity β': '
|
| 120 |
-
'Uniqueness & Novelty β': '
|
| 121 |
-
'Energy Metrics β': '
|
| 122 |
-
'Stability β': '
|
| 123 |
-
'Metastability β': '
|
| 124 |
-
'Distribution β': '
|
| 125 |
-
'Diversity β': '
|
| 126 |
-
'HHI β': '
|
| 127 |
}
|
| 128 |
|
| 129 |
# Map each column to its group for styling
|
|
|
|
| 114 |
],
|
| 115 |
}
|
| 116 |
|
| 117 |
+
# Color coding for metric families (background colors with transparency)
|
| 118 |
METRIC_GROUP_COLORS = {
|
| 119 |
+
'Validity β': 'rgba(33, 150, 243, 0.15)', # Light blue with transparency
|
| 120 |
+
'Uniqueness & Novelty β': 'rgba(156, 39, 176, 0.15)', # Light purple with transparency
|
| 121 |
+
'Energy Metrics β': 'rgba(255, 152, 0, 0.15)', # Light orange with transparency
|
| 122 |
+
'Stability β': 'rgba(76, 175, 80, 0.15)', # Light green with transparency
|
| 123 |
+
'Metastability β': 'rgba(139, 195, 74, 0.15)', # Light lime with transparency
|
| 124 |
+
'Distribution β': 'rgba(233, 30, 99, 0.15)', # Light pink with transparency
|
| 125 |
+
'Diversity β': 'rgba(0, 188, 212, 0.15)', # Light cyan with transparency
|
| 126 |
+
'HHI β': 'rgba(255, 193, 7, 0.15)', # Light amber with transparency
|
| 127 |
}
|
| 128 |
|
| 129 |
# Map each column to its group for styling
|
app.py
CHANGED
|
@@ -105,12 +105,39 @@ def show_output_box(message):
|
|
| 105 |
def submit_cif_files(problem_type, cif_files, profile: gr.OAuthProfile | None):
|
| 106 |
return
|
| 107 |
|
| 108 |
-
def
|
| 109 |
-
"""Generate HTML
|
| 110 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
for group, color in METRIC_GROUP_COLORS.items():
|
| 112 |
-
|
| 113 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
return html
|
| 115 |
|
| 116 |
def gradio_interface() -> gr.Blocks:
|
|
@@ -131,34 +158,19 @@ def gradio_interface() -> gr.Blocks:
|
|
| 131 |
)
|
| 132 |
with gr.Column(scale=1):
|
| 133 |
show_percentage = gr.Checkbox(
|
| 134 |
-
value=
|
| 135 |
label="Show as Percentages",
|
| 136 |
info="Display count-based metrics as percentages of total structures"
|
| 137 |
)
|
| 138 |
|
| 139 |
-
#
|
| 140 |
-
gr.HTML(generate_color_legend_html())
|
| 141 |
-
|
| 142 |
-
# Metric legend
|
| 143 |
with gr.Accordion("Metric Groups Legend", open=False):
|
| 144 |
-
|
| 145 |
-
| Group | Metrics | Direction |
|
| 146 |
-
|-------|---------|-----------|
|
| 147 |
-
| **Validity** | Valid, Charge Neutral, Distance Valid, Plausibility Valid | β Higher is better |
|
| 148 |
-
| **Uniqueness & Novelty** | Unique, Novel | β Higher is better |
|
| 149 |
-
| **Energy Metrics** | E Above Hull, Formation Energy, Relaxation RMSD (with std) | β Lower is better |
|
| 150 |
-
| **Stability** | Stable, Unique in Stable, SUN | β Higher is better |
|
| 151 |
-
| **Metastability** | Metastable, Unique in Metastable, MSUN | β Higher is better |
|
| 152 |
-
| **Distribution** | JS Distance, MMD, FID | β Lower is better |
|
| 153 |
-
| **Diversity** | Element, Space Group, Atomic Site, Crystal Size | β Higher is better |
|
| 154 |
-
| **HHI** | HHI Production, HHI Reserve | β Lower is better |
|
| 155 |
-
"""
|
| 156 |
-
gr.Markdown(legend_md)
|
| 157 |
|
| 158 |
try:
|
| 159 |
# Initial dataframe
|
| 160 |
initial_df = get_leaderboard()
|
| 161 |
-
formatted_df = format_dataframe(initial_df, show_percentage=
|
| 162 |
|
| 163 |
leaderboard_table = gr.Dataframe(
|
| 164 |
label="GenBench Leaderboard",
|
|
|
|
| 105 |
def submit_cif_files(problem_type, cif_files, profile: gr.OAuthProfile | None):
|
| 106 |
return
|
| 107 |
|
| 108 |
+
def generate_metric_legend_html():
|
| 109 |
+
"""Generate HTML table with color-coded metric group legend."""
|
| 110 |
+
metric_details = {
|
| 111 |
+
'Validity β': ('Valid, Charge Neutral, Distance Valid, Plausibility Valid', 'β Higher is better'),
|
| 112 |
+
'Uniqueness & Novelty β': ('Unique, Novel', 'β Higher is better'),
|
| 113 |
+
'Energy Metrics β': ('E Above Hull, Formation Energy, Relaxation RMSD (with std)', 'β Lower is better'),
|
| 114 |
+
'Stability β': ('Stable, Unique in Stable, SUN', 'β Higher is better'),
|
| 115 |
+
'Metastability β': ('Metastable, Unique in Metastable, MSUN', 'β Higher is better'),
|
| 116 |
+
'Distribution β': ('JS Distance, MMD, FID', 'β Lower is better'),
|
| 117 |
+
'Diversity β': ('Element, Space Group, Atomic Site, Crystal Size', 'β Higher is better'),
|
| 118 |
+
'HHI β': ('HHI Production, HHI Reserve', 'β Lower is better'),
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
html = '<table style="width: 100%; border-collapse: collapse;">'
|
| 122 |
+
html += '<thead><tr>'
|
| 123 |
+
html += '<th style="border: 1px solid #ddd; padding: 8px; text-align: left;">Color</th>'
|
| 124 |
+
html += '<th style="border: 1px solid #ddd; padding: 8px; text-align: left;">Group</th>'
|
| 125 |
+
html += '<th style="border: 1px solid #ddd; padding: 8px; text-align: left;">Metrics</th>'
|
| 126 |
+
html += '<th style="border: 1px solid #ddd; padding: 8px; text-align: left;">Direction</th>'
|
| 127 |
+
html += '</tr></thead><tbody>'
|
| 128 |
+
|
| 129 |
for group, color in METRIC_GROUP_COLORS.items():
|
| 130 |
+
metrics, direction = metric_details.get(group, ('', ''))
|
| 131 |
+
group_name = group.replace('β', '').replace('β', '').strip()
|
| 132 |
+
|
| 133 |
+
html += '<tr>'
|
| 134 |
+
html += f'<td style="border: 1px solid #ddd; padding: 8px;"><div style="width: 30px; height: 20px; background-color: {color}; border: 1px solid #999;"></div></td>'
|
| 135 |
+
html += f'<td style="border: 1px solid #ddd; padding: 8px;"><strong>{group_name}</strong></td>'
|
| 136 |
+
html += f'<td style="border: 1px solid #ddd; padding: 8px;">{metrics}</td>'
|
| 137 |
+
html += f'<td style="border: 1px solid #ddd; padding: 8px;">{direction}</td>'
|
| 138 |
+
html += '</tr>'
|
| 139 |
+
|
| 140 |
+
html += '</tbody></table>'
|
| 141 |
return html
|
| 142 |
|
| 143 |
def gradio_interface() -> gr.Blocks:
|
|
|
|
| 158 |
)
|
| 159 |
with gr.Column(scale=1):
|
| 160 |
show_percentage = gr.Checkbox(
|
| 161 |
+
value=True,
|
| 162 |
label="Show as Percentages",
|
| 163 |
info="Display count-based metrics as percentages of total structures"
|
| 164 |
)
|
| 165 |
|
| 166 |
+
# Metric legend with color coding
|
|
|
|
|
|
|
|
|
|
| 167 |
with gr.Accordion("Metric Groups Legend", open=False):
|
| 168 |
+
gr.HTML(generate_metric_legend_html())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 169 |
|
| 170 |
try:
|
| 171 |
# Initial dataframe
|
| 172 |
initial_df = get_leaderboard()
|
| 173 |
+
formatted_df = format_dataframe(initial_df, show_percentage=True, selected_groups=list(METRIC_GROUPS.keys()))
|
| 174 |
|
| 175 |
leaderboard_table = gr.Dataframe(
|
| 176 |
label="GenBench Leaderboard",
|