From b8fccb2559ea0d5a220724ce1e243d1a9057282f Mon Sep 17 00:00:00 2001 From: leafspark <78000825+leafspark@users.noreply.github.com> Date: Fri, 2 Aug 2024 21:27:05 -0700 Subject: [PATCH] hotfix for AutoGGUF --- README.md | 21 ++++++++------------- src/AutoGGUF.py | 17 ++++++++--------- src/modify.py | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 22 deletions(-) create mode 100644 src/modify.py diff --git a/README.md b/README.md index bafe4c7..f4cc714 100644 --- a/README.md +++ b/README.md @@ -1,29 +1,24 @@ -# AutoGGUF - automated GGUF model quantizer +AutoGGUF - Automated GGUF Model Quantizer This application provides a graphical user interface for quantizing GGUF models using the llama.cpp library. It allows users to download different versions of llama.cpp, manage multiple backends, and perform quantization tasks with various options. -**Main features**: +Main features: 1. Download and manage llama.cpp backends 2. Select and quantize GGUF models 3. Configure quantization parameters 4. Monitor system resources during quantization -**Usage**: -1. Install dependencies, either using the `requirements.txt` file or `pip install PyQt6 requests psutil`. -2. Run the `run.bat` script to start the application, or run the command `python src/main.py`. +Usage: +Run the main.py script to start the application. -**Dependencies**: +Dependencies: - PyQt6 - requests - psutil -**To be implemented:** -- Actual progress bar tracking -- Download safetensors from HF and convert to unquanted GGUF -- Specify multiple KV overrides - -**User interface:** -![image](https://github.com/user-attachments/assets/b1b58cba-4314-479d-a1d8-21ca0b5a8935) +Author: leafspark +Version: 1.0.0 +License: apache-2.0 \ No newline at end of file diff --git a/src/AutoGGUF.py b/src/AutoGGUF.py index b01674d..d334eca 100644 --- a/src/AutoGGUF.py +++ b/src/AutoGGUF.py @@ -13,6 +13,10 @@ import zipfile from datetime import datetime from imports_and_globals import ensure_directory +from DownloadThread import * +from ModelInfoDialog import * +from TaskListItem import * +from QuantizationThread import * class AutoGGUF(QMainWindow): def __init__(self): @@ -387,12 +391,7 @@ def load_models(self): if file.endswith(".gguf"): self.model_list.addItem(file) - def browse_backend(self): - backend_path = QFileDialog.getExistingDirectory(self, "Select Llama.cpp Backend Directory") - if backend_path: - self.backend_input.setText(os.path.abspath(backend_path)) - ensure_directory(backend_path) - + def browse_models(self): models_path = QFileDialog.getExistingDirectory(self, "Select Models Directory") if models_path: @@ -431,8 +430,8 @@ def toggle_token_embedding_type(self, state): self.token_embedding_type.setEnabled(state == Qt.CheckState.Checked) def validate_quantization_inputs(self): - if not self.backend_input.text(): - raise ValueError("Backend path is required") + if not self.backend_combo.currentData(): + raise ValueError("No backend selected") if not self.models_input.text(): raise ValueError("Models path is required") if not self.output_input.text(): @@ -571,7 +570,7 @@ def toggle_gpu_offload_auto(self, state): def generate_imatrix(self): try: - backend_path = self.backend_input.text() + backend_path = self.backend_combo.currentData() if not os.path.exists(backend_path): raise FileNotFoundError(f"Backend path does not exist: {backend_path}") diff --git a/src/modify.py b/src/modify.py new file mode 100644 index 0000000..e507dbf --- /dev/null +++ b/src/modify.py @@ -0,0 +1,35 @@ +import re + +def modify_file(filename): + with open(filename, 'r') as file: + content = file.read() + + # Replace validate_quantization_inputs method + content = re.sub( + r'def validate_quantization_inputs\(self\):.*?if not self\.backend_input\.text\(\):.*?raise ValueError\("Backend path is required"\)', + 'def validate_quantization_inputs(self):\n if not self.backend_combo.currentData():\n raise ValueError("No backend selected")', + content, flags=re.DOTALL + ) + + # Replace in generate_imatrix method + content = re.sub( + r'backend_path = self\.backend_input\.text\(\)', + 'backend_path = self.backend_combo.currentData()', + content + ) + + # Remove browse_backend method + content = re.sub( + r'def browse_backend\(self\):.*?ensure_directory\(backend_path\)\n', + '', + content, flags=re.DOTALL + ) + + # Write the modified content back to the file + with open(filename, 'w') as file: + file.write(content) + + print(f"File {filename} has been modified.") + +# Use the function +modify_file('AutoGGUF.py')