Spaces:
				
			
			
	
			
			
					
		Running
		
			on 
			
			CPU Upgrade
	
	
	
			
			
	
	
	
	
		
		
					
		Running
		
			on 
			
			CPU Upgrade
	more formatting
Browse files- app.py +33 -25
- content.py +12 -2
    	
        app.py
    CHANGED
    
    | @@ -71,6 +71,8 @@ class LeaderboardData: | |
| 71 | 
             
                def __init__(self):
         | 
| 72 | 
             
                    self._setup_data_paths()
         | 
| 73 | 
             
                    self._load_contact_info()
         | 
|  | |
|  | |
| 74 |  | 
| 75 | 
             
                def _setup_data_paths(self):
         | 
| 76 | 
             
                    """
         | 
| @@ -122,6 +124,9 @@ class LeaderboardData: | |
| 122 | 
             
                    """
         | 
| 123 | 
             
                    Load all evaluation data and return results and dataframes.
         | 
| 124 | 
             
                    """
         | 
|  | |
|  | |
|  | |
| 125 | 
             
                    # Load S2EF results
         | 
| 126 | 
             
                    s2ef_results = load_dataset(
         | 
| 127 | 
             
                        RESULTS_DATASET,
         | 
| @@ -148,7 +153,6 @@ class LeaderboardData: | |
| 148 |  | 
| 149 | 
             
                    # Generate result dataframes
         | 
| 150 | 
             
                    results_dfs = {}
         | 
| 151 | 
            -
             | 
| 152 | 
             
                    # S2EF dataframes
         | 
| 153 | 
             
                    for split in ["Validation", "Test"]:
         | 
| 154 | 
             
                        for subsplit in S2EF_SUBSPLITS:
         | 
| @@ -161,6 +165,10 @@ class LeaderboardData: | |
| 161 | 
             
                    for split in OTHER_EVAL_TYPES:
         | 
| 162 | 
             
                        results_dfs[split] = self._get_eval_df_from_results(eval_results, split)
         | 
| 163 |  | 
|  | |
|  | |
|  | |
|  | |
| 164 | 
             
                    return eval_results, results_dfs
         | 
| 165 |  | 
| 166 | 
             
                def _get_s2ef_df_from_results(
         | 
| @@ -495,7 +503,7 @@ def create_overview_dataframe(results_dfs: Dict[str, pd.DataFrame]) -> pd.DataFr | |
| 495 | 
             
                overview_data = {
         | 
| 496 | 
             
                    "Model": [],
         | 
| 497 | 
             
                    "Organization": [],
         | 
| 498 | 
            -
                    "Energy | 
| 499 | 
             
                    "Training Set": [],
         | 
| 500 | 
             
                }
         | 
| 501 |  | 
| @@ -523,7 +531,7 @@ def create_overview_dataframe(results_dfs: Dict[str, pd.DataFrame]) -> pd.DataFr | |
| 523 |  | 
| 524 | 
             
                    overview_data["Model"].append(entry_info["Model"])
         | 
| 525 | 
             
                    overview_data["Organization"].append(entry_info["Organization"])
         | 
| 526 | 
            -
                    overview_data["Energy | 
| 527 | 
             
                    overview_data["Training Set"].append(entry_info["Training Set"])
         | 
| 528 |  | 
| 529 | 
             
                    # Fill in metrics for each column
         | 
| @@ -557,7 +565,7 @@ def create_overview_dataframe(results_dfs: Dict[str, pd.DataFrame]) -> pd.DataFr | |
| 557 | 
             
                    # Calculate mean across columns, ignoring NaN values
         | 
| 558 | 
             
                    avg_scores = numeric_metrics.mean(axis=1)
         | 
| 559 | 
             
                    # Sort by average score (ascending for MAE metrics)
         | 
| 560 | 
            -
                    overview_df = overview_df.loc[avg_scores.sort_values( | 
| 561 |  | 
| 562 | 
             
                return overview_df
         | 
| 563 |  | 
| @@ -637,6 +645,11 @@ def create_interface() -> gr.Blocks: | |
| 637 | 
             
                            gr.Markdown(CITATION_BUTTON_LABEL)
         | 
| 638 | 
             
                            gr.Markdown(CITATION_BUTTON_TEXT)
         | 
| 639 |  | 
|  | |
|  | |
|  | |
|  | |
|  | |
| 640 | 
             
                    # S2EF Results tabs
         | 
| 641 | 
             
                    gr.Markdown("## S2EF", elem_classes="markdown-text")
         | 
| 642 | 
             
                    with gr.Tab("Test"):
         | 
| @@ -645,11 +658,6 @@ def create_interface() -> gr.Blocks: | |
| 645 | 
             
                    with gr.Tab("Validation"):
         | 
| 646 | 
             
                        create_s2ef_tabs("Validation", results_dfs)
         | 
| 647 |  | 
| 648 | 
            -
                    # Evaluation results
         | 
| 649 | 
            -
                    gr.Markdown("## Evaluations", elem_classes="markdown-text")
         | 
| 650 | 
            -
                    with gr.Row():
         | 
| 651 | 
            -
                        create_evaluation_tabs(results_dfs)
         | 
| 652 | 
            -
             | 
| 653 | 
             
                    (
         | 
| 654 | 
             
                        submit_button,
         | 
| 655 | 
             
                        file_output,
         | 
| @@ -665,22 +673,22 @@ def create_interface() -> gr.Blocks: | |
| 665 | 
             
                        submission_result,
         | 
| 666 | 
             
                    ) = create_submission_interface()
         | 
| 667 |  | 
| 668 | 
            -
                     | 
| 669 | 
            -
             | 
| 670 | 
            -
             | 
| 671 | 
            -
             | 
| 672 | 
            -
             | 
| 673 | 
            -
             | 
| 674 | 
            -
             | 
| 675 | 
            -
             | 
| 676 | 
            -
             | 
| 677 | 
            -
             | 
| 678 | 
            -
             | 
| 679 | 
            -
             | 
| 680 | 
            -
             | 
| 681 | 
            -
             | 
| 682 | 
            -
             | 
| 683 | 
            -
                     | 
| 684 |  | 
| 685 | 
             
                return demo
         | 
| 686 |  | 
|  | |
| 71 | 
             
                def __init__(self):
         | 
| 72 | 
             
                    self._setup_data_paths()
         | 
| 73 | 
             
                    self._load_contact_info()
         | 
| 74 | 
            +
                    self._eval_results = None
         | 
| 75 | 
            +
                    self._results_dfs = None
         | 
| 76 |  | 
| 77 | 
             
                def _setup_data_paths(self):
         | 
| 78 | 
             
                    """
         | 
