Spaces:
Running
Running
Fix Gradio Demo (#162)
Browse files- Fix Gradio Demo (184e387a0ce3ad7a4bbcead8cdb1094126f3cc63)
Co-authored-by: Freddy Boulton <[email protected]>
app.py
CHANGED
|
@@ -324,82 +324,68 @@ def process_model(model_id, q_method, use_imatrix, imatrix_q_method, private_rep
|
|
| 324 |
css="""/* Custom CSS to allow scrolling */
|
| 325 |
.gradio-container {overflow-y: auto;}
|
| 326 |
"""
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
info="Maximum file size when splitting model (--split-max-size). May leave empty to use the default. Accepted suffixes: M, G. Example: 256M, 5G",
|
| 390 |
-
visible=False
|
| 391 |
-
)
|
| 392 |
-
|
| 393 |
-
def update_visibility(use_imatrix):
|
| 394 |
-
return gr.update(visible=not use_imatrix), gr.update(visible=use_imatrix), gr.update(visible=use_imatrix)
|
| 395 |
-
|
| 396 |
-
use_imatrix.change(
|
| 397 |
-
fn=update_visibility,
|
| 398 |
-
inputs=use_imatrix,
|
| 399 |
-
outputs=[q_method, imatrix_q_method, train_data_file]
|
| 400 |
-
)
|
| 401 |
-
|
| 402 |
-
iface = gr.Interface(
|
| 403 |
fn=process_model,
|
| 404 |
inputs=[
|
| 405 |
model_id,
|
|
@@ -421,6 +407,13 @@ with gr.Blocks(css=css) as demo:
|
|
| 421 |
api_name=False
|
| 422 |
)
|
| 423 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 424 |
def update_split_visibility(split_model):
|
| 425 |
return gr.update(visible=split_model), gr.update(visible=split_model)
|
| 426 |
|
|
@@ -430,6 +423,15 @@ with gr.Blocks(css=css) as demo:
|
|
| 430 |
outputs=[split_max_tensors, split_max_size]
|
| 431 |
)
|
| 432 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 433 |
def restart_space():
|
| 434 |
HfApi().restart_space(repo_id="ggml-org/gguf-my-repo", token=HF_TOKEN, factory_reboot=True)
|
| 435 |
|
|
|
|
| 324 |
css="""/* Custom CSS to allow scrolling */
|
| 325 |
.gradio-container {overflow-y: auto;}
|
| 326 |
"""
|
| 327 |
+
model_id = HuggingfaceHubSearch(
|
| 328 |
+
label="Hub Model ID",
|
| 329 |
+
placeholder="Search for model id on Huggingface",
|
| 330 |
+
search_type="model",
|
| 331 |
+
)
|
| 332 |
+
|
| 333 |
+
q_method = gr.Dropdown(
|
| 334 |
+
["Q2_K", "Q3_K_S", "Q3_K_M", "Q3_K_L", "Q4_0", "Q4_K_S", "Q4_K_M", "Q5_0", "Q5_K_S", "Q5_K_M", "Q6_K", "Q8_0"],
|
| 335 |
+
label="Quantization Method",
|
| 336 |
+
info="GGML quantization type",
|
| 337 |
+
value="Q4_K_M",
|
| 338 |
+
filterable=False,
|
| 339 |
+
visible=True
|
| 340 |
+
)
|
| 341 |
+
|
| 342 |
+
imatrix_q_method = gr.Dropdown(
|
| 343 |
+
["IQ3_M", "IQ3_XXS", "Q4_K_M", "Q4_K_S", "IQ4_NL", "IQ4_XS", "Q5_K_M", "Q5_K_S"],
|
| 344 |
+
label="Imatrix Quantization Method",
|
| 345 |
+
info="GGML imatrix quants type",
|
| 346 |
+
value="IQ4_NL",
|
| 347 |
+
filterable=False,
|
| 348 |
+
visible=False
|
| 349 |
+
)
|
| 350 |
+
|
| 351 |
+
use_imatrix = gr.Checkbox(
|
| 352 |
+
value=False,
|
| 353 |
+
label="Use Imatrix Quantization",
|
| 354 |
+
info="Use importance matrix for quantization."
|
| 355 |
+
)
|
| 356 |
+
|
| 357 |
+
private_repo = gr.Checkbox(
|
| 358 |
+
value=False,
|
| 359 |
+
label="Private Repo",
|
| 360 |
+
info="Create a private repo under your username."
|
| 361 |
+
)
|
| 362 |
+
|
| 363 |
+
train_data_file = gr.File(
|
| 364 |
+
label="Training Data File",
|
| 365 |
+
file_types=["txt"],
|
| 366 |
+
visible=False
|
| 367 |
+
)
|
| 368 |
+
|
| 369 |
+
split_model = gr.Checkbox(
|
| 370 |
+
value=False,
|
| 371 |
+
label="Split Model",
|
| 372 |
+
info="Shard the model using gguf-split."
|
| 373 |
+
)
|
| 374 |
+
|
| 375 |
+
split_max_tensors = gr.Number(
|
| 376 |
+
value=256,
|
| 377 |
+
label="Max Tensors per File",
|
| 378 |
+
info="Maximum number of tensors per file when splitting model.",
|
| 379 |
+
visible=False
|
| 380 |
+
)
|
| 381 |
+
|
| 382 |
+
split_max_size = gr.Textbox(
|
| 383 |
+
label="Max File Size",
|
| 384 |
+
info="Maximum file size when splitting model (--split-max-size). May leave empty to use the default. Accepted suffixes: M, G. Example: 256M, 5G",
|
| 385 |
+
visible=False
|
| 386 |
+
)
|
| 387 |
+
|
| 388 |
+
iface = gr.Interface(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 389 |
fn=process_model,
|
| 390 |
inputs=[
|
| 391 |
model_id,
|
|
|
|
| 407 |
api_name=False
|
| 408 |
)
|
| 409 |
|
| 410 |
+
# Create Gradio interface
|
| 411 |
+
with gr.Blocks(css=css) as demo:
|
| 412 |
+
gr.Markdown("You must be logged in to use GGUF-my-repo.")
|
| 413 |
+
gr.LoginButton(min_width=250)
|
| 414 |
+
|
| 415 |
+
iface.render()
|
| 416 |
+
|
| 417 |
def update_split_visibility(split_model):
|
| 418 |
return gr.update(visible=split_model), gr.update(visible=split_model)
|
| 419 |
|
|
|
|
| 423 |
outputs=[split_max_tensors, split_max_size]
|
| 424 |
)
|
| 425 |
|
| 426 |
+
def update_visibility(use_imatrix):
|
| 427 |
+
return gr.update(visible=not use_imatrix), gr.update(visible=use_imatrix), gr.update(visible=use_imatrix)
|
| 428 |
+
|
| 429 |
+
use_imatrix.change(
|
| 430 |
+
fn=update_visibility,
|
| 431 |
+
inputs=use_imatrix,
|
| 432 |
+
outputs=[q_method, imatrix_q_method, train_data_file]
|
| 433 |
+
)
|
| 434 |
+
|
| 435 |
def restart_space():
|
| 436 |
HfApi().restart_space(repo_id="ggml-org/gguf-my-repo", token=HF_TOKEN, factory_reboot=True)
|
| 437 |
|