MekkCyber commited on
Commit
25810aa
·
1 Parent(s): 7e1138c
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -111,6 +111,13 @@ def save_model(model, model_name, quantization_type, threshold, quant_type_4, do
111
  )
112
  return f'<h1> 🤗 DONE</h1><br/>Find your repo here: <a href="https://huggingface.co/{repo_name}" target="_blank" style="text-decoration:underline">{repo_name}</a>'
113
 
 
 
 
 
 
 
 
114
  def quantize_and_save(profile: gr.OAuthProfile | None, oauth_token: gr.OAuthToken | None, model_name, quantization_type, threshold, quant_type_4, double_quant_4, quantized_model_name):
115
  if oauth_token is None :
116
  return "Error : Please Sign In to your HuggingFace account to use the quantizer"
@@ -120,10 +127,10 @@ def quantize_and_save(profile: gr.OAuthProfile | None, oauth_token: gr.OAuthToke
120
  if exists_message :
121
  return exists_message
122
 
123
- if not threshold.isdigit() :
124
- return "Threshold must be a number"
125
 
126
- threshold = int(threshold)
127
 
128
  try:
129
  quantized_model = quantize_model(model_name, quantization_type, threshold, quant_type_4, double_quant_4, oauth_token, profile.username)
 
111
  )
112
  return f'<h1> 🤗 DONE</h1><br/>Find your repo here: <a href="https://huggingface.co/{repo_name}" target="_blank" style="text-decoration:underline">{repo_name}</a>'
113
 
114
+ def is_float(value):
115
+ try:
116
+ float(value)
117
+ return True
118
+ except ValueError:
119
+ return False
120
+
121
  def quantize_and_save(profile: gr.OAuthProfile | None, oauth_token: gr.OAuthToken | None, model_name, quantization_type, threshold, quant_type_4, double_quant_4, quantized_model_name):
122
  if oauth_token is None :
123
  return "Error : Please Sign In to your HuggingFace account to use the quantizer"
 
127
  if exists_message :
128
  return exists_message
129
 
130
+ if not is_float(threshold) :
131
+ return "Threshold must be a float"
132
 
133
+ threshold = float(threshold)
134
 
135
  try:
136
  quantized_model = quantize_model(model_name, quantization_type, threshold, quant_type_4, double_quant_4, oauth_token, profile.username)