Spaces:
Running
on
A10G
Running
on
A10G
MekkCyber
commited on
Commit
·
4512289
1
Parent(s):
fa23c0d
add warnings and errors
Browse files
app.py
CHANGED
|
@@ -117,18 +117,38 @@ def save_model(model, model_name, quant_type_4, double_quant_4, compute_type_4,
|
|
| 117 |
|
| 118 |
def quantize_and_save(profile: gr.OAuthProfile | None, oauth_token: gr.OAuthToken | None, model_name, quant_type_4, double_quant_4, compute_type_4, quant_storage_4, quantized_model_name, public):
|
| 119 |
if oauth_token is None :
|
| 120 |
-
return "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
if not profile:
|
| 122 |
-
return "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
exists_message = check_model_exists(oauth_token, profile.username, model_name, quantized_model_name)
|
| 124 |
if exists_message :
|
| 125 |
-
return
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
|
| 133 |
|
| 134 |
css="""/* Custom CSS to allow scrolling */
|
|
|
|
| 117 |
|
| 118 |
def quantize_and_save(profile: gr.OAuthProfile | None, oauth_token: gr.OAuthToken | None, model_name, quant_type_4, double_quant_4, compute_type_4, quant_storage_4, quantized_model_name, public):
|
| 119 |
if oauth_token is None :
|
| 120 |
+
return """
|
| 121 |
+
<div class="error-box">
|
| 122 |
+
<h3>❌ Authentication Error</h3>
|
| 123 |
+
<p>Please sign in to your HuggingFace account to use the quantizer.</p>
|
| 124 |
+
</div>
|
| 125 |
+
"""
|
| 126 |
if not profile:
|
| 127 |
+
return """
|
| 128 |
+
<div class="error-box">
|
| 129 |
+
<h3>❌ Authentication Error</h3>
|
| 130 |
+
<p>Please sign in to your HuggingFace account to use the quantizer.</p>
|
| 131 |
+
</div>
|
| 132 |
+
"""
|
| 133 |
exists_message = check_model_exists(oauth_token, profile.username, model_name, quantized_model_name)
|
| 134 |
if exists_message :
|
| 135 |
+
return f"""
|
| 136 |
+
<div class="warning-box">
|
| 137 |
+
<h3>⚠️ Model Already Exists</h3>
|
| 138 |
+
<p>{exists_message}</p>
|
| 139 |
+
</div>
|
| 140 |
+
"""
|
| 141 |
+
try:
|
| 142 |
+
quantized_model = quantize_model(model_name, quant_type_4, double_quant_4, compute_type_4, quant_storage_4, oauth_token)
|
| 143 |
+
return save_model(quantized_model, model_name, quant_type_4, double_quant_4, compute_type_4, quant_storage_4, profile.username, oauth_token, quantized_model_name, public)
|
| 144 |
+
except Exception as e :
|
| 145 |
+
print(e)
|
| 146 |
+
return f"""
|
| 147 |
+
<div class="error-box">
|
| 148 |
+
<h3>❌ Error Occurred</h3>
|
| 149 |
+
<p>{str(e)}</p>
|
| 150 |
+
</div>
|
| 151 |
+
"""
|
| 152 |
|
| 153 |
|
| 154 |
css="""/* Custom CSS to allow scrolling */
|