Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Commit
·
f5f7856
1
Parent(s):
179c0b7
Add error handling for model information retrieval in get_model_info function
Browse files
utils.py
CHANGED
@@ -34,17 +34,21 @@ def load_json_results(file_path: Path, prepare_for_display=False, sort_col=None,
|
|
34 |
return df
|
35 |
|
36 |
def get_model_info(model_id, verbose=False):
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
|
|
|
|
|
|
|
|
48 |
|
49 |
def fetch_model_information(model_name):
|
50 |
try:
|
|
|
34 |
return df
|
35 |
|
36 |
def get_model_info(model_id, verbose=False):
|
37 |
+
try:
|
38 |
+
model_info = api.model_info(model_id)
|
39 |
+
num_downloads = model_info.downloads
|
40 |
+
num_likes = model_info.likes
|
41 |
+
license = model_info.card_data["license"]
|
42 |
+
num_parameters = round(model_info.safetensors.total / 1e6)
|
43 |
+
supported_precisions = list(model_info.safetensors.parameters.keys())
|
44 |
+
if verbose:
|
45 |
+
print(f"Model '{model_id}' has {num_downloads} downloads, {num_likes} likes, and is licensed under {license}.")
|
46 |
+
print(f"The model has approximately {num_parameters:.2f} billion parameters.")
|
47 |
+
print(f"The model supports the following precisions: {supported_precisions}")
|
48 |
+
return num_downloads, num_likes, license, num_parameters, supported_precisions
|
49 |
+
except Exception as e:
|
50 |
+
gr.Error(f"Error: Could not fetch model information. {str(e)}")
|
51 |
+
return 0, 0, "Unknown", 0, []
|
52 |
|
53 |
def fetch_model_information(model_name):
|
54 |
try:
|