cgeorgiaw HF Staff commited on
Commit
134e659
Β·
1 Parent(s): ed922f9

adding coloring but translucent

Browse files
Files changed (3) hide show
  1. __pycache__/about.cpython-310.pyc +0 -0
  2. about.py +9 -9
  3. 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 for headers)
118
  METRIC_GROUP_COLORS = {
119
- 'Validity ↑': '#e3f2fd', # Light blue
120
- 'Uniqueness & Novelty ↑': '#f3e5f5', # Light purple
121
- 'Energy Metrics ↓': '#fff3e0', # Light orange
122
- 'Stability ↑': '#e8f5e9', # Light green
123
- 'Metastability ↑': '#f1f8e9', # Light lime
124
- 'Distribution ↓': '#fce4ec', # Light pink
125
- 'Diversity ↑': '#e0f7fa', # Light cyan
126
- 'HHI ↓': '#fff8e1', # Light amber
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 generate_color_legend_html():
109
- """Generate HTML for color-coded metric group legend."""
110
- html = '<div style="display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px;">'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111
  for group, color in METRIC_GROUP_COLORS.items():
112
- html += f'<span style="background-color: {color}; padding: 4px 8px; border-radius: 4px; font-size: 12px;">{group}</span>'
113
- html += '</div>'
 
 
 
 
 
 
 
 
 
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=False,
135
  label="Show as Percentages",
136
  info="Display count-based metrics as percentages of total structures"
137
  )
138
 
139
- # Color-coded legend
140
- gr.HTML(generate_color_legend_html())
141
-
142
- # Metric legend
143
  with gr.Accordion("Metric Groups Legend", open=False):
144
- legend_md = """
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=False, selected_groups=list(METRIC_GROUPS.keys()))
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",