Clémentine commited on
Commit
1df8383
1 Parent(s): 788108a

updated model param number reader

Browse files
src/auto_leaderboard/get_model_metadata.py CHANGED
@@ -1,4 +1,5 @@
1
  import re
 
2
  from typing import List
3
 
4
  from src.utils_display import AutoEvalColumn
@@ -6,7 +7,7 @@ from src.auto_leaderboard.model_metadata_type import get_model_type
6
 
7
  from huggingface_hub import HfApi
8
  import huggingface_hub
9
- api = HfApi()
10
 
11
 
12
  def get_model_infos_from_hub(leaderboard_data: List[dict]):
@@ -15,9 +16,10 @@ def get_model_infos_from_hub(leaderboard_data: List[dict]):
15
  try:
16
  model_info = api.model_info(model_name)
17
  except huggingface_hub.utils._errors.RepositoryNotFoundError:
 
18
  model_data[AutoEvalColumn.license.name] = None
19
  model_data[AutoEvalColumn.likes.name] = None
20
- model_data[AutoEvalColumn.params.name] = None
21
  continue
22
 
23
  model_data[AutoEvalColumn.license.name] = get_model_license(model_info)
@@ -41,14 +43,12 @@ def get_model_size(model_name, model_info):
41
  try:
42
  return round(model_info.safetensors["total"] / 1e9, 3)
43
  except AttributeError:
44
- #print(f"Repository {model_id} does not have safetensors weights")
45
- pass
46
- try:
47
- size_match = re.search(size_pattern, model_name.lower())
48
- size = size_match.group(0)
49
- return round(int(size[:-1]) if size[-1] == "b" else int(size[:-1]) / 1e3, 3)
50
- except AttributeError:
51
- return None
52
 
53
 
54
  def apply_metadata(leaderboard_data: List[dict]):
 
1
  import re
2
+ import os
3
  from typing import List
4
 
5
  from src.utils_display import AutoEvalColumn
 
7
 
8
  from huggingface_hub import HfApi
9
  import huggingface_hub
10
+ api = HfApi(token=os.environ.get("H4_TOKEN", None))
11
 
12
 
13
  def get_model_infos_from_hub(leaderboard_data: List[dict]):
 
16
  try:
17
  model_info = api.model_info(model_name)
18
  except huggingface_hub.utils._errors.RepositoryNotFoundError:
19
+ print("Repo not found!", model_name)
20
  model_data[AutoEvalColumn.license.name] = None
21
  model_data[AutoEvalColumn.likes.name] = None
22
+ model_data[AutoEvalColumn.params.name] = get_model_size(model_name, None)
23
  continue
24
 
25
  model_data[AutoEvalColumn.license.name] = get_model_license(model_info)
 
43
  try:
44
  return round(model_info.safetensors["total"] / 1e9, 3)
45
  except AttributeError:
46
+ try:
47
+ size_match = re.search(size_pattern, model_name.lower())
48
+ size = size_match.group(0)
49
+ return round(int(size[:-1]) if size[-1] == "b" else int(size[:-1]) / 1e3, 3)
50
+ except AttributeError:
51
+ return None
 
 
52
 
53
 
54
  def apply_metadata(leaderboard_data: List[dict]):