Skip to content

Commit

Permalink
virtual environment 1.09
Browse files Browse the repository at this point in the history
  • Loading branch information
rainlizard committed Jan 2, 2025
1 parent 5493eb6 commit a5aac6c
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
venv/
*.zip
12 changes: 11 additions & 1 deletion CreateZip.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Read VERSION from Python file
$versionLine = Get-Content "EasyQuantizationGUI.py" | Select-String "VERSION = "
if ($versionLine -match 'VERSION = "(.*?)"') {
$version = $matches[1]
Write-Host "Found version: $version"
} else {
Write-Host "WARNING: Version not found, using 'unknown'"
$version = "unknown"
}

# Define the zip file name and subdirectory name
$zipName = "EasyQuantizationGUI.zip"
$zipName = "EasyQuantizationGUI_v$version.zip"
$subDirName = "EasyQuantizationGUI"

# Get the current directory
Expand Down
31 changes: 30 additions & 1 deletion EasyQuantizationGUI.bat
Original file line number Diff line number Diff line change
@@ -1 +1,30 @@
python EasyQuantizationGUI.py
@echo off
REM Check if pip is installed and show output only if it needs to be installed
python -m pip --version >nul 2>&1
if %ERRORLEVEL% neq 0 (
echo Installing pip...
python -m ensurepip --default-pip
) else (
python -m pip install --upgrade pip >nul 2>&1
)

REM Check if virtual environment exists, create if it doesn't
if not exist "venv" (
echo Creating virtual environment...
python -m venv venv
call venv\Scripts\activate
echo Installing requirements...
pip install -r requirements.txt
echo Setup complete!
echo.
) else (
call venv\Scripts\activate
)

REM Run the application
python EasyQuantizationGUI.py

REM Keep the window open if there's an error
if %ERRORLEVEL% neq 0 (
pause
)
9 changes: 7 additions & 2 deletions EasyQuantizationGUI.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
VERSION = "1.09"

import sys
import subprocess
import importlib
Expand Down Expand Up @@ -142,7 +144,10 @@ def run_llama_quantize():
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
startupinfo.wShowWindow = subprocess.SW_HIDE

process = subprocess.Popen(["python", convert_py_path, "--src", input_file, "--dst", temp_gguf_file],
# Get the Python executable path from the current environment
pythonpath = sys.executable

process = subprocess.Popen([pythonpath, convert_py_path, "--src", input_file, "--dst", temp_gguf_file],
stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True,
bufsize=1, universal_newlines=True, startupinfo=startupinfo)

Expand Down Expand Up @@ -214,7 +219,7 @@ def main():
global root, process_text, input_entry, output_entry, quantize_dropdown, run_button, quantize_level_var
global input_browse, output_browse # Add these two variables
root = tk.Tk()
root.title("Easy Quantization GUI")
root.title(f"Easy Quantization GUI v{VERSION}")
root.geometry("800x600")

# Quantize level selection
Expand Down
35 changes: 29 additions & 6 deletions convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,24 @@ class ModelSD3(ModelTemplate):
]
keys_banned = ["transformer_blocks.0.attn.add_q_proj.weight",]

class ModelAura(ModelTemplate):
arch = "aura"
keys_detect = [
("double_layers.3.modX.1.weight",),
("joint_transformer_blocks.3.ff_context.out_projection.weight",),
]
keys_banned = ["joint_transformer_blocks.3.ff_context.out_projection.weight",]

class ModelLTXV(ModelTemplate):
arch = "ltxv"
keys_detect = [
(
"adaln_single.emb.timestep_embedder.linear_2.weight",
"transformer_blocks.27.scale_shift_table",
"caption_projection.linear_2.weight",
)
]

class ModelSDXL(ModelTemplate):
arch = "sdxl"
shape_fix = True
Expand All @@ -47,7 +65,7 @@ class ModelSDXL(ModelTemplate):

class ModelSD1(ModelTemplate):
arch = "sd1"
shape_fix = False
shape_fix = True
keys_detect = [
("down_blocks.0.downsamplers.0.conv.weight",),
(
Expand All @@ -57,7 +75,7 @@ class ModelSD1(ModelTemplate):
]

# The architectures are checked in order and the first successful match terminates the search.
arch_list = [ModelFlux, ModelSD3, ModelSDXL, ModelSD1]
arch_list = [ModelFlux, ModelSD3, ModelAura, ModelLTXV, ModelSDXL, ModelSD1]

def is_model_arch(model, state_dict):
# check if model is correct
Expand Down Expand Up @@ -99,13 +117,18 @@ def load_state_dict(path):
state_dict = load_file(path)

# only keep unet with no prefix!
prefix = None
for pfx in ["model.diffusion_model.", "model."]:
if any([x.startswith(pfx) for x in state_dict.keys()]):
prefix = pfx
break

sd = {}
has_prefix = any(["model.diffusion_model." in x for x in state_dict.keys()])
for k, v in state_dict.items():
if has_prefix and "model.diffusion_model." not in k:
if prefix and prefix not in k:
continue
if has_prefix:
k = k.replace("model.diffusion_model.", "")
if prefix:
k = k.replace(prefix, "")
sd[k] = v

return sd
Expand Down
Binary file modified ggml.dll
Binary file not shown.
Binary file modified llama-quantize.exe
Binary file not shown.
Binary file modified llama.dll
Binary file not shown.

0 comments on commit a5aac6c

Please sign in to comment.