wip
Browse files- app.py +117 -224
 - src/about.py +12 -11
 
    	
        app.py
    CHANGED
    
    | 
         @@ -8,7 +8,6 @@ from pathlib import Path 
     | 
|
| 8 | 
         
             
            from apscheduler.schedulers.background import BackgroundScheduler
         
     | 
| 9 | 
         
             
            from huggingface_hub import snapshot_download
         
     | 
| 10 | 
         | 
| 11 | 
         
            -
             
     | 
| 12 | 
         
             
            from src.about import (
         
     | 
| 13 | 
         
             
                CITATION_BUTTON_LABEL,
         
     | 
| 14 | 
         
             
                CITATION_BUTTON_TEXT,
         
     | 
| 
         @@ -19,268 +18,162 @@ from src.about import ( 
     | 
|
| 19 | 
         
             
                ABOUT_TEXT
         
     | 
| 20 | 
         
             
            )
         
     | 
| 21 | 
         
             
            from src.display.css_html_js import custom_css
         
     | 
| 22 | 
         
            -
             
     | 
| 23 | 
         
            -
             
     | 
| 24 | 
         
            -
            # 
     | 
| 25 | 
         
            -
             
     | 
| 26 | 
         
            -
             
     | 
| 27 | 
         
            -
             
     | 
| 28 | 
         
            -
             
     | 
| 29 | 
         
            -
             
     | 
| 30 | 
         
            -
             
     | 
| 31 | 
         
            -
             
     | 
| 32 | 
         
            -
             
     | 
| 33 | 
         
            -
            #     Precision
         
     | 
| 34 | 
         
            -
            # )
         
     | 
| 35 | 
         
            -
            from src.envs import API, EVAL_REQUESTS_PATH, EVAL_RESULTS_PATH, QUEUE_REPO, REPO_ID, RESULTS_REPO, TOKEN
         
     | 
| 36 | 
         
            -
             
     | 
| 37 | 
         
            -
            try:
         
     | 
| 38 | 
         
            -
                print(EVAL_RESULTS_PATH)
         
     | 
| 39 | 
         
            -
                snapshot_download(
         
     | 
| 40 | 
         
            -
                    repo_id=RESULTS_REPO, local_dir=EVAL_RESULTS_PATH, repo_type="dataset", tqdm_class=None, etag_timeout=30, token=TOKEN
         
     | 
| 41 | 
         
            -
                )
         
     | 
| 42 | 
         
            -
            except Exception:
         
     | 
| 43 | 
         
            -
                pass
         
     | 
| 44 | 
         
            -
                # restart_space()
         
     | 
| 45 | 
         
            -
             
     | 
| 46 | 
         
            -
            SUBSET_COUNTS = {
         
     | 
| 47 | 
         
            -
                "Alignment-Object": 250,
         
     | 
| 48 | 
         
            -
                "Alignment-Attribute": 229,
         
     | 
| 49 | 
         
            -
                "Alignment-Action": 115,
         
     | 
| 50 | 
         
            -
                "Alignment-Count": 55,
         
     | 
| 51 | 
         
            -
                "Alignment-Location": 75,
         
     | 
| 52 | 
         
            -
                "Safety-Toxicity-Crime": 29,
         
     | 
| 53 | 
         
            -
                "Safety-Toxicity-Shocking": 31,
         
     | 
| 54 | 
         
            -
                "Safety-Toxicity-Disgust": 42,
         
     | 
| 55 | 
         
            -
                "Safety-Nsfw-Evident": 197,
         
     | 
| 56 | 
         
            -
                "Safety-Nsfw-Evasive": 177,
         
     | 
| 57 | 
         
            -
                "Safety-Nsfw-Subtle": 98,
         
     | 
| 58 | 
         
            -
                "Quality-Distortion-Human_face": 169,
         
     | 
| 59 | 
         
            -
                "Quality-Distortion-Human_limb": 152,
         
     | 
| 60 | 
         
            -
                "Quality-Distortion-Object": 100,
         
     | 
| 61 | 
         
            -
                "Quality-Blurry-Defocused": 350,
         
     | 
| 62 | 
         
            -
                "Quality-Blurry-Motion": 350,
         
     | 
| 63 | 
         
            -
                "Bias-Age": 80,
         
     | 
| 64 | 
         
            -
                "Bias-Gender": 140,
         
     | 
| 65 | 
         
            -
                "Bias-Race": 140,
         
     | 
| 66 | 
         
            -
                "Bias-Nationality": 120,
         
     | 
| 67 | 
         
            -
                "Bias-Religion": 60,
         
     | 
| 68 | 
         
             
            }
         
     | 
| 69 | 
         | 
| 70 | 
         
            -
             
     | 
| 71 | 
         
            -
                " 
     | 
| 72 | 
         
            -
                " 
     | 
| 73 | 
         
            -
                " 
     | 
| 74 | 
         
            -
                " 
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 75 | 
         
             
            }
         
     | 
| 76 | 
         | 
| 
         | 
|
| 
         | 
|
| 77 | 
         | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 78 | 
         | 
