Spaces:
Running
on
A10G
Running
on
A10G
MekkCyber
commited on
Commit
·
25810aa
1
Parent(s):
7e1138c
fix
Browse files
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
|
124 |
-
return "Threshold must be a
|
125 |
|
126 |
-
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)
|