Koshti10 commited on
Commit
d9fe49a
1 Parent(s): d515b04

Upload 7 files

Browse files
Files changed (3) hide show
  1. app.py +1 -1
  2. src/leaderboard_utils.py +19 -10
  3. src/version_utils.py +2 -8
app.py CHANGED
@@ -128,7 +128,7 @@ with hf_app:
128
 
129
  # Show information about the clemscore and last updated date below the table
130
  gr.HTML(CLEMSCORE_TEXT)
131
- gr.HTML(f"Last updated - {github_data['date']}")
132
 
133
  # Add a dummy leaderboard to handle search queries in leaderboard_table
134
  # This will show a temporary leaderboard based on the searched value
 
128
 
129
  # Show information about the clemscore and last updated date below the table
130
  gr.HTML(CLEMSCORE_TEXT)
131
+ gr.HTML(f"Last updated - {github_data['mm_date']}")
132
 
133
  # Add a dummy leaderboard to handle search queries in leaderboard_table
134
  # This will show a temporary leaderboard based on the searched value
src/leaderboard_utils.py CHANGED
@@ -31,17 +31,10 @@ def get_github_data():
31
 
32
  version_names = sorted(
33
  [ver['version'] for ver in versions],
34
- key=lambda v: list(map(int, v[1:].split('_')[0].split('.'))), # {{ edit_1 }}: Corrected slicing to handle 'v' prefix
35
  reverse=True
36
  )
37
 
38
- # Get Last updated date of the latest version
39
- latest_version = version_names[0]
40
- latest_date = next(
41
- ver['date'] for ver in versions if ver['version'] == latest_version
42
- )
43
- formatted_date = datetime.strptime(latest_date, "%Y-%m-%d").strftime("%d %b %Y") # {{ edit_1 }}: Updated date format
44
-
45
  # Get Leaderboard data - for text-only + multimodal
46
  github_data = {}
47
 
@@ -49,6 +42,11 @@ def get_github_data():
49
  text_dfs = []
50
  mm_dfs = []
51
 
 
 
 
 
 
52
  for version in version_names:
53
  # Collect CSV data in descending order of clembench-runs versions
54
  # Collect Text-only data
@@ -60,22 +58,33 @@ def get_github_data():
60
  df = process_df(df)
61
  df = df.sort_values(by=df.columns[1], ascending=False) # Sort by clemscore column
62
  text_dfs.append(df)
 
 
 
 
 
63
  else:
64
  print(f"Failed to read Text-only leaderboard CSV file for version: {version}. Status Code: {csv_response.status_code}")
65
 
66
  # Check if version ends with 'multimodal' before constructing the URL
67
  mm_suffix = "_multimodal" if not version.endswith('multimodal') else ""
68
- mm_url = f"{base_repo}{version}{mm_suffix}/results.csv" # {{ edit_1 }}: Conditional suffix for multimodal
69
  mm_response = requests.get(mm_url)
70
  if mm_response.status_code == 200:
71
  df = pd.read_csv(StringIO(mm_response.text))
72
  df = process_df(df)
73
  df = df.sort_values(by=df.columns[1], ascending=False) # Sort by clemscore column
74
  mm_dfs.append(df)
 
 
 
 
 
75
 
76
  github_data["text"] = text_dfs
77
  github_data["multimodal"] = mm_dfs
78
- github_data["date"] = formatted_date
 
79
 
80
  return github_data
81
 
 
31
 
32
  version_names = sorted(
33
  [ver['version'] for ver in versions],
34
+ key=lambda v: list(map(int, v[1:].split('_')[0].split('.'))),
35
  reverse=True
36
  )
37
 
 
 
 
 
 
 
 
38
  # Get Leaderboard data - for text-only + multimodal
39
  github_data = {}
40
 
 
42
  text_dfs = []
43
  mm_dfs = []
44
 
45
+ text_flag = True
46
+ text_date = ""
47
+ mm_flag = True
48
+ mm_date = ""
49
+
50
  for version in version_names:
51
  # Collect CSV data in descending order of clembench-runs versions
52
  # Collect Text-only data
 
58
  df = process_df(df)
59
  df = df.sort_values(by=df.columns[1], ascending=False) # Sort by clemscore column
60
  text_dfs.append(df)
61
+ if text_flag:
62
+ text_flag = False
63
+ text_date = next(ver['date'] for ver in versions if ver['version'] == version)
64
+ text_date = datetime.strptime(text_date, "%Y-%m-%d").strftime("%d %b %Y")
65
+
66
  else:
67
  print(f"Failed to read Text-only leaderboard CSV file for version: {version}. Status Code: {csv_response.status_code}")
68
 
69
  # Check if version ends with 'multimodal' before constructing the URL
