Try to not break portable builds

This commit is contained in:
oobabooga 2025-12-01 17:13:16 -08:00
parent 5fb1380ac1
commit 225b8c326b
3 changed files with 7 additions and 5 deletions

View file

@ -1,7 +1,5 @@
import time
import torch
import modules.shared as shared
from modules.logging_colors import logger
from modules.torch_utils import get_device
@ -18,8 +16,9 @@ def get_quantization_config(quant_method):
Returns:
PipelineQuantizationConfig or None
"""
from diffusers.quantizers import PipelineQuantizationConfig
import torch
from diffusers import BitsAndBytesConfig, QuantoConfig
from diffusers.quantizers import PipelineQuantizationConfig
if quant_method == 'none' or not quant_method:
return None
@ -88,6 +87,7 @@ def load_image_model(model_name, dtype='bfloat16', attn_backend='sdpa', cpu_offl
compile_model: Compile the model for faster inference (slow first run)
quant_method: Quantization method - 'none', 'bnb-8bit', 'bnb-4bit', 'quanto-8bit', 'quanto-4bit', 'quanto-2bit'
"""
import torch
from diffusers import ZImagePipeline
logger.info(f"Loading image model \"{model_name}\" with quantization: {quant_method}")

View file

@ -7,7 +7,6 @@ from pathlib import Path
import gradio as gr
import numpy as np
import torch
from PIL import Image
from PIL.PngImagePlugin import PngInfo
@ -605,6 +604,8 @@ def create_event_handlers():
def generate(state):
import torch
model_name = state['image_model_menu']
if not model_name or model_name == 'None':

View file

@ -172,7 +172,8 @@ def create_interface():
ui_chat.create_event_handlers()
ui_default.create_event_handlers()
ui_notebook.create_event_handlers()
ui_image_generation.create_event_handlers()
if not shared.args.portable:
ui_image_generation.create_event_handlers()
# Other events
ui_file_saving.create_event_handlers()