Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,10 +5,6 @@ from huggingface_hub import snapshot_download
|
|
| 5 |
|
| 6 |
import subprocess
|
| 7 |
|
| 8 |
-
# Recompile llama.cpp before running
|
| 9 |
-
subprocess.run(["make", "clean"], cwd="/home/user/app/llama.cpp", check=True)
|
| 10 |
-
subprocess.run(["make"], cwd="/home/user/app/llama.cpp", check=True)
|
| 11 |
-
|
| 12 |
def check_directory_path(directory_name: str) -> str:
|
| 13 |
if os.path.exists(directory_name):
|
| 14 |
path = os.path.abspath(directory_name)
|
|
@@ -39,7 +35,7 @@ def convert_to_gguf(model_dir, output_file):
|
|
| 39 |
os.makedirs(os.path.dirname(output_file), exist_ok=True)
|
| 40 |
st.write(model_dir_path)
|
| 41 |
cmd = [
|
| 42 |
-
"python3",
|
| 43 |
"--outtype", "f16", "--outfile", output_file
|
| 44 |
]
|
| 45 |
process = subprocess.run(cmd, text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
@@ -54,11 +50,11 @@ def quantize_llama(model_path, quantized_output_path, quant_type):
|
|
| 54 |
"""
|
| 55 |
st.write(f"⚡ Quantizing `{model_path}` with `{quant_type}` precision...")
|
| 56 |
os.makedirs(os.path.dirname(quantized_output_path), exist_ok=True)
|
| 57 |
-
quantize_path =
|
| 58 |
subprocess.run(["chmod", "+x", quantize_path], check=True)
|
| 59 |
|
| 60 |
cmd = [
|
| 61 |
-
|
| 62 |
model_path,
|
| 63 |
quantized_output_path,
|
| 64 |
quant_type
|
|
|
|
| 5 |
|
| 6 |
import subprocess
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
def check_directory_path(directory_name: str) -> str:
|
| 9 |
if os.path.exists(directory_name):
|
| 10 |
path = os.path.abspath(directory_name)
|
|
|
|
| 35 |
os.makedirs(os.path.dirname(output_file), exist_ok=True)
|
| 36 |
st.write(model_dir_path)
|
| 37 |
cmd = [
|
| 38 |
+
"python3", "/app/llama.cpp/convert_hf_to_gguf.py", model_dir,
|
| 39 |
"--outtype", "f16", "--outfile", output_file
|
| 40 |
]
|
| 41 |
process = subprocess.run(cmd, text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
|
|
| 50 |
"""
|
| 51 |
st.write(f"⚡ Quantizing `{model_path}` with `{quant_type}` precision...")
|
| 52 |
os.makedirs(os.path.dirname(quantized_output_path), exist_ok=True)
|
| 53 |
+
quantize_path = "/app/llama.cpp/build/bin/llama-quantize"
|
| 54 |
subprocess.run(["chmod", "+x", quantize_path], check=True)
|
| 55 |
|
| 56 |
cmd = [
|
| 57 |
+
"/app/llama.cpp/build/bin/llama-quantize",
|
| 58 |
model_path,
|
| 59 |
quantized_output_path,
|
| 60 |
quant_type
|