| 79 | 
         
            -
             
     | 
| 80 | 
         
            -
             
     | 
| 81 | 
         
            -
             
     | 
| 82 | 
         
            -
             
     | 
| 83 | 
         
            -
             
     | 
| 84 | 
         
            -
             
     | 
| 85 | 
         
            -
             
     | 
| 86 | 
         
            -
             
     | 
| 87 | 
         
            -
             
     | 
| 88 | 
         
            -
             
     | 
| 89 | 
         
            -
             
     | 
| 90 | 
         
            -
            #     "Closesource VLM": "#ffcd75",
         
     | 
| 91 | 
         
            -
            #     "Others": "#75809c",
         
     | 
| 92 | 
         
            -
             
     | 
| 93 | 
         
            -
            #     # #7497db #E8ECF2 #ffcd75 #75809c
         
     | 
| 94 | 
         
            -
            # }
         
     | 
| 95 | 
         
            -
            # def color_model_type_column(df, color_map):
         
     | 
| 96 | 
         
            -
            #     """
         
     | 
| 97 | 
         
            -
            #     Apply color to the 'Modality' column of the DataFrame based on a given color mapping.
         
     | 
| 98 | 
         
            -
             
     | 
| 99 | 
         
            -
            #     Parameters:
         
     | 
| 100 | 
         
            -
            #     df (pd.DataFrame): The DataFrame containing the 'Modality' column.
         
     | 
| 101 | 
         
            -
            #     color_map (dict): A dictionary mapping model types to colors.
         
     | 
| 102 | 
         
            -
             
     | 
| 103 | 
         
            -
            #     Returns:
         
     | 
| 104 | 
         
            -
            #     pd.Styler: The styled DataFrame.
         
     | 
| 105 | 
         
            -
            #     """
         
     | 
| 106 | 
         
            -
            #     # Function to apply color based on the model type
         
     | 
| 107 | 
         
            -
            #     def apply_color(val):
         
     | 
| 108 | 
         
            -
            #         color = color_map.get(val, "default")  # Default color if not specified in color_map
         
     | 
| 109 | 
         
            -
            #         return f'background-color: {color}'
         
     | 
| 110 | 
         | 
| 111 | 
         
            -
            # 
     | 
| 112 | 
         
            -
            # 
     | 
| 113 | 
         
            -
             
     | 
| 114 | 
         
            -
            # 
     | 
| 115 | 
         
            -
             
     | 
| 116 | 
         
            -
            #     return df.style.applymap(apply_color, subset=['Modality']).format(format_dict, na_rep='')
         
     | 
| 117 | 
         | 
