This commit is contained in:
oobabooga 2025-11-27 18:15:15 -08:00
parent 30d1f502aa
commit 822e74ac97
4 changed files with 10 additions and 14 deletions

View file

@ -1678,6 +1678,6 @@ button:focus {
button#swap-height-width {
position: absolute;
top: -50px;
right: 0px;
right: 0;
border: 0;
}

View file

@ -1,5 +1,3 @@
# modules/image_model_settings.py
import os
from pathlib import Path
import yaml
@ -7,7 +5,6 @@ import yaml
import modules.shared as shared
from modules.logging_colors import logger
DEFAULTS = {
'model_name': 'None',
'dtype': 'bfloat16',

View file

@ -1,11 +1,11 @@
# modules/image_models.py
import time
import torch
import modules.shared as shared
from modules.logging_colors import logger
from modules.utils import resolve_model_path
from modules.torch_utils import get_device
from modules.utils import resolve_model_path
def load_image_model(model_name, dtype='bfloat16', attn_backend='sdpa', cpu_offload=False, compile_model=False):
@ -56,7 +56,7 @@ def load_image_model(model_name, dtype='bfloat16', attn_backend='sdpa', cpu_offl
shared.image_model = pipe
shared.image_model_name = model_name
logger.info(f"Loaded image model \"{model_name}\" in {(time.time()-t0):.2f} seconds.")
logger.info(f"Loaded image model \"{model_name}\" in {(time.time() - t0):.2f} seconds.")
return pipe
except Exception as e:
@ -73,9 +73,7 @@ def unload_image_model():
shared.image_model = None
shared.image_model_name = 'None'
# Clear CUDA cache
if torch.cuda.is_available():
torch.cuda.empty_cache()
from modules.torch_utils import clear_torch_cache
clear_torch_cache()
logger.info("Image model unloaded.")

View file

@ -1,4 +1,3 @@
# modules/ui_image_generation.py
import os
import traceback
from datetime import datetime
@ -9,9 +8,11 @@ import numpy as np
import torch
from modules import shared, utils
from modules.image_model_settings import (
get_effective_settings,
save_image_model_settings
)
from modules.image_models import load_image_model, unload_image_model
from modules.image_model_settings import get_effective_settings, save_image_model_settings
# Aspect ratio definitions: name -> (width_ratio, height_ratio)
ASPECT_RATIOS = {