|  | |
| 124 | 
             
                    """
         | 
| 125 | 
             
                    Load all evaluation data and return results and dataframes.
         | 
| 126 | 
             
                    """
         | 
| 127 | 
            +
                    if self._eval_results is not None and self._results_dfs is not None:
         | 
| 128 | 
            +
                        return self._eval_results, self._results_dfs
         | 
| 129 | 
            +
             | 
| 130 | 
             
                    # Load S2EF results
         | 
| 131 | 
             
                    s2ef_results = load_dataset(
         | 
| 132 | 
             
                        RESULTS_DATASET,
         | 
|  | |
| 153 |  | 
| 154 | 
             
                    # Generate result dataframes
         | 
| 155 | 
             
                    results_dfs = {}
         | 
|  | |
| 156 | 
             
                    # S2EF dataframes
         | 
| 157 | 
             
                    for split in ["Validation", "Test"]:
         | 
| 158 | 
             
                        for subsplit in S2EF_SUBSPLITS:
         | 
|  | |
| 165 | 
             
                    for split in OTHER_EVAL_TYPES:
         | 
| 166 | 
             
                        results_dfs[split] = self._get_eval_df_from_results(eval_results, split)
         | 
| 167 |  | 
| 168 | 
            +
                    # Cache the results
         | 
| 169 | 
            +
                    self._eval_results = eval_results
         | 
| 170 | 
            +
                    self._results_dfs = results_dfs
         | 
| 171 | 
            +
             | 
| 172 | 
             
                    return eval_results, results_dfs
         | 
| 173 |  | 
| 174 | 
             
                def _get_s2ef_df_from_results(
         | 
|  | |
| 503 | 
             
                overview_data = {
         | 
| 504 | 
             
                    "Model": [],
         | 
| 505 | 
             
                    "Organization": [],
         | 
| 506 | 
            +
                    "Energy\nConserving": [],
         | 
| 507 | 
             
                    "Training Set": [],
         | 
| 508 | 
             
                }
         | 
| 509 |  | 
|  | |
| 531 |  | 
| 532 | 
             
                    overview_data["Model"].append(entry_info["Model"])
         | 
| 533 | 
             
                    overview_data["Organization"].append(entry_info["Organization"])
         | 
| 534 | 
            +
                    overview_data["Energy\nConserving"].append(entry_info["Energy Conserving"])
         | 
| 535 | 
             
                    overview_data["Training Set"].append(entry_info["Training Set"])
         | 
| 536 |  | 
| 537 | 
             
                    # Fill in metrics for each column
         | 
|  | |
| 565 | 
             
                    # Calculate mean across columns, ignoring NaN values
         | 
| 566 | 
             
                    avg_scores = numeric_metrics.mean(axis=1)
         | 
| 567 | 
             
                    # Sort by average score (ascending for MAE metrics)
         | 
| 568 | 
            +
                    overview_df = overview_df.loc[avg_scores.sort_values().index]
         | 
| 569 |  | 
| 570 | 
             
                return overview_df
         | 
| 571 |  | 
|  | |
| 645 | 
             
                            gr.Markdown(CITATION_BUTTON_LABEL)
         | 
| 646 | 
             
                            gr.Markdown(CITATION_BUTTON_TEXT)
         | 
| 647 |  | 
| 648 | 
            +
                    # Evaluation results
         | 
| 649 | 
            +
                    gr.Markdown("## Evaluations", elem_classes="markdown-text")
         | 
| 650 | 
            +
                    with gr.Row():
         | 
| 651 | 
            +
                        create_evaluation_tabs(results_dfs)
         | 
| 652 | 
            +
             | 
| 653 | 
             
                    # S2EF Results tabs
         | 
| 654 | 
             
                    gr.Markdown("## S2EF", elem_classes="markdown-text")
         | 
| 655 | 
             
                    with gr.Tab("Test"):
         | 
|  | |
| 658 | 
             
                    with gr.Tab("Validation"):
         | 
| 659 | 
             
                        create_s2ef_tabs("Validation", results_dfs)
         | 
| 660 |  | 
|  | |
|  | |
|  | |
|  | |
|  | |
| 661 | 
             
                    (
         | 
| 662 | 
             
                        submit_button,
         | 
| 663 | 
             
                        file_output,
         | 
|  | |
| 673 | 
             
                        submission_result,
         | 
| 674 | 
             
                    ) = create_submission_interface()
         | 
| 675 |  | 
| 676 | 
            +
                    submit_button.click(
         | 
| 677 | 
            +
                        add_new_eval,
         | 
| 678 | 
            +
                        [
         | 
| 679 | 
            +
                            file_output,
         | 
| 680 | 
            +
                            eval_type,
         | 
| 681 | 
            +
                            organization,
         | 
| 682 | 
            +
                            model_name_textbox,
         | 
| 683 | 
            +
                            model_url,
         | 
| 684 | 
            +
                            paper_url,
         | 
| 685 | 
            +
                            energy_conserving,
         | 
| 686 | 
            +
                            mail,
         | 
| 687 | 
            +
                            dataset,
         | 
| 688 | 
            +
                            additional_info,
         | 
| 689 | 
            +
                        ],
         | 
| 690 | 
            +
                        submission_result,
         | 
| 691 | 
            +
                    )
         | 
| 692 |  | 
| 693 | 
             
                return demo
         | 
| 694 |  | 
    	
        content.py
    CHANGED
    
    | @@ -68,8 +68,18 @@ TYPES = ["markdown", "str", "bool", "str"] | |
| 68 |  | 
| 69 | 
             
            def model_hyperlink(model_link: str, paper_link: str, model_name: str) -> str:
         | 
| 70 | 
             
                """Create a hyperlink for model names in the leaderboard."""
         | 
| 71 | 
            -
             | 
|  | |
|  | |
|  | |
|  | |
|  | |
| 72 | 
             
                    return model_name
         | 
| 73 | 
            -
             | 
|  | |
| 74 | 
             
                    return f'<a target="_blank" href="{model_link}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;" title="Download model">{model_name}</a>'
         | 
|  | |
|  | |
|  | |
|  | |
| 75 | 
             
                return f'<a target="_blank" href="{model_link}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;" title="Download model">{model_name}</a> <a target="_blank" href="{paper_link}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;" title="Read paper">π</a>'
         | 
|  | |
| 68 |  | 
| 69 | 
             
            def model_hyperlink(model_link: str, paper_link: str, model_name: str) -> str:
         | 
| 70 | 
             
                """Create a hyperlink for model names in the leaderboard."""
         | 
| 71 | 
            +
             | 
| 72 | 
            +
                # Check if we have valid links
         | 
| 73 | 
            +
                has_model_link = model_link and model_link.strip() != ""
         | 
| 74 | 
            +
                has_paper_link = paper_link and paper_link.strip() != ""
         | 
| 75 | 
            +
             | 
| 76 | 
            +
                if not has_model_link and not has_paper_link:
         | 
| 77 | 
             
                    return model_name
         | 
| 78 | 
            +
             | 
| 79 | 
            +
                if has_model_link and not has_paper_link:
         | 
| 80 | 
             
                    return f'<a target="_blank" href="{model_link}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;" title="Download model">{model_name}</a>'
         | 
| 81 | 
            +
             | 
| 82 | 
            +
                if not has_model_link and has_paper_link:
         | 
| 83 | 
            +
                    return f'{model_name} <a target="_blank" href="{paper_link}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;" title="Read paper">π</a>'
         | 
| 84 | 
            +
             | 
| 85 | 
             
                return f'<a target="_blank" href="{model_link}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;" title="Download model">{model_name}</a> <a target="_blank" href="{paper_link}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;" title="Read paper">π</a>'
         | 

