MohamedRashad commited on
Commit
887de83
Β·
1 Parent(s): f5f7856

Improve error handling in model information retrieval and enforce model size constraints

Browse files
Files changed (1) hide show
  1. utils.py +7 -6
utils.py CHANGED
@@ -47,7 +47,7 @@ def get_model_info(model_id, verbose=False):
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):
@@ -61,11 +61,12 @@ def fetch_model_information(model_name):
61
  return gr.update(choices=supported_precisions, value=supported_precisions[0]), license, num_parameters, num_downloads, num_likes
62
 
63
  def submit_model(model_name, revision, precision, params, license, task, pending_gradio_df):
64
- try:
65
- if float(params) > 5000:
66
- return "Model size should be less than 5000 million parameters (5 billion) πŸ‘€", pending_gradio_df
67
- except ValueError:
68
- gr.Error("The parameter count is not present or is not a number. Please make sure its available and its correct"),
 
69
 
70
  # Handle 'Missing' precision
71
  if precision == 'Missing':
 
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
+ print(f"Error: Could not fetch model information. {str(e)}")
51
  return 0, 0, "Unknown", 0, []
52
 
53
  def fetch_model_information(model_name):
 
61
  return gr.update(choices=supported_precisions, value=supported_precisions[0]), license, num_parameters, num_downloads, num_likes
62
 
63
  def submit_model(model_name, revision, precision, params, license, task, pending_gradio_df):
64
+
65
+ if float(params) == 0:
66
+ return "Model size cannot be zero. If the Auto Fetch feature failed and your model is suitable for evaluation, please open a community discussion for help.", pending_gradio_df
67
+
68
+ if float(params) > 5000:
69
+ return "Model size should be less than 5000 million parameters (5 billion) πŸ‘€", pending_gradio_df
70
 
71
  # Handle 'Missing' precision
72
  if precision == 'Missing':