Make portable builds functional again after b3666e140d

This commit is contained in:
oobabooga 2025-12-02 10:06:57 -08:00
parent 6291e72129
commit 9d07d3a229
3 changed files with 44 additions and 39 deletions

View file

@ -2,7 +2,6 @@ import time
import modules.shared as shared
from modules.logging_colors import logger
from modules.torch_utils import get_device
from modules.utils import resolve_model_path
@ -82,6 +81,8 @@ def load_image_model(model_name, dtype='bfloat16', attn_backend='sdpa', cpu_offl
import torch
from diffusers import DiffusionPipeline
from modules.torch_utils import get_device
logger.info(f"Loading image model \"{model_name}\" with quantization: {quant_method}")
t0 = time.time()

View file

@ -280,25 +280,26 @@ def list_interface_input_elements():
'include_past_attachments',
]
# Image generation elements
elements += [
'image_prompt',
'image_neg_prompt',
'image_width',
'image_height',
'image_aspect_ratio',
'image_steps',
'image_cfg_scale',
'image_seed',
'image_batch_size',
'image_batch_count',
'image_model_menu',
'image_dtype',
'image_attn_backend',
'image_compile',
'image_cpu_offload',
'image_quant',
]
if not shared.args.portable:
# Image generation elements
elements += [
'image_prompt',
'image_neg_prompt',
'image_width',
'image_height',
'image_aspect_ratio',
'image_steps',
'image_cfg_scale',
'image_seed',
'image_batch_size',
'image_batch_count',
'image_model_menu',
'image_dtype',
'image_attn_backend',
'image_compile',
'image_cpu_offload',
'image_quant',
]
return elements
@ -531,25 +532,29 @@ def setup_auto_save():
'paste_to_attachment',
'include_past_attachments',
# Image generation tab (ui_image_generation.py)
'image_prompt',
'image_neg_prompt',
'image_width',
'image_height',
'image_aspect_ratio',
'image_steps',
'image_cfg_scale',
'image_seed',
'image_batch_size',
'image_batch_count',
'image_model_menu',
'image_dtype',
'image_attn_backend',
'image_compile',
'image_cpu_offload',
'image_quant',
]
if not shared.args.portable:
# Image generation tab (ui_image_generation.py)
change_elements += [
'image_prompt',
'image_neg_prompt',
'image_width',
'image_height',
'image_aspect_ratio',
'image_steps',
'image_cfg_scale',
'image_seed',
'image_batch_size',
'image_batch_count',
'image_model_menu',
'image_dtype',
'image_attn_backend',
'image_compile',
'image_cpu_offload',
'image_quant',
]
for element_name in change_elements:
if element_name in shared.gradio:
shared.gradio[element_name].change(

View file

@ -18,7 +18,6 @@ from modules.image_models import (
)
from modules.logging_colors import logger
from modules.text_generation import stop_everything_event
from modules.torch_utils import get_device
from modules.utils import gradio
ASPECT_RATIOS = {
@ -667,7 +666,7 @@ def generate(state):
"""
import torch
from modules.torch_utils import clear_torch_cache
from modules.torch_utils import clear_torch_cache, get_device
clear_torch_cache()