70
  mm_suffix = "_multimodal" if not version.endswith('multimodal') else ""
71
+ mm_url = f"{base_repo}{version}{mm_suffix}/results.csv"
72
  mm_response = requests.get(mm_url)
73
  if mm_response.status_code == 200:
74
  df = pd.read_csv(StringIO(mm_response.text))
75
  df = process_df(df)
76
  df = df.sort_values(by=df.columns[1], ascending=False) # Sort by clemscore column
77
  mm_dfs.append(df)
78
+ if mm_flag:
79
+ mm_flag = False
80
+ mm_date = next(ver['date'] for ver in versions if ver['version'] == version)
81
+ mm_date = datetime.strptime(mm_date, "%Y-%m-%d").strftime("%d %b %Y")
82
+
83
 
84
  github_data["text"] = text_dfs
85
  github_data["multimodal"] = mm_dfs
86
+ github_data["date"] = text_date
87
+ github_data["mm_date"] = mm_date
88
 
89
  return github_data
90
 
src/version_utils.py CHANGED
@@ -33,7 +33,7 @@ def get_versions_data():
33
 
34
  version_names = sorted(
35
  [ver['version'] for ver in versions],
36
- key=lambda v: list(map(int, v[1:].split('_')[0].split('.'))), # {{ edit_1 }}: Corrected slicing to handle 'v' prefix
37
  reverse=True
38
  )
39
 
@@ -42,7 +42,7 @@ def get_versions_data():
42
  latest_date = next(
43
  ver['date'] for ver in versions if ver['version'] == latest_version
44
  )
45
- formatted_date = datetime.strptime(latest_date, "%Y-%m-%d").strftime("%d %b %Y") # {{ edit_1 }}: Updated date format
46
 
47
  # Get Versions data
48
  versions_data = {"latest": latest_version, "date": formatted_date}
@@ -62,8 +62,6 @@ def get_versions_data():
62
  df = process_df(df)
63
  df = df.sort_values(by=df.columns[1], ascending=False) # Sort by clemscore column
64
  versions_data[version] = df
65
- else:
66
- print(f"Failed to read Text-only leaderboard CSV file for version: {version}. Status Code: {response.status_code}")
67
 
68
  # Multimodal Data
69
  mm_response = requests.get(mm_url)
@@ -72,8 +70,6 @@ def get_versions_data():
72
  mm_df = process_df(mm_df)
73
  mm_df = mm_df.sort_values(by=mm_df.columns[1], ascending=False) # Sort by clemscore column
74
  versions_data[version+"_multimodal"] = mm_df
75
- else:
76
- print(f"Failed to read multimodal leaderboard CSV file for version: {version}: Status Code: {mm_response.status_code}. Please ignore this message if multimodal results are not available for this version")
77
 
78
  # Multimodal Data
79
  q_response = requests.get(quant_url)
@@ -82,8 +78,6 @@ def get_versions_data():
82
  q_df = process_df(q_df)
83
  q_df = q_df.sort_values(by=q_df.columns[1], ascending=False) # Sort by clemscore column
84
  versions_data[version + "_quantized"] = q_df
85
- else:
86
- print(f"Failed to read quantized leaderboard CSV file for version: {version}: Status Code: {mm_response.status_code}. Please ignore this message if quantized results are not available for this version")
87
 
88
  return versions_data
89
 
 
33
 
34
  version_names = sorted(
35
  [ver['version'] for ver in versions],
36
+ key=lambda v: list(map(int, v[1:].split('_')[0].split('.'))),
37
  reverse=True
38
  )
39
 
 
42
  latest_date = next(
43
  ver['date'] for ver in versions if ver['version'] == latest_version
44
  )
45
+ formatted_date = datetime.strptime(latest_date, "%Y-%m-%d").strftime("%d %b %Y")
46
 
47
  # Get Versions data
48
  versions_data = {"latest": latest_version, "date": formatted_date}
 
62
  df = process_df(df)
63
  df = df.sort_values(by=df.columns[1], ascending=False) # Sort by clemscore column
64
  versions_data[version] = df
 
 
65
 
66
  # Multimodal Data
67
  mm_response = requests.get(mm_url)
 
70
  mm_df = process_df(mm_df)
71
  mm_df = mm_df.sort_values(by=mm_df.columns[1], ascending=False) # Sort by clemscore column
72
  versions_data[version+"_multimodal"] = mm_df
 
 
73
 
74
  # Multimodal Data
75
  q_response = requests.get(quant_url)
 
78
  q_df = process_df(q_df)
79
  q_df = q_df.sort_values(by=q_df.columns[1], ascending=False) # Sort by clemscore column
80
  versions_data[version + "_quantized"] = q_df
 
 
81
 
82
  return versions_data
83