mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 09:14:35 +02:00
multiple fixes
This commit is contained in:
+1
-1
@@ -114,7 +114,7 @@ def compatibility_args(opts, args):
|
||||
opts.sd_vae_as_default = True
|
||||
opts.enable_emphasis = True
|
||||
opts.enable_batch_seeds = True
|
||||
opts.multiple_tqdm = False
|
||||
# opts.multiple_tqdm = False
|
||||
opts.print_hypernet_extra = False
|
||||
opts.dimensions_and_batch_together = True
|
||||
opts.enable_pnginfo = True
|
||||
|
||||
+7
-3
@@ -9,7 +9,11 @@ initialized = False
|
||||
logging.getLogger("DeepSpeed").disabled = True
|
||||
# os.environ.setdefault('OMP_NUM_THREADS', 1)
|
||||
# os.environ.setdefault('MKL_NUM_THREADS', 1)
|
||||
|
||||
# import tensorflow as tf # pylint: disable=C0411
|
||||
|
||||
import torch # pylint: disable=C0411
|
||||
|
||||
# torch.set_num_threads(1)
|
||||
try:
|
||||
import intel_extension_for_pytorch as ipex # pylint: disable=import-error, unused-import
|
||||
@@ -19,14 +23,14 @@ except Exception:
|
||||
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
||||
import torchvision # pylint: disable=W0611,C0411
|
||||
import pytorch_lightning # pytorch_lightning should be imported after torch, but it re-enables warnings on import so import once to disable them # pylint: disable=W0611,C0411
|
||||
if ".dev" in torch.__version__ or "+git" in torch.__version__:
|
||||
torch.__long_version__ = torch.__version__
|
||||
torch.__version__ = re.search(r'[\d.]+[\d]', torch.__version__).group(0)
|
||||
logging.getLogger("xformers").addFilter(lambda record: 'A matching Triton is not available' not in record.getMessage())
|
||||
logging.getLogger("pytorch_lightning").disabled = True
|
||||
warnings.filterwarnings(action="ignore", category=DeprecationWarning)
|
||||
warnings.filterwarnings(action="ignore", category=FutureWarning)
|
||||
warnings.filterwarnings(action="ignore", category=UserWarning, module="torchvision")
|
||||
if ".dev" in torch.__version__ or "+git" in torch.__version__:
|
||||
torch.__long_version__ = torch.__version__
|
||||
torch.__version__ = re.search(r'[\d.]+[\d]', torch.__version__).group(0)
|
||||
timer.startup.record("torch")
|
||||
|
||||
from fastapi import FastAPI # pylint: disable=W0611,C0411
|
||||
|
||||
@@ -163,6 +163,7 @@ class StableDiffusionProcessing:
|
||||
self.refiner_steps = 5
|
||||
self.refiner_start = 0
|
||||
self.ops = []
|
||||
self.resize_mode: int = 0
|
||||
self.ddim_discretize = shared.opts.ddim_discretize
|
||||
self.s_min_uncond = shared.opts.s_min_uncond
|
||||
self.s_churn = shared.opts.s_churn
|
||||
@@ -172,9 +173,10 @@ class StableDiffusionProcessing:
|
||||
self.s_tmin = shared.opts.s_tmin
|
||||
self.s_tmax = float('inf') # not representable as a standard ui option
|
||||
self.refiner_switch_at = 0 # a1111 compatibility item
|
||||
self.comments = {}
|
||||
self.is_api = False
|
||||
self.resize_mode: int = 0
|
||||
self.all_hr_prompts = [] # a1111 compatibility item
|
||||
self.hr_prompt = '' # a1111 compatibility item
|
||||
self.comments = {} # a1111 compatibility item
|
||||
self.is_api = False # a1111 compatibility item
|
||||
shared.opts.data['clip_skip'] = clip_skip
|
||||
|
||||
@property
|
||||
@@ -1180,6 +1182,8 @@ class StableDiffusionProcessingImg2Img(StableDiffusionProcessing):
|
||||
crop_region = None
|
||||
image_mask = self.image_mask
|
||||
if image_mask is not None:
|
||||
if type(image_mask) == list:
|
||||
image_mask = image_mask[0]
|
||||
image_mask = image_mask.convert('L')
|
||||
if self.inpainting_mask_invert:
|
||||
image_mask = ImageOps.invert(image_mask)
|
||||
|
||||
@@ -51,6 +51,7 @@ class CheckpointInfo:
|
||||
self.filename = filename
|
||||
self.type = ''
|
||||
relname = filename
|
||||
app_path = os.path.abspath(script_path)
|
||||
|
||||
def rel(fn, path):
|
||||
try:
|
||||
@@ -58,6 +59,8 @@ class CheckpointInfo:
|
||||
except Exception:
|
||||
return fn
|
||||
|
||||
if relname.startswith('..'):
|
||||
relname = os.path.abspath(relname)
|
||||
if relname.startswith(shared.opts.ckpt_dir):
|
||||
relname = rel(filename, shared.opts.ckpt_dir)
|
||||
elif relname.startswith(shared.opts.diffusers_dir):
|
||||
@@ -66,6 +69,8 @@ class CheckpointInfo:
|
||||
relname = rel(filename, model_path)
|
||||
elif relname.startswith(script_path):
|
||||
relname = rel(filename, script_path)
|
||||
elif relname.startswith(app_path):
|
||||
relname = rel(filename, app_path)
|
||||
else:
|
||||
relname = os.path.abspath(relname)
|
||||
relname, ext = os.path.splitext(relname)
|
||||
@@ -705,6 +710,9 @@ def compile_diffusers(sd_model):
|
||||
|
||||
|
||||
def set_diffuser_options(sd_model, vae, op: str):
|
||||
if sd_model is None:
|
||||
shared.log.warning(f'{op} is not loaded')
|
||||
return
|
||||
if (shared.opts.diffusers_model_cpu_offload or shared.cmd_opts.medvram) and (shared.opts.diffusers_seq_cpu_offload or shared.cmd_opts.lowvram):
|
||||
shared.log.warning(f'Setting {op}: Model CPU offload and Sequential CPU offload are not compatible')
|
||||
shared.log.debug(f'Setting {op}: disabling model CPU offload')
|
||||
|
||||
+16
-19
@@ -5,8 +5,6 @@ from modules import devices, paths, shared
|
||||
|
||||
|
||||
sd_vae_approx_model = None
|
||||
simple_weights = None
|
||||
simple_bias = None
|
||||
|
||||
|
||||
class VAEApprox(nn.Module):
|
||||
@@ -58,24 +56,23 @@ def nn_approximation(sample): # Approximate NN
|
||||
|
||||
def cheap_approximation(sample): # Approximate simple
|
||||
# https://discuss.huggingface.co/t/decoding-latents-to-rgb-without-upscaling/23204/2
|
||||
global simple_weights, simple_bias # pylint: disable=global-statement
|
||||
if simple_weights is None or simple_bias is None:
|
||||
if shared.sd_model_type == "sdxl":
|
||||
simple_weights = torch.tensor([
|
||||
[0.4543,-0.2868, 0.1566,-0.4748],
|
||||
[0.5008, 0.0952, 0.2155,-0.3268],
|
||||
[0.5294, 0.1625,-0.0624,-0.3793]
|
||||
]).reshape(3, 4, 1, 1).to(sample.device)
|
||||
simple_bias = torch.tensor([0.1375, 0.0144, -0.0675]).to(sample.device)
|
||||
else:
|
||||
simple_weights = torch.tensor([
|
||||
[0.298, 0.187,-0.158,-0.184],
|
||||
[0.207, 0.286, 0.189,-0.271],
|
||||
[0.208, 0.173, 0.264,-0.473],
|
||||
]).reshape(3, 4, 1, 1).to(sample.device)
|
||||
simple_bias = None
|
||||
if shared.sd_model_type == "sdxl":
|
||||
simple_weights = torch.tensor([
|
||||
[0.4543,-0.2868, 0.1566,-0.4748],
|
||||
[0.5008, 0.0952, 0.2155,-0.3268],
|
||||
[0.5294, 0.1625,-0.0624,-0.3793]
|
||||
]).reshape(3, 4, 1, 1)
|
||||
simple_bias = torch.tensor([0.1375, 0.0144, -0.0675])
|
||||
else:
|
||||
simple_weights = torch.tensor([
|
||||
[0.298, 0.187,-0.158,-0.184],
|
||||
[0.207, 0.286, 0.189,-0.271],
|
||||
[0.208, 0.173, 0.264,-0.473],
|
||||
]).reshape(3, 4, 1, 1)
|
||||
simple_bias = None
|
||||
try:
|
||||
x_sample = nn.functional.conv2d(sample, simple_weights, simple_bias) # pylint: disable=not-callable
|
||||
print('HERE', sample.dtype, sample.device)
|
||||
x_sample = nn.functional.conv2d(sample, simple_weights.to(sample.device, sample.dtype), simple_bias.to(sample.device, sample.dtype)) # pylint: disable=not-callable
|
||||
return x_sample
|
||||
except Exception as e:
|
||||
shared.log.error(f'Decode simple: {e}')
|
||||
|
||||
Reference in New Issue
Block a user