From c6ae2e319c1c6fd0fb43b0784deef65e18924cb5 Mon Sep 17 00:00:00 2001 From: leafspark <78000825+leafspark@users.noreply.github.com> Date: Fri, 2 Aug 2024 21:55:57 -0700 Subject: [PATCH] Add files via upload --- README.md | 21 ++++++++------------- run.bat | 1 + src/AutoGGUF.py | 2 +- src/QuantizationThread.py | 5 +++-- src/imports_and_globals.py | 11 ++++++++++- 5 files changed, 23 insertions(+), 17 deletions(-) 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/run.bat b/run.bat index da50243..5ad473c 100644 --- a/run.bat +++ b/run.bat @@ -1,2 +1,3 @@ @echo off +set PYTHONIOENCODING=utf-8 python src/main.py \ No newline at end of file diff --git a/src/AutoGGUF.py b/src/AutoGGUF.py index d334eca..ecd460d 100644 --- a/src/AutoGGUF.py +++ b/src/AutoGGUF.py @@ -531,7 +531,7 @@ def show_task_details(self, item): # Load existing content if os.path.exists(task_item.log_file): - with open(task_item.log_file, 'r') as f: + with open_file_safe(task_item.log_file, 'r') as f: log_text.setPlainText(f.read()) # Connect to the thread if it's still running diff --git a/src/QuantizationThread.py b/src/QuantizationThread.py index 13fabd0..5c2d5df 100644 --- a/src/QuantizationThread.py +++ b/src/QuantizationThread.py @@ -11,7 +11,9 @@ import platform import requests import zipfile +import traceback from datetime import datetime +from imports_and_globals import open_file_safe class QuantizationThread(QThread): output_signal = pyqtSignal(str) @@ -32,7 +34,7 @@ def run(self): try: self.process = subprocess.Popen(self.command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, cwd=self.cwd) - with open(self.log_file, 'w') as log: + with open_file_safe(self.log_file, 'w') as log: for line in self.process.stdout: line = line.strip() self.output_signal.emit(line) @@ -40,7 +42,6 @@ def run(self): log.flush() self.status_signal.emit("In Progress") self.parse_model_info(line) - self.process.wait() if self.process.returncode == 0: self.status_signal.emit("Completed") diff --git a/src/imports_and_globals.py b/src/imports_and_globals.py index 92293b8..d54328e 100644 --- a/src/imports_and_globals.py +++ b/src/imports_and_globals.py @@ -18,4 +18,13 @@ def ensure_directory(path): if not os.path.exists(path): - os.makedirs(path) \ No newline at end of file + os.makedirs(path) + +def open_file_safe(file_path, mode='r'): + encodings = ['utf-8', 'latin-1', 'ascii', 'utf-16'] + for encoding in encodings: + try: + return open(file_path, mode, encoding=encoding) + except UnicodeDecodeError: + continue + raise ValueError(f"Unable to open file {file_path} with any of the encodings: {encodings}") \ No newline at end of file