Bekhouche commited on
Commit
505d963
Β·
1 Parent(s): ed52aea

Add 12/09/2025 results

Browse files
Files changed (10) hide show
  1. requirements.txt +2 -0
  2. .gitignore +1 -0
  3. README.md +3 -2
  4. app.py +296 -0
  5. constants.py +125 -0
  6. evaluation.py +241 -0
  7. imagenet_results.jsonl +19 -0
  8. init.py +47 -0
  9. models_list.json +177 -0
  10. utils_display.py +56 -0
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ pandas==2.3.0
2
+ gradio==4.44.1
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ __pycache__/
README.md CHANGED
@@ -1,12 +1,13 @@
1
  ---
2
  title: ImageNet-1k Leaderboard
3
- emoji: 🐠
4
  colorFrom: blue
5
  colorTo: red
6
  sdk: gradio
7
  sdk_version: 5.45.0
8
  app_file: app.py
9
  pinned: false
 
 
10
  ---
11
 
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
  title: ImageNet-1k Leaderboard
3
+ emoji: πŸ†
4
  colorFrom: blue
5
  colorTo: red
6
  sdk: gradio
7
  sdk_version: 5.45.0
8
  app_file: app.py
9
  pinned: false
10
+ tags:
11
+ - leaderboard
12
  ---
