Spaces:
Running
on
A10G
Running
on
A10G
MekkCyber
commited on
Commit
Β·
2eaaab3
1
Parent(s):
364af2c
add arch
Browse files
app.py
CHANGED
|
@@ -113,7 +113,28 @@ def save_model(model, model_name, quant_type_4, double_quant_4, compute_type_4,
|
|
| 113 |
repo_id=repo_name,
|
| 114 |
repo_type="model",
|
| 115 |
)
|
| 116 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 :
|
|
@@ -129,7 +150,7 @@ def quantize_and_save(profile: gr.OAuthProfile | None, oauth_token: gr.OAuthToke
|
|
| 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"""
|
|
@@ -415,8 +436,8 @@ with gr.Blocks(theme=gr.themes.Ocean(), css=css) as demo:
|
|
| 415 |
|
| 416 |
with gr.Column():
|
| 417 |
quantize_button = gr.Button("π Quantize and Push to the Hub", variant="primary")
|
| 418 |
-
output_link = gr.Markdown(
|
| 419 |
-
|
| 420 |
quantize_button.click(
|
| 421 |
fn=quantize_and_save,
|
| 422 |
inputs=[model_name, quant_type_4, double_quant_4, compute_type_4, quant_storage_4, quantized_model_name, public],
|
|
|
|
| 113 |
repo_id=repo_name,
|
| 114 |
repo_type="model",
|
| 115 |
)
|
| 116 |
+
# Get model architecture as string
|
| 117 |
+
import io
|
| 118 |
+
from contextlib import redirect_stdout
|
| 119 |
+
import html
|
| 120 |
+
|
| 121 |
+
# Capture the model architecture string
|
| 122 |
+
f = io.StringIO()
|
| 123 |
+
with redirect_stdout(f):
|
| 124 |
+
print(model)
|
| 125 |
+
model_architecture_str = f.getvalue()
|
| 126 |
+
|
| 127 |
+
# Escape HTML characters and format with line breaks
|
| 128 |
+
model_architecture_str_html = html.escape(model_architecture_str).replace('\n', '<br/>')
|
| 129 |
+
|
| 130 |
+
# Format it for display in markdown with proper styling
|
| 131 |
+
model_architecture_info = f"""
|
| 132 |
+
<div class="model-architecture" style="max-height: 500px; overflow-y: auto; overflow-x: auto; background-color: #f5f5f5; padding: 5px; border-radius: 8px; font-family: monospace; white-space: pre-wrap;">
|
| 133 |
+
<div style="line-height: 1.2; font-size: 0.75em;">{model_architecture_str_html}</div>
|
| 134 |
+
</div>
|
| 135 |
+
"""
|
| 136 |
+
|
| 137 |
+
return f'π Quantized Model <br/><h1> π€ DONE</h1><br/>Find your repo here: <a href="https://huggingface.co/{repo_name}" target="_blank" style="text-decoration:underline">{repo_name}</a><br/><br/>π Model Architecture<br/>{model_architecture_info}'
|
| 138 |
|
| 139 |
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):
|
| 140 |
if oauth_token is None :
|
|
|
|
| 150 |
<h3>β Authentication Error</h3>
|
| 151 |
<p>Please sign in to your HuggingFace account to use the quantizer.</p>
|
| 152 |
</div>
|
| 153 |
+
"""
|
| 154 |
exists_message = check_model_exists(oauth_token, profile.username, model_name, quantized_model_name)
|
| 155 |
if exists_message :
|
| 156 |
return f"""
|
|
|
|
| 436 |
|
| 437 |
with gr.Column():
|
| 438 |
quantize_button = gr.Button("π Quantize and Push to the Hub", variant="primary")
|
| 439 |
+
output_link = gr.Markdown("π Quantized Model", container=True, min_height=100)
|
| 440 |
+
|
| 441 |
quantize_button.click(
|
| 442 |
fn=quantize_and_save,
|
| 443 |
inputs=[model_name, quant_type_4, double_quant_4, compute_type_4, quant_storage_4, quantized_model_name, public],
|