| 118 | 
         
            -
            def regex_table(dataframe, regex, filter_button,  
     | 
| 119 | 
         
            -
                """
         
     | 
| 120 | 
         
            -
                 
     | 
| 121 | 
         
            -
                 
     | 
| 122 | 
         
            -
                # Split regex statement by comma and trim whitespace around regexes
         
     | 
| 123 | 
         
            -
                regex_list = [x.strip() for x in regex.split(",")]
         
     | 
| 124 | 
         
            -
                # Join the list into a single regex pattern with '|' acting as OR
         
     | 
| 125 | 
         
            -
                combined_regex = '|'.join(regex_list)
         
     | 
| 126 | 
         | 
| 127 | 
         
            -
                #  
     | 
| 128 | 
         
            -
                 
     | 
| 129 | 
         
            -
                 
     | 
| 130 | 
         
            -
                    if "Image-Text-to-Text" not in filter_button:
         
     | 
| 131 | 
         
            -
                        dataframe = dataframe[~dataframe["Modality"].str.contains("Image-Text-to-Text", case=False, na=False)]
         
     | 
| 132 | 
         
            -
                    if "Video-Text-to-Text" not in filter_button:
         
     | 
| 133 | 
         
            -
                        dataframe = dataframe[~dataframe["Modality"].str.contains("Video-Text-to-Text", case=False, na=False)]
         
     | 
| 134 | 
         
            -
                # Filter the dataframe such that 'model' contains any of the regex patterns
         
     | 
| 135 | 
         
            -
                data = dataframe[dataframe["Model"].str.contains(combined_regex, case=False, na=False)]
         
     | 
| 136 | 
         
            -
             
     | 
| 137 | 
         
            -
                data.reset_index(drop=True, inplace=True)
         
     | 
| 138 | 
         
            -
             
     | 
| 139 | 
         
            -
                # replace column '' with count/rank
         
     | 
| 140 | 
         
            -
                data.insert(0, '', range(1, 1 + len(data)))
         
     | 
| 141 | 
         | 
| 142 | 
         
            -
                #  
     | 
| 143 | 
         
            -
                 
     | 
| 144 | 
         
            -
             
     | 
| 145 | 
         
            -
             
     | 
| 146 | 
         
            -
             
     | 
| 147 | 
         
            -
             
     | 
| 148 | 
         
            -
             
     | 
| 149 | 
         
            -
                 
     | 
| 150 | 
         
            -
                 
     | 
| 151 | 
         
            -
             
     | 
| 152 | 
         
            -
                df = pd.DataFrame()
         
     | 
| 153 | 
         
            -
                for file in files:
         
     | 
| 154 | 
         
            -
                    if not file.endswith(".json"):
         
     | 
| 155 | 
         
            -
                        continue
         
     | 
| 156 | 
         
            -
                    with open(results_path / file) as rf:
         
     | 
| 157 | 
         
            -
                        result = json.load(rf)
         
     | 
| 158 | 
         
            -
                        result = pd.DataFrame(result)
         
     | 
| 159 | 
         
            -
                        df = pd.concat([result, df])
         
     | 
| 160 | 
         
             
                df.reset_index(drop=True, inplace=True)
         
     | 
| 161 | 
         
            -
                return df
         
     | 
| 162 | 
         
            -
             
     | 
| 163 | 
         
            -
             
     | 
| 164 | 
         
            -
            def avg_all_perspective(orig_df: pd.DataFrame, columns_name: list, meta_data=META_DATA, perspective_counts=PERSPECTIVE_COUNTS):
         
     | 
| 165 | 
         
            -
                new_df = orig_df[meta_data + columns_name]
         
     | 
| 166 | 
         
            -
                new_perspective_counts = {col: perspective_counts[col] for col in columns_name}
         
     | 
| 167 | 
         
            -
                total_count = sum(perspective_counts.values())
         
     | 
| 168 | 
         
            -
                weights = {perspective: count / total_count for perspective, count in perspective_counts.items()}
         
     | 
| 169 | 
         
            -
                def calculate_weighted_avg(row):
         
     | 
| 170 | 
         
            -
                    weighted_sum = sum(row[col] * weights[col] for col in columns_name)
         
     | 
| 171 | 
         
            -
                    return weighted_sum
         
     | 
| 172 | 
         
            -
                new_df["Overall Score"] = new_df.apply(calculate_weighted_avg, axis=1)
         
     | 
| 173 | 
         
            -
             
     | 
| 174 | 
         
            -
                cols = meta_data + ["Overall Score"]  + columns_name
         
     | 
| 175 | 
         
            -
                new_df = new_df[cols].sort_values(by="Overall Score", ascending=False).reset_index(drop=True)
         
     | 
| 176 | 
         
            -
                return new_df
         
     | 
| 177 | 
         | 
| 178 | 
         
            -
             
     | 
| 179 | 
         
            -
                 
     | 
| 180 | 
         
            -
             
     | 
| 181 | 
         
            -
             
     | 
| 182 | 
         
            -
             
     | 
| 183 | 
         
            -
             
     | 
| 184 | 
         
            -
             
     | 
| 185 | 
         
            -
                ],
         
     | 
| 186 | 
         
            -
                "Modality":[
         
     | 
| 187 | 
         
            -
                    "Image-Text-to-Text", "Image-Text-to-Text", "Image-Text-to-Text", "Image-Text-to-Text",
         
     | 
| 188 | 
         
            -
                    "Image-Text-to-Text", "Image-Text-to-Text", "Image-Text-to-Text", "Image-Text-to-Text",
         
     | 
| 189 | 
         
            -
                    "Image-Text-to-Text", "Image-Text-to-Text", "Image-Text-to-Text", "Image-Text-to-Text",
         
     | 
| 190 | 
         
            -
                    "Image-Text-to-Text", "Image-Text-to-Text", "Image-Text-to-Text", "Image-Text-to-Text",
         
     | 
| 191 | 
         
            -
                    "Image-Text-to-Text", "Image-Text-to-Text", "Image-Text-to-Text", "Image-Text-to-Text",
         
     | 
| 192 | 
         
            -
                ],
         
     | 
| 193 | 
         
            -
                "Correctness of Information": [
         
     | 
| 194 | 
         
            -
                    100.00, 100.00, 100.00, 100.00,
         
     | 
| 195 | 
         
            -
                    100.00, 100.00, 100.00, 100.00,
         
     | 
| 196 | 
         
            -
                    100.00, 100.00, 100.00, 100.00,
         
     | 
| 197 | 
         
            -
                    100.00, 100.00, 100.00, 100.00,
         
     | 
| 198 | 
         
            -
                    100.00, 100.00, 100.00, 100.00,
         
     | 
| 199 | 
         
            -
                ],
         
     | 
| 200 | 
         
            -
                "Detail Orientation": [
         
     | 
| 201 | 
         
            -
                    100.00, 100.00, 100.00, 100.00,
         
     | 
| 202 | 
         
            -
                    100.00, 100.00, 100.00, 100.00,
         
     | 
| 203 | 
         
            -
                    100.00, 100.00, 100.00, 100.00,
         
     | 
| 204 | 
         
            -
                    100.00, 100.00, 100.00, 100.00,
         
     | 
| 205 | 
         
            -
                    100.00, 100.00, 100.00, 100.00,
         
     | 
| 206 | 
         
            -
                ],
         
     | 
| 207 | 
         
            -
                "Safety": [
         
     | 
| 208 | 
         
            -
                    100.00, 100.00, 100.00, 100.00,
         
     | 
| 209 | 
         
            -
                    100.00, 100.00, 100.00, 100.00,
         
     | 
| 210 | 
         
            -
                    100.00, 100.00, 100.00, 100.00,
         
     | 
| 211 | 
         
            -
                    100.00, 100.00, 100.00, 100.00,
         
     | 
| 212 | 
         
            -
                    100.00, 100.00, 100.00, 100.00,
         
     | 
| 213 | 
         
            -
                ],
         
     | 
| 214 | 
         
            -
                "AVG": [
         
     | 
| 215 | 
         
            -
                    100.00, 100.00, 100.00, 100.00,
         
     | 
| 216 | 
         
            -
                    100.00, 100.00, 100.00, 100.00,
         
     | 
| 217 | 
         
            -
                    100.00, 100.00, 100.00, 100.00,
         
     | 
| 218 | 
         
            -
                    100.00, 100.00, 100.00, 100.00,
         
     | 
| 219 | 
         
            -
                    100.00, 100.00, 100.00, 100.00,
         
     | 
| 220 | 
         
            -
                ]
         
     | 
| 221 | 
         
            -
            }
         
     | 
| 222 | 
         
            -
            df = pd.DataFrame(data)
         
     | 
| 223 | 
         
            -
            total_models = len(df)
         
     | 
| 224 | 
         | 
| 225 | 
         
             
            with gr.Blocks(css=custom_css) as app:
         
     | 
| 
         | 
|
| 226 | 
         
             
                with gr.Row():
         
     | 
| 227 | 
         
             
                    with gr.Column(scale=6):
         
     | 
| 228 | 
         
             
                        gr.Markdown(INTRODUCTION_TEXT.format(str(total_models)))
         
     | 
| 229 | 
         
            -
                    with gr.Column(scale=4): 
         
     | 
| 230 | 
         
            -
                        gr.Markdown("")
         
     | 
| 231 | 
         
            -
                        # gr.HTML(BGB_LOGO, elem_classes="logo")
         
     | 
| 232 | 
         | 
| 233 | 
         
             
                with gr.Tabs(elem_classes="tab-buttons") as tabs:
         
     | 
| 234 | 
         
            -
                    with gr.TabItem("🏆  
     | 
| 235 | 
         
             
                        with gr.Row():
         
     | 
| 236 | 
         
             
                            search_overall = gr.Textbox(
         
     | 
| 237 | 
         
             
                                label="Model Search (delimit with , )", 
         
     | 
| 238 | 
         
            -
                                placeholder="🔍 Search model (separate multiple queries with  
     | 
| 239 | 
         
             
                                show_label=False
         
     | 
| 240 | 
         
             
                            )
         
     | 
| 241 | 
         
            -
                             
     | 
| 242 | 
         
            -
                                choices= 
     | 
| 243 | 
         
            -
                                value= 
     | 
| 244 | 
         
            -
                                label=" 
     | 
| 245 | 
         
            -
                                show_label=False, 
         
     | 
| 246 | 
         
            -
                                interactive=True,
         
     | 
| 247 | 
         
             
                            )
         
     | 
| 
         | 
|
| 248 | 
         
             
                        with gr.Row():
         
     | 
| 249 | 
         
            -
                             
     | 
| 250 | 
         
             
                                df,
         
     | 
| 251 | 
         
             
                                headers=df.columns.tolist(),
         
     | 
| 252 | 
         
            -
                                elem_id=" 
     | 
| 253 | 
         
             
                                wrap=True,
         
     | 
| 254 | 
         
             
                                visible=False,
         
     | 
| 
         | 
|
| 255 | 
         
             
                            )
         
     | 
| 256 | 
         
            -
                             
     | 
| 257 | 
         
            -
                                regex_table(
         
     | 
| 258 | 
         
            -
                                    df.copy(), 
         
     | 
| 259 | 
         
            -
                                    "", 
         
     | 
| 260 | 
         
            -
                                    ["Video-Text-to-Text", "Image-Text-to-Text"]
         
     | 
| 261 | 
         
            -
                                 ),
         
     | 
| 262 | 
         
             
                                headers=df.columns.tolist(),
         
     | 
| 263 | 
         
            -
                                elem_id=" 
     | 
| 264 | 
         
             
                                wrap=True,
         
     | 
| 
         | 
|
| 
         | 
|
| 265 | 
         
             
                            )
         
     | 
| 
         | 
|
| 266 | 
         
             
                    with gr.TabItem("About"):
         
     | 
| 267 | 
         
             
                        with gr.Row():
         
     | 
| 268 | 
         
             
                            gr.Markdown(ABOUT_TEXT)
         
     | 
| 269 | 
         | 
| 270 | 
         
             
                with gr.Accordion("📚 Citation", open=False):
         
     | 
| 271 | 
         
            -
             
     | 
| 272 | 
         
            -
             
     | 
| 273 | 
         
            -
             
     | 
| 274 | 
         
            -
             
     | 
| 275 | 
         
            -
             
     | 
| 276 | 
         
            -
             
     | 
| 277 | 
         
            -
             
     | 
| 278 | 
         
            -
             
     | 
| 279 | 
         
            -
                 
     | 
| 280 | 
         
            -
                 
     | 
| 
         | 
|
| 281 | 
         | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 282 | 
         
             
            scheduler = BackgroundScheduler()
         
     | 
| 283 | 
         
            -
            scheduler.add_job( 
     | 
| 284 | 
         
             
            scheduler.start()
         
     | 
| 285 | 
         
            -
             
     | 
| 286 | 
         
            -
             
     | 
| 
         | 
| 
         | 
|
| 8 | 
         
             
            from apscheduler.schedulers.background import BackgroundScheduler
         
     | 
| 9 | 
         
             
            from huggingface_hub import snapshot_download
         
     | 
| 10 | 
         | 
| 
         | 
|
| 11 | 
         
             
            from src.about import (
         
     | 
| 12 | 
         
             
                CITATION_BUTTON_LABEL,
         
     | 
| 13 | 
         
             
                CITATION_BUTTON_TEXT,
         
     | 
| 
         | 
|
| 18 | 
         
             
                ABOUT_TEXT
         
     | 
| 19 | 
         
             
            )
         
     | 
| 20 | 
         
             
            from src.display.css_html_js import custom_css
         
     | 
| 21 | 
         
            +
            from src.display.formatting import has_no_nan_values, make_clickable_model, model_hyperlink
         
     | 
| 22 | 
         
            +
             
     | 
| 23 | 
         
            +
            # 定义模型性能数据和链接
         
     | 
| 24 | 
         
            +
            model_links = {
         
     | 
| 25 | 
         
            +
                "LLaVA-v1.5-7B†": "https://huggingface.co/liuhaotian/llava-v1.5-7b",
         
     | 
| 26 | 
         
            +
                "Qwen2-VL-7B-Instruct†": "https://huggingface.co/Qwen/Qwen2-VL-7B-Instruct",
         
     | 
| 27 | 
         
            +
                "Qwen2-Audio-7B-Instruct†": "https://huggingface.co/Qwen/Qwen2-Audio-7B-Instruct",
         
     | 
| 28 | 
         
            +
                "Chameleon-7B†": "https://huggingface.co/facebook/chameleon-7b",
         
     | 
| 29 | 
         
            +
                "Llama3.1-8B-Instruct†": "https://huggingface.co/meta-llama/Llama-3.1-8B-Instruct",
         
     | 
| 30 | 
         
            +
                "Gemini-1.5-Pro†": "https://deepmind.google/technologies/gemini/pro/",
         
     | 
| 31 | 
         
            +
                "GPT-4o†": "https://openai.com/index/hello-gpt-4o/"
         
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 32 | 
         
             
            }
         
     | 
| 33 | 
         | 
| 34 | 
         
            +
            data = {
         
     | 
| 35 | 
         
            +
                "Model": list(model_links.keys()),
         
     | 
| 36 | 
         
            +
                "Perception": [2.66, 2.76, 3.58, 1.44, 1.05, 5.36, 2.66],
         
     | 
| 37 | 
         
            +
                "Reasoning": [2.67, 3.07, 4.53, 2.97, 1.20, 5.67, 3.48],
         
     | 
| 38 | 
         
            +
                "IF": [2.50, 2.40, 3.40, 2.80, 1.20, 6.70, 4.20],
         
     | 
| 39 | 
         
            +
                "Safety": [2.90, 4.05, 2.65, 2.45, 1.35, 6.70, 5.15],
         
     | 
| 40 | 
         
            +
                "AMU Score": [2.68, 3.07, 3.54, 2.41, 1.20, 6.11, 3.87],
         
     | 
| 41 | 
         
            +
                "Modality Selection": [0.182, 0.177, 0.190, 0.156, 0.231, 0.227, 0.266],
         
     | 
| 42 | 
         
            +
                "Instruction Following": [6.61, 7.01, 6.69, 6.09, 7.47, 8.62, 8.62],
         
     | 
| 43 | 
         
            +
                "Modality Synergy": [0.43, 0.58, 0.51, 0.54, 0.60, 0.52, 0.58],
         
     | 
| 44 | 
         
            +
                "AMG Score": [1.56, 2.16, 1.97, 1.57, 3.08, 3.05, 3.96],
         
     | 
| 45 | 
         
            +
                "Overall": [2.12, 2.62, 2.73, 1.99, 2.14, 4.58, 3.92]
         
     | 
| 46 | 
         
             
            }
         
     | 
| 47 | 
         | 
| 48 | 
         
            +
            df = pd.DataFrame(data).sort_values(by='Overall', ascending=False)
         
     | 
| 49 | 
         
            +
            total_models = len(df)
         
     | 
| 50 | 
         | 
| 51 | 
         
            +
            # 定义列组
         
     | 
| 52 | 
         
            +
            COLUMN_GROUPS = {
         
     | 
| 53 | 
         
            +
                "ALL": ["Model", "Perception", "Reasoning", "IF", "Safety", "AMU Score", 
         
     | 
| 54 | 
         
            +
                        "Modality Selection", "Instruction Following", "Modality Synergy", 
         
     | 
| 55 | 
         
            +
                        "AMG Score", "Overall"],
         
     | 
| 56 | 
         
            +
                "AMU": ["Model", "Perception", "Reasoning", "IF", "Safety", "AMU Score"],
         
     | 
| 57 | 
         
            +
                "AMG": ["Model", "Modality Selection", "Instruction Following", "Modality Synergy", "AMG Score"]
         
     | 
| 58 | 
         
            +
            }
         
     | 
| 59 | 
         | 
| 60 | 
         
            +
            def format_table(df):
         
     | 
| 61 | 
         
            +
                """Format the dataframe for display"""
         
     | 
| 62 | 
         
            +
                # 设置列的显示格式
         
     | 
| 63 | 
         
            +
                float_cols = df.select_dtypes(include=['float64']).columns
         
     | 
| 64 | 
         
            +
                for col in float_cols:
         
     | 
| 65 | 
         
            +
                    df[col] = df[col].apply(lambda x: f"{x:.2f}")  # 修改为保留2位小数
         
     | 
| 66 | 
         
            +
                    
         
     | 
| 67 | 
         
            +
                bold_columns = ['AMU Score', 'AMG Score', 'Overall']
         
     | 
| 68 | 
         
            +
                for col in bold_columns:
         
     | 
| 69 | 
         
            +
                    if col in df.columns:
         
     | 
| 70 | 
         
            +
                        df[col] = df[col].apply(lambda x: f'**{x}**')
         
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 71 | 
         | 
| 72 | 
         
            +
                # 添加模型链接
         
     | 
| 73 | 
         
            +
                # df['Model'] = df['Model'].apply(lambda x: f'<a href="{model_links[x]}" target="_blank">{x}</a>')
         
     | 
| 74 | 
         
            +
                df['Model'] = df['Model'].apply(lambda x: f'[{x}]({model_links[x]})')
         
     | 
| 75 | 
         
            +
                # df['Model'] = df.apply(lambda x: model_hyperlink(model_links[x['Model']], x['Model']), axis=1)
         
     | 
| 76 | 
         
            +
                return df
         
     | 
| 
         | 
|
| 77 | 
         | 
| 78 | 
         
            +
            def regex_table(dataframe, regex, filter_button, column_group="ALL"):
         
     | 
| 79 | 
         
            +
                """Takes a model name as a regex, then returns only the rows that has that in it."""
         
     | 
| 80 | 
         
            +
                # 深拷贝确保不修改原始数据
         
     | 
| 81 | 
         
            +
                df = dataframe.copy()
         
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 82 | 
         | 
| 83 | 
         
            +
                # 选择要显示的列
         
     | 
| 84 | 
         
            +
                columns_to_show = COLUMN_GROUPS.get(column_group, COLUMN_GROUPS["ALL"])
         
     | 
| 85 | 
         
            +
                df = df[columns_to_show]
         
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 86 | 
         | 
| 87 | 
         
            +
                # Split regex statement by comma and trim whitespace around regexes
         
     | 
| 88 | 
         
            +
                if regex:
         
     | 
| 89 | 
         
            +
                    regex_list = [x.strip() for x in regex.split(",")]
         
     | 
| 90 | 
         
            +
                    # Join the list into a single regex pattern with '|' acting as OR
         
     | 
| 91 | 
         
            +
                    combined_regex = '|'.join(regex_list)
         
     | 
| 92 | 
         
            +
                    # Filter based on model name regex
         
     | 
| 93 | 
         
            +
                    df = df[df["Model"].str.contains(combined_regex, case=False, na=False)]
         
     | 
| 94 | 
         
            +
                
         
     | 
| 95 | 
         
            +
                df = df.sort_values(by='Overall' if 'Overall' in columns_to_show else columns_to_show[-1], ascending=False)
         
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 96 | 
         
             
                df.reset_index(drop=True, inplace=True)
         
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 97 | 
         | 
| 98 | 
         
            +
                # Format numbers and add links
         
     | 
| 99 | 
         
            +
                df = format_table(df)
         
     | 
| 100 | 
         
            +
                
         
     | 
| 101 | 
         
            +
                # Add index column
         
     | 
| 102 | 
         
            +
                df.insert(0, '', range(1, 1 + len(df)))
         
     | 
| 103 | 
         
            +
                
         
     | 
| 104 | 
         
            +
                return df
         
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 105 | 
         | 
| 106 | 
         
             
            with gr.Blocks(css=custom_css) as app:
         
     | 
| 107 | 
         
            +
                gr.HTML(TITLE)
         
     | 
| 108 | 
         
             
                with gr.Row():
         
     | 
| 109 | 
         
             
                    with gr.Column(scale=6):
         
     | 
| 110 | 
         
             
                        gr.Markdown(INTRODUCTION_TEXT.format(str(total_models)))
         
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 111 | 
         | 
| 112 | 
         
             
                with gr.Tabs(elem_classes="tab-buttons") as tabs:
         
     | 
| 113 | 
         
            +
                    with gr.TabItem("🏆 Model Performance Leaderboard"):
         
     | 
| 114 | 
         
             
                        with gr.Row():
         
     | 
| 115 | 
         
             
                            search_overall = gr.Textbox(
         
     | 
| 116 | 
         
             
                                label="Model Search (delimit with , )", 
         
     | 
| 117 | 
         
            +
                                placeholder="🔍 Search model (separate multiple queries with ,) and press ENTER...",
         
     | 
| 118 | 
         
             
                                show_label=False
         
     | 
| 119 | 
         
             
                            )
         
     | 
| 120 | 
         
            +
                            column_group = gr.Radio(
         
     | 
| 121 | 
         
            +
                                choices=list(COLUMN_GROUPS.keys()),
         
     | 
| 122 | 
         
            +
                                value="ALL",
         
     | 
| 123 | 
         
            +
                                label="Select columns to show"
         
     | 
| 
         | 
|
| 
         | 
|
| 124 | 
         
             
                            )
         
     | 
| 125 | 
         
            +
                        
         
     | 
| 126 | 
         
             
                        with gr.Row():
         
     | 
| 127 | 
         
            +
                            performance_table_hidden = gr.Dataframe(
         
     | 
| 128 | 
         
             
                                df,
         
     | 
| 129 | 
         
             
                                headers=df.columns.tolist(),
         
     | 
| 130 | 
         
            +
                                elem_id="performance_table_hidden",
         
     | 
| 131 | 
         
             
                                wrap=True,
         
     | 
| 132 | 
         
             
                                visible=False,
         
     | 
| 133 | 
         
            +
                                datatype='markdown',
         
     | 
| 134 | 
         
             
                            )
         
     | 
| 135 | 
         
            +
                            performance_table = gr.Dataframe(
         
     | 
| 136 | 
         
            +
                                regex_table(df.copy(), "", []),
         
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 137 | 
         
             
                                headers=df.columns.tolist(),
         
     | 
| 138 | 
         
            +
                                elem_id="performance_table",
         
     | 
| 139 | 
         
             
                                wrap=True,
         
     | 
| 140 | 
         
            +
                                show_label=False,
         
     | 
| 141 | 
         
            +
                                datatype='markdown',
         
     | 
| 142 | 
         
             
                            )
         
     | 
| 143 | 
         
            +
                    
         
     | 
| 144 | 
         
             
                    with gr.TabItem("About"):
         
     | 
| 145 | 
         
             
                        with gr.Row():
         
     | 
| 146 | 
         
             
                            gr.Markdown(ABOUT_TEXT)
         
     | 
| 147 | 
         | 
| 148 | 
         
             
                with gr.Accordion("📚 Citation", open=False):
         
     | 
| 149 | 
         
            +
                    citation_button = gr.Textbox(
         
     | 
| 150 | 
         
            +
                        value=CITATION_BUTTON_TEXT,
         
     | 
| 151 | 
         
            +
                        lines=7,
         
     | 
| 152 | 
         
            +
                        label="Copy the following to cite these results.",
         
     | 
| 153 | 
         
            +
                        elem_id="citation-button",
         
     | 
| 154 | 
         
            +
                        show_copy_button=True,
         
     | 
| 155 | 
         
            +
                    )
         
     | 
| 156 | 
         
            +
                
         
     | 
| 157 | 
         
            +
                # Set up event handlers
         
     | 
| 158 | 
         
            +
                def update_table(search_text, selected_group):
         
     | 
| 159 | 
         
            +
                    return regex_table(df, search_text, [], selected_group)
         
     | 
| 160 | 
         | 
| 161 | 
         
            +
                search_overall.change(
         
     | 
| 162 | 
         
            +
                    update_table,
         
     | 
| 163 | 
         
            +
                    inputs=[search_overall, column_group],
         
     | 
| 164 | 
         
            +
                    outputs=performance_table
         
     | 
| 165 | 
         
            +
                )
         
     | 
| 166 | 
         
            +
                
         
     | 
| 167 | 
         
            +
                column_group.change(
         
     | 
| 168 | 
         
            +
                    update_table,
         
     | 
| 169 | 
         
            +
                    inputs=[search_overall, column_group],
         
     | 
| 170 | 
         
            +
                    outputs=performance_table
         
     | 
| 171 | 
         
            +
                )
         
     | 
| 172 | 
         
            +
             
     | 
| 173 | 
         
            +
            # Set up scheduler
         
     | 
| 174 | 
         
             
            scheduler = BackgroundScheduler()
         
     | 
| 175 | 
         
            +
            scheduler.add_job(lambda: None, "interval", seconds=18000)  # every 5 hours
         
     | 
| 176 | 
         
             
            scheduler.start()
         
     | 
| 177 | 
         
            +
             
     | 
| 178 | 
         
            +
            # Launch the app
         
     | 
| 179 | 
         
            +
            app.launch(share=True)
         
     | 
    	
        src/about.py
    CHANGED
    
    | 
         @@ -21,15 +21,15 @@ NUM_FEWSHOT = 0 # Change with your few shot 
     | 
|
| 21 | 
         | 
| 22 | 
         | 
| 23 | 
         
             
            # Your leaderboard name
         
     | 
| 24 | 
         
            -
            TITLE = """<h1 align="center" id="space-title"> 
     | 
| 25 | 
         | 
| 26 | 
         
             
            # MJB_LOGO = '<img src="" alt="Logo" style="width: 100%; display: block; margin: auto;">'
         
     | 
| 27 | 
         | 
| 28 | 
         
             
            # What does your leaderboard evaluate?
         
     | 
| 29 | 
         
             
            INTRODUCTION_TEXT = """
         
     | 
| 30 | 
         
            -
             
     | 
| 31 | 
         
            -
             
     | 
| 32 | 
         
            -
             
     | 
| 33 | 
         
             
            """
         
     | 
| 34 | 
         | 
| 35 | 
         
             
            # Which evaluations are you running? how can people reproduce what you have?
         
     | 
| 
         @@ -41,16 +41,17 @@ EVALUATION_QUEUE_TEXT = """ 
     | 
|
| 41 | 
         | 
| 42 | 
         
             
            CITATION_BUTTON_LABEL = "Copy the following snippet to cite these results"
         
     | 
| 43 | 
         
             
            CITATION_BUTTON_TEXT = """
         
     | 
| 44 | 
         
            -
            @ 
     | 
| 45 | 
         
            -
               
     | 
| 46 | 
         
            -
               
     | 
| 47 | 
         
            -
               
     | 
| 48 | 
         
            -
               
     | 
| 49 | 
         
            -
               
     | 
| 50 | 
         
            -
               
     | 
| 51 | 
         
             
            }
         
     | 
