reach-vb HF staff commited on
Commit
7edda8b
1 Parent(s): 17d8fa0

Update app.py (#2)

Browse files
Files changed (1) hide show
  1. app.py +29 -8
app.py CHANGED
@@ -1,6 +1,8 @@
1
- import gradio as gr
2
  import subprocess
3
 
 
 
4
  from huggingface_hub import create_repo, HfApi
5
  from huggingface_hub import snapshot_download
6
 
@@ -24,7 +26,7 @@ def process_model(model_id, q_method, username, hf_token):
24
  print("Quantised successfully!")
25
 
26
  # Create empty repo
27
- create_repo(
28
  repo_id = f"{username}/{MODEL_NAME}-{q_method}-GGUF",
29
  repo_type="model",
30
  exist_ok=True,
@@ -36,21 +38,40 @@ def process_model(model_id, q_method, username, hf_token):
36
  api.upload_folder(
37
  folder_path=MODEL_NAME,
38
  repo_id=f"{username}/{MODEL_NAME}-{q_method}-GGUF",
39
- allow_patterns=["*.gguf","$.md"],
40
  token=hf_token
41
  )
42
  print("Uploaded successfully!")
43
 
44
- return "Processing complete."
 
 
 
45
 
46
  # Create Gradio interface
47
  iface = gr.Interface(
48
  fn=process_model,
49
  inputs=[
50
- gr.Textbox(lines=1, label="Model ID"),
51
- gr.Textbox(lines=1, label="Quantization Methods"),
52
- gr.Textbox(lines=1, label="Username"),
53
- gr.Textbox(lines=1, label="Token")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  ],
55
  outputs="text"
56
  )
 
1
+ import shutil
2
  import subprocess
3
 
4
+ import gradio as gr
5
+
6
  from huggingface_hub import create_repo, HfApi
7
  from huggingface_hub import snapshot_download
8
 
 
26
  print("Quantised successfully!")
27
 
28
  # Create empty repo
29
+ repo_url = create_repo(
30
  repo_id = f"{username}/{MODEL_NAME}-{q_method}-GGUF",
31
  repo_type="model",
32
  exist_ok=True,
 
38
  api.upload_folder(
39
  folder_path=MODEL_NAME,
40
  repo_id=f"{username}/{MODEL_NAME}-{q_method}-GGUF",
41
+ allow_patterns=["*.gguf","*.md"],
42
  token=hf_token
43
  )
44
  print("Uploaded successfully!")
45
 
46
+ shutil.rmtree(MODEL_NAME)
47
+ print("Folder cleaned up successfully!")
48
+
49
+ return f"Processing complete: {repo_url}"
50
 
51
  # Create Gradio interface
52
  iface = gr.Interface(
53
  fn=process_model,
54
  inputs=[
55
+ gr.Textbox(
56
+ lines=1,
57
+ label="Hub Model ID",
58
+ info="Model repo ID"
59
+ ),
60
+ gr.Dropdown(
61
+ ["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"],
62
+ label="Quantization Method",
63
+ info="GGML quantisation type"
64
+ ),
65
+ gr.Textbox(
66
+ lines=1,
67
+ label="Username",
68
+ info="Your Hugging Face username"
69
+ ),
70
+ gr.Textbox(
71
+ lines=1,
72
+ label="HF Write Token",
73
+ info="https://hf.co/settings/token"
74
+ )
75
  ],
76
  outputs="text"
77
  )