Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -11,6 +11,7 @@ from gradio_huggingfacehub_search import HuggingfaceHubSearch
|
|
11 |
from apscheduler.schedulers.background import BackgroundScheduler
|
12 |
from datetime import datetime
|
13 |
import numpy as np
|
|
|
14 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
15 |
|
16 |
os.environ["GRADIO_ANALYTICS_ENABLED"] = "False"
|
@@ -60,16 +61,22 @@ Run them directly with [llama.cpp](https://github.com/ggml-org/llama.cpp), or an
|
|
60 |
First, make sure you have hugginface-cli installed:
|
61 |
```
|
62 |
pip install -U "huggingface_hub[cli]"
|
|
|
63 |
```
|
64 |
Then, you can target the specific file you want:
|
|
|
65 |
```
|
66 |
huggingface-cli download {new_repo_url} --include "{gguf_files[0][0]}" --local-dir ./
|
|
|
67 |
```
|
68 |
If the model is bigger than 50GB, it will have been split into multiple files. In order to download them all to a local folder, run:
|
|
|
69 |
```
|
70 |
huggingface-cli download {new_repo_url} --include "{gguf_files[0][0]}/*" --local-dir ./
|
|
|
71 |
```
|
72 |
You can either specify a new local-dir (deepseek-ai_DeepSeek-V3-0324-Q8_0) or download them all in place (./)
|
|
|
73 |
</details>
|
74 |
"""
|
75 |
return text
|
@@ -229,7 +236,8 @@ def process_model(model_id, q_method, use_imatrix, imatrix_q_method, private_rep
|
|
229 |
fp16 = str(Path(outdir)/f"{model_name}.fp16.gguf")
|
230 |
|
231 |
with tempfile.TemporaryDirectory(dir=downloads_dir) as tmpdir:
|
232 |
-
print("
|
|
|
233 |
local_dir = Path(tmpdir)/model_name
|
234 |
api.snapshot_download(repo_id=model_id, local_dir=local_dir, local_dir_use_symlinks=False, allow_patterns=dl_pattern)
|
235 |
|
@@ -237,12 +245,16 @@ def process_model(model_id, q_method, use_imatrix, imatrix_q_method, private_rep
|
|
237 |
adapter_config_dir = local_dir/"adapter_config.json"
|
238 |
if os.path.exists(adapter_config_dir) and not os.path.exists(config_dir):
|
239 |
raise Exception("adapter_config.json is present. If converting LoRA, use GGUF-my-lora.")
|
|
|
|
|
240 |
|
241 |
-
print("Download successfully")
|
242 |
result = subprocess.run(["python", CONVERSION_SCRIPT, local_dir, "--outtype", "f16", "--outfile", fp16], shell=False, capture_output=True)
|
243 |
-
print("Converted to f16")
|
|
|
|
|
244 |
if result.returncode != 0:
|
245 |
raise Exception(f"Error converting to fp16: {result.stderr.decode()}")
|
|
|
246 |
|
247 |
imatrix_path = Path(outdir)/"imatrix.dat"
|
248 |
if use_imatrix:
|
@@ -256,7 +268,9 @@ def process_model(model_id, q_method, use_imatrix, imatrix_q_method, private_rep
|
|
256 |
|
257 |
gguf_files = []
|
258 |
for method in quant_methods:
|
259 |
-
print("Begin quantize")
|
|
|
|
|
260 |
name = f"{model_name.lower()}-{method.lower()}-{suffix}.gguf" if suffix else f"{model_name.lower()}-{method.lower()}.gguf"
|
261 |
path = str(Path(outdir)/name)
|
262 |
quant_cmd = ["./llama.cpp/llama-quantize", "--imatrix", imatrix_path, fp16, path, method] if use_imatrix else ["./llama.cpp/llama-quantize", fp16, path, method]
|
@@ -266,7 +280,9 @@ def process_model(model_id, q_method, use_imatrix, imatrix_q_method, private_rep
|
|
266 |
size = os.path.getsize(path)/1024/1024/1024
|
267 |
gguf_files.append((name, path, size, method))
|
268 |
|
269 |
-
print("Quantize successfully!")
|
|
|
|
|
270 |
suffix_for_repo = f"{imatrix_q_method}-imat" if use_imatrix else "-".join(quant_methods)
|
271 |
repo_id = f"{repo_namespace}/{model_name}-GGUF"
|
272 |
new_repo_url = api.create_repo(repo_id=repo_id, exist_ok=True, private=private_repo)
|
|
|
11 |
from apscheduler.schedulers.background import BackgroundScheduler
|
12 |
from datetime import datetime
|
13 |
import numpy as np
|
14 |
+
import shutil
|
15 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
16 |
|
17 |
os.environ["GRADIO_ANALYTICS_ENABLED"] = "False"
|
|
|
61 |
First, make sure you have hugginface-cli installed:
|
62 |
```
|
63 |
pip install -U "huggingface_hub[cli]"
|
64 |
+
|
65 |
```
|
66 |
Then, you can target the specific file you want:
|
67 |
+
|
68 |
```
|
69 |
huggingface-cli download {new_repo_url} --include "{gguf_files[0][0]}" --local-dir ./
|
70 |
+
|
71 |
```
|
72 |
If the model is bigger than 50GB, it will have been split into multiple files. In order to download them all to a local folder, run:
|
73 |
+
|
74 |
```
|
75 |
huggingface-cli download {new_repo_url} --include "{gguf_files[0][0]}/*" --local-dir ./
|
76 |
+
|
77 |
```
|
78 |
You can either specify a new local-dir (deepseek-ai_DeepSeek-V3-0324-Q8_0) or download them all in place (./)
|
79 |
+
|
80 |
</details>
|
81 |
"""
|
82 |
return text
|
|
|
236 |
fp16 = str(Path(outdir)/f"{model_name}.fp16.gguf")
|
237 |
|
238 |
with tempfile.TemporaryDirectory(dir=downloads_dir) as tmpdir:
|
239 |
+
print(datetime.now().strftime("%Y-%m-%d %H:%M:%S") + " Start download")
|
240 |
+
logger.info(datetime.now().strftime("%Y-%m-%d %H:%M:%S") + " Start download")
|
241 |
local_dir = Path(tmpdir)/model_name
|
242 |
api.snapshot_download(repo_id=model_id, local_dir=local_dir, local_dir_use_symlinks=False, allow_patterns=dl_pattern)
|
243 |
|
|
|
245 |
adapter_config_dir = local_dir/"adapter_config.json"
|
246 |
if os.path.exists(adapter_config_dir) and not os.path.exists(config_dir):
|
247 |
raise Exception("adapter_config.json is present. If converting LoRA, use GGUF-my-lora.")
|
248 |
+
print(datetime.now().strftime("%Y-%m-%d %H:%M:%S") + " Download successfully")
|
249 |
+
logger.info(datetime.now().strftime("%Y-%m-%d %H:%M:%S") + " Download successfully")
|
250 |
|
|
|
251 |
result = subprocess.run(["python", CONVERSION_SCRIPT, local_dir, "--outtype", "f16", "--outfile", fp16], shell=False, capture_output=True)
|
252 |
+
print(datetime.now().strftime("%Y-%m-%d %H:%M:%S") + " Converted to f16")
|
253 |
+
logger.info(datetime.now().strftime("%Y-%m-%d %H:%M:%S") + " Converted to f16")
|
254 |
+
|
255 |
if result.returncode != 0:
|
256 |
raise Exception(f"Error converting to fp16: {result.stderr.decode()}")
|
257 |
+
shutil.rmtree(downloads_dir)
|
258 |
|
259 |
imatrix_path = Path(outdir)/"imatrix.dat"
|
260 |
if use_imatrix:
|
|
|
268 |
|
269 |
gguf_files = []
|
270 |
for method in quant_methods:
|
271 |
+
print(datetime.now().strftime("%Y-%m-%d %H:%M:%S") + " Begin quantize")
|
272 |
+
logger.info(datetime.now().strftime("%Y-%m-%d %H:%M:%S") + " Begin quantize")
|
273 |
+
|
274 |
name = f"{model_name.lower()}-{method.lower()}-{suffix}.gguf" if suffix else f"{model_name.lower()}-{method.lower()}.gguf"
|
275 |
path = str(Path(outdir)/name)
|
276 |
quant_cmd = ["./llama.cpp/llama-quantize", "--imatrix", imatrix_path, fp16, path, method] if use_imatrix else ["./llama.cpp/llama-quantize", fp16, path, method]
|
|
|
280 |
size = os.path.getsize(path)/1024/1024/1024
|
281 |
gguf_files.append((name, path, size, method))
|
282 |
|
283 |
+
print(datetime.now().strftime("%Y-%m-%d %H:%M:%S") + " Quantize successfully!")
|
284 |
+
logger.info(datetime.now().strftime("%Y-%m-%d %H:%M:%S") + " Quantize successfully!")
|
285 |
+
|
286 |
suffix_for_repo = f"{imatrix_q_method}-imat" if use_imatrix else "-".join(quant_methods)
|
287 |
repo_id = f"{repo_namespace}/{model_name}-GGUF"
|
288 |
new_repo_url = api.create_repo(repo_id=repo_id, exist_ok=True, private=private_repo)
|