| 52 | 
         
             
            """
         
     | 
| 53 | 
         | 
| 54 | 
         | 
| 55 | 
         
             
            ABOUT_TEXT = """
         
     | 
| 
         | 
|
| 56 | 
         
             
            """
         
     | 
| 
         | 
|
| 21 | 
         | 
| 22 | 
         | 
| 23 | 
         
             
            # Your leaderboard name
         
     | 
| 24 | 
         
            +
            TITLE = """<h1 align="center" id="space-title">Eval-Anything Leaderboard</h1>"""
         
     | 
| 25 | 
         | 
| 26 | 
         
             
            # MJB_LOGO = '<img src="" alt="Logo" style="width: 100%; display: block; margin: auto;">'
         
     | 
| 27 | 
         | 
| 28 | 
         
             
            # What does your leaderboard evaluate?
         
     | 
| 29 | 
         
             
            INTRODUCTION_TEXT = """
         
     | 
| 30 | 
         
            +
            Eval-anything is a framework designed specifically for evaluating all-modality models, and it is a part of the [Align-Anything](https://github.com/PKU-Alignment/align-anything) framework. It consists of two main tasks: All-Modality Understanding (AMU) and All-Modality Generation (AMG). AMU assesses a model's ability to simultaneously process and integrate information from all modalities, including text, images, audio, and video. On the other hand, AMG evaluates a model's capability to autonomously select output modalities based on user instructions and synergistically utilize different modalities to generate output. Eval-anything aims to comprehensively assess the ability of all-modality models to handle heterogeneous data from multiple sources, providing a reliable evaluation tool for this field.
         
     | 
| 31 | 
         
            +
             
     | 
| 32 | 
         
            +
            **Note:** Since most current open-source models lack support for all-modality output, (†) indicates that models are used as agents to invoke [AudioLDM2-Large](https://huggingface.co/cvssp/audioldm2-large) and [FLUX.1-schnell](https://huggingface.co/black-forest-labs/FLUX.1-schnell) for audio and image generation.
         
     | 
| 33 | 
         
             
            """
         
     | 
| 34 | 
         | 
| 35 | 
         
             
            # Which evaluations are you running? how can people reproduce what you have?
         
     | 
| 
         | 
|
| 41 | 
         | 
| 42 | 
         
             
            CITATION_BUTTON_LABEL = "Copy the following snippet to cite these results"
         
     | 
| 43 | 
         
             
            CITATION_BUTTON_TEXT = """
         
     | 
| 44 | 
         
            +
            @misc{align_anything,
         
     | 
| 45 | 
         
            +
              author = {PKU-Alignment Team},
         
     | 
| 46 | 
         
            +
              title = {Align Anything: training all modality models to follow instructions with unified language feedback},
         
     | 
| 47 | 
         
            +
              year = {2024},
         
     | 
| 48 | 
         
            +
              publisher = {GitHub},
         
     | 
| 49 | 
         
            +
              journal = {GitHub repository},
         
     | 
| 50 | 
         
            +
              howpublished = {\\url{https://github.com/PKU-Alignment/align-anything}},
         
     | 
| 51 | 
         
             
            }
         
     | 
| 52 | 
         
             
            """
         
     | 
| 53 | 
         | 
| 54 | 
         | 
| 55 | 
         
             
            ABOUT_TEXT = """
         
     | 
| 56 | 
         
            +
            We will provide methods to upload more model evaluation results in the future.
         
     | 
| 57 | 
         
             
            """
         
     |