13
 
 
app.py ADDED
@@ -0,0 +1,296 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import pandas as pd
3
+ import json
4
+ import os
5
+ from constants import BANNER, INTRODUCTION_TEXT, CITATION_TEXT, METRICS_TAB_TEXT, DIR_OUTPUT_REQUESTS, LEADERBOARD_CSS
6
+ from init import is_model_on_hub, upload_file, load_all_info_from_dataset_hub
7
+ from utils_display import AutoEvalColumn, fields, make_clickable_model, make_clickable_paper, styled_error, styled_message, get_imagenet_columns
8
+ import numpy as np
9
+ from datetime import datetime, timezone
10
+
11
+ def get_last_updated_date(file_path):
12
+ """Get the last modification date of a file and format it nicely"""
13
+ try:
14
+ timestamp = os.path.getmtime(file_path)
15
+ dt = datetime.fromtimestamp(timestamp)
16
+ # Format as "Month DDth YYYY"
17
+ day = dt.day
18
+ if 4 <= day <= 20 or 24 <= day <= 30:
19
+ suffix = "th"
20
+ else:
21
+ suffix = ["st", "nd", "rd"][day % 10 - 1] if day % 10 in [1, 2, 3] else "th"
22
+
23
+ return dt.strftime(f"%b {day}{suffix} %Y")
24
+ except OSError:
25
+ return "Unknown"
26
+
27
+ def load_models_list(json_path):
28
+ """Load models list with paper and year information"""
29
+ with open(json_path, 'r') as f:
30
+ models_list = json.load(f)
31
+
32
+ # Create a dictionary for quick lookup
33
+ models_dict = {}
34
+ for model in models_list:
35
+ models_dict[model['path']] = {
36
+ 'paper': model['paper'],
37
+ 'year': model['year'],
38
+ 'license': model['license']
39
+ }
40
+ return models_dict
41
+
42
+ def read_jsonl_to_dataframe(jsonl_path, models_dict):
43
+ """Read JSONL file and convert to pandas DataFrame with proper unit conversions and model info"""
44
+ data = []
45
+ with open(jsonl_path, 'r') as f:
46
+ for line in f:
47
+ if line.strip(): # Skip empty lines
48
+ record = json.loads(line.strip())
49
+
50
+ # Convert units to match expected column names
51
+ if 'parameters' in record:
52
+ record['parameters_millions'] = record['parameters'] / 1_000_000
53
+
54
+ if 'flops' in record:
55
+ record['flops_giga'] = record['flops'] / 1_000_000_000
56
+
57
+ if 'model_size' in record:
58
+ record['model_size_mb'] = record['model_size'] / (1024 * 1024)
59
+
60
+ # Add paper and year information if model exists in models list
61
+ model_name = record.get('model', '')
62
+ if model_name in models_dict:
63
+ record['paper'] = models_dict[model_name]['paper']
64
+ record['year'] = str(models_dict[model_name]['year'])
65
+ # Use license from models_dict if available, otherwise keep existing
66
+ if 'license' not in record:
67
+ record['license'] = models_dict[model_name]['license']
68
+ else:
69
+ # Set default values for models not in the list
70
+ record['paper'] = "N/A"
71
+ record['year'] = "N/A"
72
+
73
+ data.append(record)
74
+ return pd.DataFrame(data)
75
+
76
+ # Column names mapping for ImageNet-1k leaderboard
77
+ column_names = {
78
+ "model": "Model",
79
+ "top1_accuracy": "Top-1 Accuracy ⬆️",
80
+ "top5_accuracy": "Top-5 Accuracy ⬆️",
81
+ "parameters_millions": "Parameters (M)",
82
+ "flops_giga": "FLOPs (G)",
83
+ "model_size_mb": "Model Size (MB)",
84
+ "paper": "Paper",
85
+ "year": "Year",
86
+ "license": "License"
87
+ }
88
+
89
+ eval_queue_repo, requested_models, jsonl_results, _ = load_all_info_from_dataset_hub()
90
+
91
+ if not jsonl_results.exists():
92
+ raise Exception(f"JSONL file {jsonl_results} does not exist locally")
93
+
94
+ # Load models list with paper and year information
95
+ models_dict = load_models_list("/data3/salah/ImageNet-1k_leaderboard/models_list.json")
96
+
97
+ # Get jsonl with data and parse columns
98
+ original_df = read_jsonl_to_dataframe(jsonl_results, models_dict)
99
+
100
+ # Get last updated date from the jsonl file
101
+ LAST_UPDATED = get_last_updated_date(jsonl_results)
102
+
103
+ # Formats the columns
104
+ def formatter(x):
105
+ if type(x) is str:
106
+ x = x
107
+ elif x == -1 or pd.isna(x):
108
+ x = "NA"
109
+ else:
110
+ x = round(x, 2)
111
+ return x
112
+
113
+ # Select only the columns we want to display in the final table
114
+ display_columns = ['model', 'top1_accuracy', 'top5_accuracy', 'parameters_millions',
115
+ 'flops_giga', 'model_size_mb', 'year','paper']
116
+
117
+ # Filter dataframe to only include display columns that exist
118
+ available_columns = [col for col in display_columns if col in original_df.columns]
119
+ filtered_df = original_df[available_columns].copy()
120
+
121
+ # Format the columns
122
+ for col in filtered_df.columns:
123
+ if col == "model":
124
+ filtered_df[col] = filtered_df[col].apply(lambda x: make_clickable_model(x))
125
+ elif col == "paper":
126
+ filtered_df[col] = filtered_df[col].apply(lambda x: make_clickable_paper(x))
127
+ else:
128
+ filtered_df[col] = filtered_df[col].apply(formatter) # For numerical values
129
+
130
+ # Rename columns for display
131
+ filtered_df.rename(columns=column_names, inplace=True)
132
+ filtered_df.sort_values(by='Top-1 Accuracy ⬆️', ascending=False, inplace=True)
133
+
134
+ # Update original_df to be the filtered version
135
+ original_df = filtered_df
136
+
137
+ # Get column definitions for ImageNet-1k
138
+ imagenet_columns = get_imagenet_columns()
139
+ COLS = [c.name for c in imagenet_columns]
140
+ TYPES = [c.type for c in imagenet_columns]
141
+
142
+ # ImageNet-1k specific functions (no multilingual functionality needed)
143
+
144
+
145
+ def request_model(model_text, chb_imagenet):
146
+ """Request evaluation of a model on ImageNet-1k dataset"""
147
+
148
+ # Determine the selected checkboxes
149
+ dataset_selection = []
150
+ if chb_imagenet:
151
+ dataset_selection.append("ImageNet-1k validation set")
152
+
153
+ if len(dataset_selection) == 0:
154
+ return styled_error("You need to select at least one dataset")
155
+
156
+ base_model_on_hub, error_msg = is_model_on_hub(model_text)
157
+
158
+ if not base_model_on_hub:
159
+ return styled_error(f"Base model '{model_text}' {error_msg}")
160
+
161
+ # Construct the output dictionary
162
+ current_time = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
163
+ required_datasets = ', '.join(dataset_selection)
164
+ eval_entry = {
165
+ "date": current_time,
166
+ "model": model_text,
167
+ "datasets_selected": required_datasets,
168
+ "evaluation_type": "ImageNet-1k_classification"
169
+ }
170
+
171
+ # Prepare file path
172
+ DIR_OUTPUT_REQUESTS.mkdir(parents=True, exist_ok=True)
173
+
174
+ fn_datasets = '@ '.join(dataset_selection)
175
+ filename = model_text.replace("/","@") + "@@" + fn_datasets
176
+ if filename in requested_models:
177
+ return styled_error(f"A request for this model '{model_text}' and dataset(s) was already made.")
178
+ try:
179
+ filename_ext = filename + ".txt"
180
+ out_filepath = DIR_OUTPUT_REQUESTS / filename_ext
181
+
182
+ # Write the results to a text file
183
+ with open(out_filepath, "w") as f:
184
+ f.write(json.dumps(eval_entry))
185
+
186
+ upload_file(filename, out_filepath)
187
+
188
+ # Include file in the list of uploaded files
189
+ requested_models.append(filename)
190
+
191
+ # Remove the local file
192
+ out_filepath.unlink()
193
+
194
+ return styled_message("πŸ€— Your request has been submitted and will be evaluated soon!")
195
+ except Exception as e:
196
+ return styled_error(f"Error submitting request!")
197
+
198
+ def filter_main_table(show_proprietary=True):
199
+ filtered_df = original_df.copy()
200
+
201
+ # Filter proprietary models if needed
202
+ if not show_proprietary and "License" in filtered_df.columns:
203
+ # Keep only models with "Open" license
204
+ filtered_df = filtered_df[filtered_df["License"] == "Open"]
205
+
206
+ return filtered_df
207
+
208
+ with gr.Blocks(css=LEADERBOARD_CSS) as demo:
209
+ gr.HTML(BANNER, elem_id="banner")
210
+ gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
211
+
212
+ with gr.Tabs(elem_classes="tab-buttons") as tabs:
213
+ with gr.TabItem("πŸ… Leaderboard", elem_id="imagenet-benchmark-tab-table", id=0):
214
+ leaderboard_table = gr.components.Dataframe(
215
+ value=original_df,
216
+ datatype=TYPES,
217
+ elem_id="leaderboard-table",
218
+ interactive=False,
219
+ visible=True,
220
+ )
221
+ with gr.Row():
222
+ show_proprietary_checkbox = gr.Checkbox(
223
+ label="Show proprietary models",
224
+ value=True,
225
+ elem_id="show-proprietary-checkbox"
226
+ )
227
+
228
+ # Connect checkbox to the filtering function
229
+ show_proprietary_checkbox.change(
230
+ filter_main_table,
231
+ inputs=[show_proprietary_checkbox],
232
+ outputs=leaderboard_table
233
+ )
234
+
235
+ with gr.TabItem("πŸ“ˆ Metrics", elem_id="imagenet-metrics-tab", id=1):
236
+ gr.Markdown(METRICS_TAB_TEXT, elem_classes="markdown-text")
237
+
238
+ with gr.TabItem("βœ‰οΈβœ¨ Request a model here!", elem_id="imagenet-request-tab", id=2):
239
+ with gr.Column():
240
+ gr.Markdown("# βœ‰οΈβœ¨ Request evaluation for a new model here!", elem_classes="markdown-text")
241
+ with gr.Column():
242
+ gr.Markdown("Select a dataset:", elem_classes="markdown-text")
243
+ with gr.Column():
244
+ model_name_textbox = gr.Textbox(label="Model name (user_name/model_name)")
245
+ chb_imagenet = gr.Checkbox(label="ImageNet-1k validation set", value=True, interactive=True)
246
+ with gr.Column():
247
+ mdw_submission_result = gr.Markdown()
248
+ btn_submitt = gr.Button(value="πŸš€ Request Evaluation")
249
+ btn_submitt.click(request_model,
250
+ [model_name_textbox, chb_imagenet],
251
+ mdw_submission_result)
252
+
253
+ # add an about section
254
+ with gr.TabItem("πŸ€— About", elem_id="imagenet-about-tab", id=3):
255
+ gr.Markdown("## About", elem_classes="markdown-text")
256
+ gr.Markdown("""
257
+ ### ImageNet-1k Leaderboard
258
+
259
+ This leaderboard tracks the performance of computer vision models on the ImageNet-1k dataset,
260
+ which is one of the most widely used benchmarks for image classification.
261
+
262
+ #### Dataset Information
263
+ - **Training images**: 1.2 million
264
+ - **Validation images**: 50,000
265
+ - **Classes**: 1,000 object categories
266
+ - **Image resolution**: Variable (typically 224Γ—224 or 384Γ—384)
267
+
268
+ #### Hardware Configuration
269
+ - **GPU**: NVIDIA L4
270
+ - All results are tested on the same hardware configuration to ensure fair comparison
271
+
272
+ #### Evaluation Metrics
273
+ - **Top-1 Accuracy**: Percentage of images where the top prediction is correct
274
+ - **Top-5 Accuracy**: Percentage of images where the correct class is in top 5 predictions
275
+ - **Parameters**: Number of trainable parameters in millions
276
+ - **FLOPs**: Floating point operations in billions
277
+ - **Model Size**: Size of the model file in MB
278
+
279
+ #### Contributing
280
+ To add your model to the leaderboard, use the "Request a model here!" tab.
281
+ Your model will be evaluated on the ImageNet-1k validation set using NVIDIA L4 GPU and added to the leaderboard.
282
+ """, elem_classes="markdown-text")
283
+
284
+ gr.Markdown(f"Last updated on **{LAST_UPDATED}**", elem_classes="markdown-text")
285
+
286
+ with gr.Row():
287
+ with gr.Accordion("πŸ“™ Citation", open=False):
288
+ gr.Textbox(
289
+ value=CITATION_TEXT, lines=7,
290
+ label="Copy the BibTeX snippet to cite this source",
291
+ elem_id="citation-button",
292
+ show_copy_button=True,
293
+ )
294
+
295
+ if __name__ == "__main__":
296
+ demo.launch()
constants.py ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Constants for ImageNet-1k Leaderboard
2
+
3
+ BANNER = """
4
+ <div style="text-align: center; margin-bottom: 20px;">
5
+ <h1>πŸ† ImageNet-1k Leaderboard</h1>
6
+ <p style="font-size: 18px; color: #666;">Compare computer vision models on ImageNet-1k classification</p>
7
+ </div>
8
+ """
9
+
10
+ INTRODUCTION_TEXT = """
11
+ # ImageNet-1k Leaderboard
12
+
13
+ Welcome to the ImageNet-1k Leaderboard! This leaderboard tracks the performance of various computer vision models on the ImageNet-1k dataset, which contains 1.2 million training images across 1000 classes.
14
+
15
+ ## Key Metrics
16
+
17
+ - **Top-1 Accuracy**: Percentage of images where the model's top prediction is correct
18
+ - **Top-5 Accuracy**: Percentage of images where the correct class is among the top 5 predictions
19
+ - **Parameters**: Number of trainable parameters in the model
20
+ - **FLOPs**: Floating point operations required for inference
21
+ - **Inference Time**: Average time per image (if available)
22
+
23
+ ## Dataset
24
+
25
+ ImageNet-1k is a subset of the ImageNet dataset containing:
26
+ - **Training set**: 1.2M images
27
+ - **Validation set**: 50K images
28
+ - **Classes**: 1000 object categories
29
+ - **Image size**: Variable (typically resized to 224x224 or 384x384)
30
+
31
+ ## Hardware Configuration
32
+
33
+ All results are tested on **NVIDIA L4 GPU** to ensure consistent and fair comparison across models.
34
+
35
+ The leaderboard is sorted by Top-1 Accuracy (descending) as the primary metric.
36
+ """
37
+
38
+ CITATION_TEXT = """@article{imagenet,
39
+ title={ImageNet: A large-scale hierarchical image database},
40
+ author={Deng, Jia and Dong, Wei and Socher, Richard and Li, Li-Jia and Li, Kai and Fei-Fei, Li},
41
+ journal={2009 IEEE conference on computer vision and pattern recognition},
42
+ pages={248--255},
43
+ year={2009},
44
+ organization={IEEE}
45
+ }"""
46
+
47
+ METRICS_TAB_TEXT = """
48
+ # Evaluation Metrics
49
+
50
+ ## Hardware Configuration
51
+ All models are evaluated on **NVIDIA L4 GPU** to ensure consistent and fair comparison across different architectures.
52
+
53
+ ## Top-1 Accuracy
54
+ The percentage of test images for which the model's highest confidence prediction matches the ground truth label.
55
+
56
+ ## Top-5 Accuracy
57
+ The percentage of test images for which the ground truth label appears in the model's top 5 highest confidence predictions.
58
+
59
+ ## Parameters
60
+ The total number of trainable parameters in the model. This gives an indication of model complexity and size.
61
+
62
+ ## FLOPs (Floating Point Operations)
63
+ The number of floating point operations required for a single forward pass through the model. This is a measure of computational complexity.
64
+
65
+ ## Inference Time
66
+ The average time required to process a single image on NVIDIA L4 GPU. This metric helps compare the computational efficiency of different models.
67
+
68
+ ## Model Size
69
+ The size of the model file in MB or GB, indicating storage requirements.
70
+ """
71
+
72
+ # Directory for storing evaluation requests
73
+ from pathlib import Path
74
+ DIR_OUTPUT_REQUESTS = Path("evaluation_requests")
75
+
76
+ # CSS styling for the leaderboard
77
+ LEADERBOARD_CSS = """
78
+ .leaderboard-table {
79
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
80
+ }
81
+
82
+ .leaderboard-table th {
83
+ background-color: #f8f9fa;
84
+ font-weight: bold;
85
+ text-align: center;
86
+ padding: 12px;
87
+ border: 1px solid #dee2e6;
88
+ }
89
+
90
+ .leaderboard-table td {
91
+ text-align: center;
92
+ padding: 8px 12px;
93
+ border: 1px solid #dee2e6;
94
+ }
95
+
96
+ .leaderboard-table tr:nth-child(even) {
97
+ background-color: #f8f9fa;
98
+ }
99
+
100
+ .leaderboard-table tr:hover {
101
+ background-color: #e9ecef;
102
+ }
103
+
104
+ .markdown-text {
105
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
106
+ line-height: 1.6;
107
+ }
108
+
109
+ .tab-buttons {
110
+ margin-bottom: 20px;
111
+ }
112
+
113
+ #banner {
114
+ text-align: center;
115
+ margin-bottom: 30px;
116
+ padding: 20px;
117
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
118
+ color: white;
119
+ border-radius: 10px;
120
+ }
121
+
122
+ #show-proprietary-checkbox {
123
+ margin-top: 10px;
124
+ }
125
+ """
evaluation.py ADDED
@@ -0,0 +1,241 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import argparse
3
+ import json
4
+ import time
5
+ import os
6
+ from fvcore.nn import FlopCountAnalysis, parameter_count_table
7
+ from torch.utils.data import DataLoader
8
+ from datasets import load_dataset
9
+ from transformers import AutoModelForImageClassification, AutoImageProcessor
10
+ from tqdm import tqdm
11
+
12
+
13
+ def benchmark_inference(model, processor, device, runs=20, warmup=5):
14
+ dummy_image = torch.randn(1, 3, processor.size['height'], processor.size['width'], device=device)
15
+ model.eval()
16
+
17
+ # Warmup
18
+ for _ in range(warmup):
19
+ _ = model(dummy_image)
20
+
21
+ torch.cuda.synchronize()
22
+ start = time.time()
23
+
24
+ for _ in range(runs):
25
+ _ = model(dummy_image)
26
+
27
+ torch.cuda.synchronize()
28
+ elapsed = (time.time() - start) * 1000
29
+
30
+ avg_latency = elapsed / runs
31
+ throughput = 1000.0 / avg_latency
32
+
33
+ return avg_latency, throughput
34
+
35
+
36
+ def load_dataloader(args):
37
+ dataset = load_dataset(args.data_path, split="validation")
38
+ def collate_fn(batch):
39
+ images = [item['image'].convert('RGB') for item in batch]
40
+ labels = [item['label'] for item in batch]
41
+ labels = torch.tensor(labels)
42
+ return {
43
+ 'image': images,
44
+ 'label': labels
45
+ }
46
+ return DataLoader(dataset, batch_size=args.batch_size, shuffle=False, num_workers=4, collate_fn=collate_fn)
47
+
48
+
49
+ def evaluate_model(args, dataloader, model_info):
50
+ """Evaluate a model on ImageNet-1k validation set"""
51
+ device = torch.device(args.device if torch.cuda.is_available() else "cpu")
52
+
53
+ model = AutoModelForImageClassification.from_pretrained(
54
+ model_info["path"],
55
+ torch_dtype=torch.float32 # Use float32 for consistency
56
+ )
57
+
58
+ processor = AutoImageProcessor.from_pretrained(model_info["path"])
59
+ print(dir(processor))
60
+ print(processor.size)
61
+ model.to(device)
62
+ model.eval()
63
+
64
+ # Initialize metrics
65
+ correct_top1 = 0
66
+ correct_top5 = 0
67
+ total_samples = 0
68
+
69
+ with torch.no_grad():
70
+ for batch_idx, batch in enumerate(tqdm(dataloader, desc="Evaluating")):
71
+ images = batch['image']
72
+ labels = batch['label']
73
+
74
+ inputs = processor(images, return_tensors="pt")
75
+
76
+ inputs = {k: v.to(device) for k, v in inputs.items()}
77
+ labels = labels.to(device)
78
+
79
+
80
+ outputs = model(**inputs)
81
+ torch.cuda.synchronize()
82
+
83
+ logits = outputs.logits
84
+ predictions = torch.softmax(logits, dim=-1)
85
+
86
+ _, predicted_classes = torch.topk(predictions, 5, dim=1)
87
+
88
+ correct_top1 += (predicted_classes[:, 0] == labels).sum().item()
89
+
90
+ for i in range(5):
91
+ correct_top5 += (predicted_classes[:, i] == labels).sum().item()
92
+
93
+ total_samples += labels.size(0)
94
+
95
+ top1_accuracy = (correct_top1 / total_samples) * 100
96
+ top5_accuracy = (correct_top5 / total_samples) * 100
97
+ avg_inference_time, throughput = benchmark_inference(model, processor, device)
98
+
99
+
100
+ sample_inputs = processor(images[:1], return_tensors="pt")
101
+ sample_inputs = {k: v.to(device) for k, v in sample_inputs.items()}
102
+
103
+ # Calculate model parameters
104
+ total_params = sum(p.numel() for p in model.parameters())
105
+ parameters_millions = total_params
106
+
107
+ # Calculate model size
108
+ model_size = sum(p.numel() * p.element_size() for p in model.parameters())
109
+
110
+ sample_tensor = sample_inputs['pixel_values']
111
+ flops = FlopCountAnalysis(model, sample_tensor).total()
112
+
113
+ metrics = {
114
+ "model": model_info["path"],
115
+ "top1_accuracy": top1_accuracy,
116
+ "top5_accuracy": top5_accuracy,
117
+ "parameters": total_params,
118
+ "flops": flops,
119
+ "inference_time": avg_inference_time,
120
+ "model_size": model_size,
121
+ "license": model_info["license"]
122
+ }
123
+
124
+ return metrics
125
+
126
+
127
+
128
+
129
+ def load_models_list(json_path):
130
+ """Load models list from JSON file"""
131
+ with open(json_path, 'r') as f:
132
+ models = json.load(f)
133
+ return models
134
+
135
+
136
+ def load_existing_results(output_path):
137
+ """Load existing results from JSONL file and return set of evaluated model paths"""
138
+ evaluated_models = set()
139
+ results = []
140
+
141
+ if os.path.exists(output_path):
142
+ try:
143
+ with open(output_path, 'r') as f:
144
+ for line in f:
145
+ if line.strip(): # Skip empty lines
146
+ result = json.loads(line.strip())
147
+ evaluated_models.add(result['model'])
148
+ results.append(result)
149
+ print(f"Found {len(evaluated_models)} existing results in {output_path}")
150
+ except (json.JSONDecodeError, KeyError) as e:
151
+ print(f"Warning: Error reading existing results from {output_path}: {e}")
152
+ print("Starting fresh evaluation...")
153
+
154
+ return evaluated_models, results
155
+
156
+
157
+ def save_result_to_jsonl(result, output_path):
158
+ """Append a single evaluation result to JSONL file"""
159
+ with open(output_path, 'a') as jsonlfile:
160
+ jsonlfile.write(json.dumps(result) + '\n')
161
+
162
+ print(f"Result saved to {output_path}")
163
+
164
+
165
+ def save_results_to_jsonl(results, output_path):
166
+ """Save evaluation results to JSONL file (overwrites existing file)"""
167
+ if not results:
168
+ print("No results to save.")
169
+ return
170
+
171
+ with open(output_path, 'w') as jsonlfile:
172
+ for result in results:
173
+ jsonlfile.write(json.dumps(result) + '\n')
174
+
175
+ print(f"Results saved to {output_path}")
176
+
177
+ if __name__ == "__main__":
178
+ parser = argparse.ArgumentParser(
179
+ prog='ImageNet-1k Evaluation',
180
+ description='Evaluate models on ImageNet-1k validation set',
181
+ epilog='Results will be saved to JSONL file')
182
+ parser.add_argument('--data-path', default="ILSVRC/imagenet-1k",
183
+ help='Path to ImageNet-1k dataset')
184
+ parser.add_argument('--device', default="cuda",
185
+ help='Device to use for evaluation (cuda/cpu)')
186
+ parser.add_argument('--batch-size', type=int, default=128,
187
+ help='Batch size for evaluation')
188
+ parser.add_argument('--models-list', default="models_list.json",
189
+ help='Path to JSON file containing models list')
190
+ parser.add_argument('--output-path', default="imagenet_results.jsonl",
191
+ help='Path to save evaluation results')
192
+ args = parser.parse_args()
193
+
194
+ # Override data path with absolute path
195
+ args.device = "cuda:6"
196
+ args.data_path = "/data3/salah/datasets/imagenet-1k"
197
+
198
+ # Load models list
199
+ models_list = load_models_list(args.models_list)
200
+
201
+ # Load existing results to avoid re-evaluating models
202
+ evaluated_models, existing_results = load_existing_results(args.output_path)
203
+
204
+ # Filter out models that have already been evaluated
205
+ models_to_evaluate = [model for model in models_list if model['path'] not in evaluated_models]
206
+
207
+ if len(models_to_evaluate) < len(models_list):
208
+ skipped_count = len(models_list) - len(models_to_evaluate)
209
+ print(f"Skipping {skipped_count} models that have already been evaluated")
210
+
211
+ if not models_to_evaluate:
212
+ print("All models have already been evaluated!")
213
+ results = existing_results
214
+ else:
215
+ # Load dataset only if we have models to evaluate
216
+ print("Loading dataset...")
217
+ dataloader = load_dataloader(args)
218
+ print(f"Dataset loaded with {len(dataloader)} batches")
219
+
220
+ # Evaluate remaining models
221
+ results = existing_results.copy() # Start with existing results
222
+ for i, model_info in enumerate(models_to_evaluate):
223
+ print(f"\n{'='*50}")
224
+ print(f"Evaluating model {i+1}/{len(models_to_evaluate)}: {model_info['path']}")
225
+ print(f"{'='*50}")
226
+
227
+ metrics = evaluate_model(args, dataloader, model_info)
228
+ results.append(metrics)
229
+
230
+ # Save result immediately after each model evaluation
231
+ save_result_to_jsonl(metrics, args.output_path)
232
+
233
+ print(f"\nEvaluation complete! Results saved to {args.output_path}")
234
+
235
+ # Print summary
236
+ print("\nSummary:")
237
+ for result in results:
238
+ if result['top1_accuracy'] != -1:
239
+ print(f" {result['model']}: {result['top1_accuracy']:.2f}% Top-1, {result['top5_accuracy']:.2f}% Top-5")
240
+ else:
241
+ print(f" {result['model']}: Failed to evaluate")
imagenet_results.jsonl ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"model": "microsoft/resnet-18", "top1_accuracy": 69.6, "top5_accuracy": 89.098, "parameters": 11689512, "flops": 1819065856, "inference_time": 2.6572346687316895, "model_size": 46758048, "license": "Open"}
2
+ {"model": "microsoft/resnet-26", "top1_accuracy": 75.27199999999999, "top5_accuracy": 92.596, "parameters": 15995176, "flops": 2357058560, "inference_time": 3.2204389572143555, "model_size": 63980704, "license": "Open"}
3
+ {"model": "microsoft/resnet-34", "top1_accuracy": 75.14999999999999, "top5_accuracy": 92.186, "parameters": 21797672, "flops": 3671262720, "inference_time": 3.9008617401123047, "model_size": 87190688, "license": "Open"}
4
+ {"model": "microsoft/resnet-50", "top1_accuracy": 80.128, "top5_accuracy": 94.502, "parameters": 25557032, "flops": 4111512576, "inference_time": 5.436229705810547, "model_size": 102228128, "license": "Open"}
5
+ {"model": "microsoft/resnet-101", "top1_accuracy": 81.914, "top5_accuracy": 95.692, "parameters": 44549160, "flops": 7833969664, "inference_time": 10.08899211883545, "model_size": 178196640, "license": "Open"}
6
+ {"model": "microsoft/resnet-152", "top1_accuracy": 82.5, "top5_accuracy": 96.076, "parameters": 60192808, "flops": 11558835200, "inference_time": 14.954924583435059, "model_size": 240771232, "license": "Open"}
7
+ {"model": "facebook/convnext-base-224-22k-1k", "top1_accuracy": 85.82, "top5_accuracy": 97.858, "parameters": 88591464, "flops": 15378066432, "inference_time": 8.328402042388916, "model_size": 354365856, "license": "Open"}
8
+ {"model": "facebook/convnext-base-224", "top1_accuracy": 83.842, "top5_accuracy": 96.746, "parameters": 88591464, "flops": 15378066432, "inference_time": 8.364510536193848, "model_size": 354365856, "license": "Open"}
9
+ {"model": "facebook/convnext-base-384-22k-1k", "top1_accuracy": 86.816, "top5_accuracy": 98.25, "parameters": 88591464, "flops": 45190689792, "inference_time": 8.065569400787354, "model_size": 354365856, "license": "Open"}
10
+ {"model": "facebook/convnext-base-384", "top1_accuracy": 85.098, "top5_accuracy": 97.344, "parameters": 88591464, "flops": 45190689792, "inference_time": 12.745106220245361, "model_size": 354365856, "license": "Open"}
11
+ {"model": "facebook/convnext-large-224-22k-1k", "top1_accuracy": 86.614, "top5_accuracy": 98.042, "parameters": 197767336, "flops": 34396439040, "inference_time": 13.010406494140625, "model_size": 791069344, "license": "Open"}
12
+ {"model": "facebook/convnext-large-224", "top1_accuracy": 84.312, "top5_accuracy": 96.89999999999999, "parameters": 197767336, "flops": 34396439040, "inference_time": 13.037407398223877, "model_size": 791069344, "license": "Open"}
13
+ {"model": "facebook/convnext-large-384-22k-1k", "top1_accuracy": 87.456, "top5_accuracy": 98.372, "parameters": 197767336, "flops": 101080419840, "inference_time": 13.244283199310303, "model_size": 791069344, "license": "Open"}
14
+ {"model": "facebook/convnext-large-384", "top1_accuracy": 85.5, "top5_accuracy": 97.592, "parameters": 197767336, "flops": 101080419840, "inference_time": 12.705540657043457, "model_size": 791069344, "license": "Open"}
15
+ {"model": "facebook/convnext-small-224", "top1_accuracy": 83.166, "top5_accuracy": 96.42399999999999, "parameters": 50223688, "flops": 8701214976, "inference_time": 10.579216480255127, "model_size": 200894752, "license": "Open"}
16
+ {"model": "facebook/convnext-tiny-224", "top1_accuracy": 82.062, "top5_accuracy": 95.86200000000001, "parameters": 28589128, "flops": 4466260224, "inference_time": 4.517614841461182, "model_size": 114356512, "license": "Open"}
17
+ {"model": "facebook/convnext-xlarge-224-22k-1k", "top1_accuracy": 86.98599999999999, "top5_accuracy": 98.202, "parameters": 350196968, "flops": 60967704576, "inference_time": 22.357892990112305, "model_size": 1400787872, "license": "Open"}
18
+ {"model": "facebook/convnext-xlarge-384-22k-1k", "top1_accuracy": 87.764, "top5_accuracy": 98.55199999999999, "parameters": 350196968, "flops": 179166406656, "inference_time": 22.17559814453125, "model_size": 1400787872, "license": "Open"}
19
+ {"model": "facebook/deit-base-distilled-patch16-224", "top1_accuracy": 83.39800000000001, "top5_accuracy": 96.43599999999999, "parameters": 87338192, "flops": 16953211392, "inference_time": 5.678451061248779, "model_size": 349352768, "license": "Open"}
init.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ from pathlib import Path
3
+ import pandas as pd
4
+ from typing import Tuple, List
5
+
6
+ # Mock data for demonstration - in a real implementation, this would load from a dataset hub
7
+ def is_model_on_hub(model_name: str) -> Tuple[bool, str]:
8
+ """
9
+ Check if a model exists on Hugging Face Hub.
10
+ Returns (is_on_hub, error_message)
11
+ """
12
+ try:
13
+ # For demo purposes, we'll accept any model name that contains a slash
14
+ if "/" not in model_name:
15
+ return False, "Model name must be in format 'username/model_name'"
16
+
17
+ # In a real implementation, you would check the Hugging Face API
18
+ # response = requests.get(f"https://huggingface.co/api/models/{model_name}")
19
+ # return response.status_code == 200, ""
20
+
21
+ return True, ""
22
+ except Exception as e:
23
+ return False, f"Error checking model: {str(e)}"
24
+
25
+ def upload_file(filename: str, filepath: Path) -> None:
26
+ """
27
+ Upload a file to the dataset hub.
28
+ In a real implementation, this would upload to Hugging Face Hub.
29
+ """
30
+ # For demo purposes, we'll just print the upload
31
+ print(f"Uploading {filename} from {filepath}")
32
+ # In a real implementation, you would use the Hugging Face Hub API
33
+ pass
34
+
35
+ def load_all_info_from_dataset_hub() -> Tuple[Path, List[str], Path, None]:
36
+ """
37
+ Load evaluation queue, requested models, and results from dataset hub.
38
+ Returns (eval_queue_repo, requested_models, jsonl_results, multilingual_jsonl_path)
39
+ """
40
+ # Create mock data for demonstration
41
+ eval_queue_repo = Path("evaluation_queue")
42
+ requested_models = []
43
+
44
+ # Create a sample JSONL with ImageNet-1k results
45
+ jsonl_results = Path("imagenet_results.jsonl")
46
+
47
+ return eval_queue_repo, requested_models, jsonl_results, None
models_list.json ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {"path": "microsoft/resnet-18", "paper": "https://arxiv.org/abs/1512.03385", "license": "Open", "year": 2015},
3
+ {"path": "microsoft/resnet-26", "paper": "https://arxiv.org/abs/1512.03385", "license": "Open", "year": 2015},
4
+ {"path": "microsoft/resnet-34", "paper": "https://arxiv.org/abs/1512.03385", "license": "Open", "year": 2015},
5
+ {"path": "microsoft/resnet-50", "paper": "https://arxiv.org/abs/1512.03385", "license": "Open", "year": 2015},
6
+ {"path": "microsoft/resnet-101", "paper": "https://arxiv.org/abs/1512.03385", "license": "Open", "year": 2015},
7
+ {"path": "microsoft/resnet-152", "paper": "https://arxiv.org/abs/1512.03385", "license": "Open", "year": 2015},
8
+
9
+ {"path": "facebook/convnext-base-224-22k-1k", "paper": "https://arxiv.org/abs/2201.09792", "license": "Open", "year": 2022},
10
+ {"path": "facebook/convnext-base-224", "paper": "https://arxiv.org/abs/2201.09792", "license": "Open", "year": 2022},
11
+ {"path": "facebook/convnext-base-384-22k-1k", "paper": "https://arxiv.org/abs/2201.09792", "license": "Open", "year": 2022},
12
+ {"path": "facebook/convnext-base-384", "paper": "https://arxiv.org/abs/2201.09792", "license": "Open", "year": 2022},
13
+ {"path": "facebook/convnext-large-224-22k-1k", "paper": "https://arxiv.org/abs/2201.09792", "license": "Open", "year": 2022},
14
+ {"path": "facebook/convnext-large-224", "paper": "https://arxiv.org/abs/2201.09792", "license": "Open", "year": 2022},
15
+ {"path": "facebook/convnext-large-384-22k-1k", "paper": "https://arxiv.org/abs/2201.09792", "license": "Open", "year": 2022},
16
+ {"path": "facebook/convnext-large-384", "paper": "https://arxiv.org/abs/2201.09792", "license": "Open", "year": 2022},
17
+ {"path": "facebook/convnext-small-224", "paper": "https://arxiv.org/abs/2201.09792", "license": "Open", "year": 2022},
18
+ {"path": "facebook/convnext-tiny-224", "paper": "https://arxiv.org/abs/2201.09792", "license": "Open", "year": 2022},
19
+ {"path": "facebook/convnext-xlarge-224-22k-1k", "paper": "https://arxiv.org/abs/2201.09792", "license": "Open", "year": 2022},
20
+ {"path": "facebook/convnext-xlarge-384-22k-1k", "paper": "https://arxiv.org/abs/2201.09792", "license": "Open", "year": 2022},
21
+
22
+ {"path": "facebook/deit-base-distilled-patch16-224", "paper": "https://arxiv.org/abs/2012.12877", "license": "Open", "year": 2020},
23
+ {"path": "facebook/deit-base-distilled-patch16-384", "paper": "https://arxiv.org/abs/2012.12877", "license": "Open", "year": 2020},
24
+ {"path": "facebook/deit-base-patch16-224", "paper": "https://arxiv.org/abs/2012.12877", "license": "Open", "year": 2020},
25
+ {"path": "facebook/deit-base-patch16-384", "paper": "https://arxiv.org/abs/2012.12877", "license": "Open", "year": 2020},
26
+ {"path": "facebook/deit-small-distilled-patch16-224", "paper": "https://arxiv.org/abs/2012.12877", "license": "Open", "year": 2020},
27
+ {"path": "facebook/deit-small-patch16-224", "paper": "https://arxiv.org/abs/2012.12877", "license": "Open", "year": 2020},
28
+ {"path": "facebook/deit-tiny-distilled-patch16-224", "paper": "https://arxiv.org/abs/2012.12877", "license": "Open", "year": 2020},
29
+ {"path": "facebook/deit-tiny-patch16-224", "paper": "https://arxiv.org/abs/2012.12877", "license": "Open", "year": 2020},
30
+
31
+ {"path": "facebook/regnet-x-002", "paper": "https://arxiv.org/abs/2003.13678", "license": "Open", "year": 2020},
32
+ {"path": "facebook/regnet-x-004", "paper": "https://arxiv.org/abs/2003.13678", "license": "Open", "year": 2020},
33
+ {"path": "facebook/regnet-x-006", "paper": "https://arxiv.org/abs/2003.13678", "license": "Open", "year": 2020},
34
+ {"path": "facebook/regnet-x-008", "paper": "https://arxiv.org/abs/2003.13678", "license": "Open", "year": 2020},
35
+ {"path": "facebook/regnet-x-016", "paper": "https://arxiv.org/abs/2003.13678", "license": "Open", "year": 2020},
36
+ {"path": "facebook/regnet-x-032", "paper": "https://arxiv.org/abs/2003.13678", "license": "Open", "year": 2020},
37
+ {"path": "facebook/regnet-x-040", "paper": "https://arxiv.org/abs/2003.13678", "license": "Open", "year": 2020},
38
+ {"path": "facebook/regnet-x-064", "paper": "https://arxiv.org/abs/2003.13678", "license": "Open", "year": 2020},
39
+ {"path": "facebook/regnet-x-080", "paper": "https://arxiv.org/abs/2003.13678", "license": "Open", "year": 2020},
40
+ {"path": "facebook/regnet-x-120", "paper": "https://arxiv.org/abs/2003.13678", "license": "Open", "year": 2020},
41
+ {"path": "facebook/regnet-x-160", "paper": "https://arxiv.org/abs/2003.13678", "license": "Open", "year": 2020},
42
+ {"path": "facebook/regnet-x-320", "paper": "https://arxiv.org/abs/2003.13678", "license": "Open", "year": 2020},
43
+ {"path": "facebook/regnet-y-002", "paper": "https://arxiv.org/abs/2003.13678", "license": "Open", "year": 2020},
44
+ {"path": "facebook/regnet-y-004", "paper": "https://arxiv.org/abs/2003.13678", "license": "Open", "year": 2020},
45
+ {"path": "facebook/regnet-y-006", "paper": "https://arxiv.org/abs/2003.13678", "license": "Open", "year": 2020},
46
+ {"path": "facebook/regnet-y-008", "paper": "https://arxiv.org/abs/2003.13678", "license": "Open", "year": 2020},
47
+ {"path": "facebook/regnet-y-016", "paper": "https://arxiv.org/abs/2003.13678", "license": "Open", "year": 2020},
48
+ {"path": "facebook/regnet-y-032", "paper": "https://arxiv.org/abs/2003.13678", "license": "Open", "year": 2020},
49
+ {"path": "facebook/regnet-y-040", "paper": "https://arxiv.org/abs/2003.13678", "license": "Open", "year": 2020},
50
+ {"path": "facebook/regnet-y-064", "paper": "https://arxiv.org/abs/2003.13678", "license": "Open", "year": 2020},
51
+ {"path": "facebook/regnet-y-080", "paper": "https://arxiv.org/abs/2003.13678", "license": "Open", "year": 2020},
52
+ {"path": "facebook/regnet-y-120", "paper": "https://arxiv.org/abs/2003.13678", "license": "Open", "year": 2020},
53
+ {"path": "facebook/regnet-y-160", "paper": "https://arxiv.org/abs/2003.13678", "license": "Open", "year": 2020},
54
+ {"path": "facebook/regnet-y-320", "paper": "https://arxiv.org/abs/2003.13678", "license": "Open", "year": 2020},
55
+ {"path": "facebook/regnet-y-320-seer-in1k", "paper": "https://arxiv.org/abs/2003.13678", "license": "Open", "year": 2020},
56
+ {"path": "facebook/regnet-y-640-seer-in1k", "paper": "https://arxiv.org/abs/2003.13678", "license": "Open", "year": 2020},
57
+ {"path": "facebook/regnet-y-1280-seer-in1k", "paper": "https://arxiv.org/abs/2003.13678", "license": "Open", "year": 2020},
58
+ {"path": "facebook/regnet-y-10b-seer-in1k", "paper": "https://arxiv.org/abs/2003.13678", "license": "Open", "year": 2020},
59
+
60
+ {"path": "facebook/data2vec-vision-base", "paper": "https://arxiv.org/abs/2202.03555", "license": "Open", "year": 2022},
61
+ {"path": "facebook/data2vec-vision-large", "paper": "https://arxiv.org/abs/2202.03555", "license": "Open", "year": 2022},
62
+ {"path": "facebook/data2vec-vision-large-ft1k", "paper": "https://arxiv.org/abs/2202.03555", "license": "Open", "year": 2022},
63
+ {"path": "facebook/data2vec-vision-base-ft1k", "paper": "https://arxiv.org/abs/2202.03555", "license": "Open", "year": 2022},
64
+
65
+ {"path": "facebook/levit-128", "paper": "https://arxiv.org/abs/2104.01136", "license": "Open", "year": 2021},
66
+ {"path": "facebook/levit-128S", "paper": "https://arxiv.org/abs/2104.01136", "license": "Open", "year": 2021},
67
+ {"path": "facebook/levit-192", "paper": "https://arxiv.org/abs/2104.01136", "license": "Open", "year": 2021},
68
+ {"path": "facebook/levit-256", "paper": "https://arxiv.org/abs/2104.01136", "license": "Open", "year": 2021},
69
+ {"path": "facebook/levit-384", "paper": "https://arxiv.org/abs/2104.01136", "license": "Open", "year": 2021},
70
+
71
+ {"path": "facebook/convnextv2-atto-1k-224", "paper": "https://arxiv.org/abs/2301.00808", "license": "Open", "year": 2023},
72
+ {"path": "facebook/convnextv2-femto-1k-224", "paper": "https://arxiv.org/abs/2301.00808", "license": "Open", "year": 2023},
73
+ {"path": "facebook/convnextv2-pico-1k-224", "paper": "https://arxiv.org/abs/2301.00808", "license": "Open", "year": 2023},
74
+ {"path": "facebook/convnextv2-nano-1k-224", "paper": "https://arxiv.org/abs/2301.00808", "license": "Open", "year": 2023},
75
+ {"path": "facebook/convnextv2-tiny-1k-224", "paper": "https://arxiv.org/abs/2301.00808", "license": "Open", "year": 2023},
76
+ {"path": "facebook/convnextv2-base-1k-224", "paper": "https://arxiv.org/abs/2301.00808", "license": "Open", "year": 2023},
77
+ {"path": "facebook/convnextv2-large-1k-224", "paper": "https://arxiv.org/abs/2301.00808", "license": "Open", "year": 2023},
78
+ {"path": "facebook/convnextv2-huge-1k-224", "paper": "https://arxiv.org/abs/2301.00808", "license": "Open", "year": 2023},
79
+ {"path": "facebook/convnextv2-nano-22k-224", "paper": "https://arxiv.org/abs/2301.00808", "license": "Open", "year": 2023},
80
+ {"path": "facebook/convnextv2-nano-22k-384", "paper": "https://arxiv.org/abs/2301.00808", "license": "Open", "year": 2023},
81
+ {"path": "facebook/convnextv2-tiny-22k-224", "paper": "https://arxiv.org/abs/2301.00808", "license": "Open", "year": 2023},
82
+ {"path": "facebook/convnextv2-tiny-22k-384", "paper": "https://arxiv.org/abs/2301.00808", "license": "Open", "year": 2023},
83
+ {"path": "facebook/convnextv2-base-22k-224", "paper": "https://arxiv.org/abs/2301.00808", "license": "Open", "year": 2023},
84
+ {"path": "facebook/convnextv2-base-22k-384", "paper": "https://arxiv.org/abs/2301.00808", "license": "Open", "year": 2023},
85
+ {"path": "facebook/convnextv2-large-22k-224", "paper": "https://arxiv.org/abs/2301.00808", "license": "Open", "year": 2023},
86
+ {"path": "facebook/convnextv2-large-22k-384", "paper": "https://arxiv.org/abs/2301.00808", "license": "Open", "year": 2023},
87
+ {"path": "facebook/convnextv2-huge-22k-384", "paper": "https://arxiv.org/abs/2301.00808", "license": "Open", "year": 2023},
88
+ {"path": "facebook/convnextv2-huge-22k-512", "paper": "https://arxiv.org/abs/2301.00808", "license": "Open", "year": 2023},
89
+
90
+ {"path": "facebook/dinov2-small-imagenet1k-1-layer", "paper": "https://arxiv.org/abs/2304.07193", "license": "Open", "year": 2023},
91
+ {"path": "facebook/dinov2-base-imagenet1k-1-layer", "paper": "https://arxiv.org/abs/2304.07193", "license": "Open", "year": 2023},
92
+ {"path": "facebook/dinov2-large-imagenet1k-1-layer", "paper": "https://arxiv.org/abs/2304.07193", "license": "Open", "year": 2023},
93
+ {"path": "facebook/dinov2-giant-imagenet1k-1-layer", "paper": "https://arxiv.org/abs/2304.07193", "license": "Open", "year": 2023},
94
+ {"path": "facebook/dinov2-with-registers-small-imagenet1k-1-layer", "paper": "https://arxiv.org/abs/2304.07193", "license": "Open", "year": 2023},
95
+ {"path": "facebook/dinov2-with-registers-base-imagenet1k-1-layer", "paper": "https://arxiv.org/abs/2304.07193", "license": "Open", "year": 2023},
96
+ {"path": "facebook/dinov2-with-registers-large-imagenet1k-1-layer", "paper": "https://arxiv.org/abs/2304.07193", "license": "Open", "year": 2023},
97
+ {"path": "facebook/dinov2-with-registers-giant-imagenet1k-1-layer", "paper": "https://arxiv.org/abs/2304.07193", "license": "Open", "year": 2023},
98
+
99
+ {"path": "facebook/hiera-tiny-224-in1k-hf", "paper": "https://arxiv.org/abs/2306.00989", "license": "Open", "year": 2023},
100
+ {"path": "facebook/hiera-small-224-in1k-hf", "paper": "https://arxiv.org/abs/2306.00989", "license": "Open", "year": 2023},
101
+ {"path": "facebook/hiera-base-224-in1k-hf", "paper": "https://arxiv.org/abs/2306.00989", "license": "Open", "year": 2023},
102
+ {"path": "facebook/hiera-base-plus-224-in1k-hf", "paper": "https://arxiv.org/abs/2306.00989", "license": "Open", "year": 2023},
103
+ {"path": "facebook/hiera-large-224-in1k-hf", "paper": "https://arxiv.org/abs/2306.00989", "license": "Open", "year": 2023},
104
+ {"path": "facebook/hiera-huge-224-in1k-hf", "paper": "https://arxiv.org/abs/2306.00989", "license": "Open", "year": 2023},
105
+ {"path": "facebook/hiera_small_224.mae_in1k_ft_in1k", "paper": "https://arxiv.org/abs/2306.00989", "license": "Open", "year": 2023},
106
+ {"path": "facebook/hiera_base_224.mae_in1k_ft_in1k", "paper": "https://arxiv.org/abs/2306.00989", "license": "Open", "year": 2023},
107
+
108
+ {"path": "facebook/superblock-vit-b-16", "paper": "https://arxiv.org/abs/2305.15798", "license": "Open", "year": 2023},
109
+
110
+ {"path": "google/vit-base-patch16-224", "paper": "https://arxiv.org/abs/2010.11929", "license": "Apache-2.0", "year": 2020},
111
+ {"path": "google/vit-large-patch16-384", "paper": "https://arxiv.org/abs/2010.11929", "license": "Apache-2.0", "year": 2020},
112
+ {"path": "google/vit-base-patch16-384", "paper": "https://arxiv.org/abs/2010.11929", "license": "Apache-2.0", "year": 2020},
113
+ {"path": "google/vit-base-patch32-384", "paper": "https://arxiv.org/abs/2010.11929", "license": "Apache-2.0", "year": 2020},
114
+ {"path": "google/vit-large-patch16-224", "paper": "https://arxiv.org/abs/2010.11929", "license": "Apache-2.0", "year": 2020},
115
+ {"path": "google/vit-large-patch32-384", "paper": "https://arxiv.org/abs/2010.11929", "license": "Apache-2.0", "year": 2020},
116
+ {"path": "google/vit-hybrid-base-bit-384", "paper": "https://arxiv.org/abs/2010.11929", "license": "Apache-2.0", "year": 2020},
117
+
118
+ {"path": "google/cxr-foundation", "paper": "https://arxiv.org/abs/2311.18775", "license": "Apache-2.0", "year": 2023},
119
+ {"path": "google/derm-foundation", "paper": "https://arxiv.org/abs/2311.18775", "license": "Apache-2.0", "year": 2023},
120
+
121
+ {"path": "google/mobilenet_v2_1.4_224", "paper": "https://arxiv.org/abs/1801.04381", "license": "Apache-2.0", "year": 2018},
122
+ {"path": "google/mobilenet_v2_1.0_224", "paper": "https://arxiv.org/abs/1801.04381", "license": "Apache-2.0", "year": 2018},
123
+ {"path": "google/mobilenet_v2_0.75_160", "paper": "https://arxiv.org/abs/1801.04381", "license": "Apache-2.0", "year": 2018},
124
+ {"path": "google/mobilenet_v2_0.35_96", "paper": "https://arxiv.org/abs/1801.04381", "license": "Apache-2.0", "year": 2018},
125
+
126
+ {"path": "google/mobilenet_v1_1.0_224", "paper": "https://arxiv.org/abs/1704.04861", "license": "Apache-2.0", "year": 2017},
127
+ {"path": "google/mobilenet_v1_0.75_192", "paper": "https://arxiv.org/abs/1704.04861", "license": "Apache-2.0", "year": 2017},
128
+
129
+ {"path": "google/bit-50", "paper": "https://arxiv.org/abs/1912.11370", "license": "Apache-2.0", "year": 2019},
130
+
131
+ {"path": "google/efficientnet-b0", "paper": "https://arxiv.org/abs/1905.11946", "license": "Apache-2.0", "year": 2019},
132
+ {"path": "google/efficientnet-b1", "paper": "https://arxiv.org/abs/1905.11946", "license": "Apache-2.0", "year": 2019},
133
+ {"path": "google/efficientnet-b2", "paper": "https://arxiv.org/abs/1905.11946", "license": "Apache-2.0", "year": 2019},
134
+ {"path": "google/efficientnet-b3", "paper": "https://arxiv.org/abs/1905.11946", "license": "Apache-2.0", "year": 2019},
135
+ {"path": "google/efficientnet-b4", "paper": "https://arxiv.org/abs/1905.11946", "license": "Apache-2.0", "year": 2019},
136
+ {"path": "google/efficientnet-b5", "paper": "https://arxiv.org/abs/1905.11946", "license": "Apache-2.0", "year": 2019},
137
+ {"path": "google/efficientnet-b6", "paper": "https://arxiv.org/abs/1905.11946", "license": "Apache-2.0", "year": 2019},
138
+ {"path": "google/efficientnet-b7", "paper": "https://arxiv.org/abs/1905.11946", "license": "Apache-2.0", "year": 2019},
139
+
140
+
141
+ {"path": "qualcomm/MobileNet-v3-Small", "paper": "https://arxiv.org/abs/1905.02244", "license": "Open", "year": 2019},
142
+ {"path": "qualcomm/Swin-Base", "paper": "https://arxiv.org/abs/2103.14030", "license": "Open", "year": 2021},
143
+ {"path": "qualcomm/DenseNet-121", "paper": "https://arxiv.org/abs/1608.06993", "license": "Open", "year": 2016},
144
+ {"path": "qualcomm/Inception-v3", "paper": "https://arxiv.org/abs/1512.00567", "license": "Open", "year": 2015},
145
+ {"path": "qualcomm/WideResNet50", "paper": "https://arxiv.org/abs/1605.07146", "license": "Open", "year": 2016},
146
+ {"path": "qualcomm/RegNet", "paper": "https://arxiv.org/abs/2003.13678", "license": "Open", "year": 2020},
147
+ {"path": "qualcomm/ResNet18", "paper": "https://arxiv.org/abs/1512.03385", "license": "Open", "year": 2015},
148
+ {"path": "qualcomm/MobileNet-v2", "paper": "https://arxiv.org/abs/1801.04381", "license": "Open", "year": 2018},
149
+ {"path": "qualcomm/ConvNext-Tiny", "paper": "https://arxiv.org/abs/2201.03545", "license": "Open", "year": 2022},
150
+ {"path": "qualcomm/ResNet101", "paper": "https://arxiv.org/abs/1512.03385", "license": "Open", "year": 2015},
151
+ {"path": "qualcomm/OpenAI-Clip", "paper": "https://arxiv.org/abs/2103.00020", "license": "Open", "year": 2021},
152
+ {"path": "qualcomm/Swin-Tiny", "paper": "https://arxiv.org/abs/2103.14030", "license": "Open", "year": 2021},
153
+ {"path": "qualcomm/ResNeXt101", "paper": "https://arxiv.org/abs/1611.05431", "license": "Open", "year": 2016},
154
+ {"path": "qualcomm/EfficientNet-B0", "paper": "https://arxiv.org/abs/1905.11946", "license": "Open", "year": 2019},
155
+ {"path": "qualcomm/GoogLeNet", "paper": "https://arxiv.org/abs/1409.4842", "license": "Open", "year": 2014},
156
+ {"path": "qualcomm/MNASNet05", "paper": "https://arxiv.org/abs/1807.11626", "license": "Open", "year": 2018},
157
+ {"path": "qualcomm/Shufflenet-v2", "paper": "https://arxiv.org/abs/1807.11164", "license": "Open", "year": 2018},
158
+ {"path": "qualcomm/MobileNet-v3-Large", "paper": "https://arxiv.org/abs/1905.02244", "license": "Open", "year": 2019},
159
+ {"path": "qualcomm/Swin-Small", "paper": "https://arxiv.org/abs/2103.14030", "license": "Open", "year": 2021},
160
+ {"path": "qualcomm/ResNet50", "paper": "https://arxiv.org/abs/1512.03385", "license": "Open", "year": 2015},
161
+ {"path": "qualcomm/ResNeXt50", "paper": "https://arxiv.org/abs/1611.05431", "license": "Open", "year": 2016},
162
+ {"path": "qualcomm/VIT", "paper": "https://arxiv.org/abs/2010.11929", "license": "Open", "year": 2020},
163
+ {"path": "qualcomm/EfficientViT-l2-cls", "paper": "https://arxiv.org/abs/2205.14756", "license": "Open", "year": 2022},
164
+ {"path": "qualcomm/EfficientNet-B4", "paper": "https://arxiv.org/abs/1905.11946", "license": "Open", "year": 2019},
165
+ {"path": "qualcomm/EfficientViT-b2-cls", "paper": "https://arxiv.org/abs/2205.14756", "license": "Open", "year": 2022},
166
+ {"path": "qualcomm/EfficientNet-V2-s", "paper": "https://arxiv.org/abs/2104.00298", "license": "Open", "year": 2021},
167
+ {"path": "qualcomm/ConvNext-Base", "paper": "https://arxiv.org/abs/2201.03545", "license": "Open", "year": 2022},
168
+ {"path": "qualcomm/Beit", "paper": "https://arxiv.org/abs/2106.08254", "license": "Open", "year": 2021},
169
+ {"path": "qualcomm/LeViT", "paper": "https://arxiv.org/abs/2104.01136", "license": "Open", "year": 2021},
170
+ {"path": "qualcomm/NASNet", "paper": "https://arxiv.org/abs/1707.07012", "license": "Open", "year": 2017},
171
+ {"path": "qualcomm/DLA-102-X", "paper": "https://arxiv.org/abs/1707.06484", "license": "Open", "year": 2017},
172
+ {"path": "qualcomm/Mobile-VIT", "paper": "https://arxiv.org/abs/2110.02178", "license": "Open", "year": 2021},
173
+ {"path": "qualcomm/SqueezeNet-1.1", "paper": "https://arxiv.org/abs/1602.07360", "license": "Open", "year": 2016},
174
+ {"path": "qualcomm/EfficientFormer", "paper": "https://arxiv.org/abs/2206.01191", "license": "Open", "year": 2022},
175
+
176
+ {"path": "Intel/vit-base-patch16-224-int8-static-inc", "paper": "https://arxiv.org/abs/2010.11929", "license": "Apache-2.0", "year": 2020}
177
+ ]
utils_display.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from dataclasses import dataclass
2
+ from typing import List, Any
3
+ import gradio as gr
4
+
5
+ @dataclass
6
+ class AutoEvalColumn:
7
+ """Column definition for the main leaderboard table"""
8
+ name: str
9
+ type: str
10
+
11
+ def make_clickable_model(model_name: str) -> str:
12
+ """
13
+ Convert model name to clickable link format for Gradio.
14
+ """
15
+ if not model_name or model_name == "N/A":
16
+ return model_name
17
+
18
+ # Create clickable link to Hugging Face model page
19
+ huggingface_url = f"https://huggingface.co/{model_name}"
20
+ return f"[{model_name}]({huggingface_url})"
21
+
22
+ def make_clickable_paper(paper_url: str) -> str:
23
+ """
24
+ Convert paper URL to clickable link format for Gradio.
25
+ """
26
+ if paper_url == "N/A" or not paper_url:
27
+ return "N/A"
28
+ # Use markdown format for better Gradio compatibility
29
+ return f'[πŸ“„ Paper]({paper_url})'
30
+
31
+ def styled_error(message: str) -> str:
32
+ """Return a styled error message"""
33
+ return f'<div style="color: red; background-color: #ffe6e6; padding: 10px; border-radius: 5px; border: 1px solid #ffcccc;">❌ {message}</div>'
34
+
35
+ def styled_message(message: str) -> str:
36
+ """Return a styled success message"""
37
+ return f'<div style="color: green; background-color: #e6ffe6; padding: 10px; border-radius: 5px; border: 1px solid #ccffcc;">βœ… {message}</div>'
38
+
39
+ # Define the fields for the main leaderboard
40
+ fields = lambda cls: [getattr(cls, field.name) for field in cls.__dataclass_fields__.values()]
41
+
42
+ # Column definitions for ImageNet-1k leaderboard
43
+ def get_imagenet_columns() -> List[AutoEvalColumn]:
44
+ """Get column definitions for ImageNet-1k leaderboard"""
45
+ return [
46
+ AutoEvalColumn("Model", "markdown"),
47
+ AutoEvalColumn("Top-1 Accuracy ⬆️", "number"),
48
+ AutoEvalColumn("Top-5 Accuracy ⬆️", "number"),
49
+ AutoEvalColumn("Parameters (M)", "number"),
50
+ AutoEvalColumn("FLOPs (G)", "number"),
51
+ AutoEvalColumn("Inference Time (ms)", "number"),
52
+ AutoEvalColumn("Model Size (MB)", "number"),
53
+ AutoEvalColumn("Paper", "markdown"),
54
+ AutoEvalColumn("Year", "number"),
55
+ AutoEvalColumn("License", "str")
56
+ ]