mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 09:14:35 +02:00
add low/high threshold to balanced offload
Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
@@ -368,14 +368,13 @@ def validate_sample(tensor):
|
||||
sample = 255.0 * np.moveaxis(sample, 0, 2) if not shared.native else 255.0 * sample
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
cast = sample.astype(np.uint8)
|
||||
minimum, maximum, mean = np.min(cast), np.max(cast), np.mean(cast)
|
||||
if len(w) > 0 or minimum == maximum:
|
||||
if len(w) > 0:
|
||||
nans = np.isnan(sample).sum()
|
||||
cast = np.nan_to_num(sample)
|
||||
cast = cast.astype(np.uint8)
|
||||
vae = shared.sd_model.vae.dtype if hasattr(shared.sd_model, 'vae') else None
|
||||
upcast = getattr(shared.sd_model.vae.config, 'force_upcast', None) if hasattr(shared.sd_model, 'vae') and hasattr(shared.sd_model.vae, 'config') else None
|
||||
shared.log.error(f'Decode: sample={sample.shape} invalid={nans} mean={mean} dtype={dtype} vae={vae} upcast={upcast} failed to validate')
|
||||
shared.log.error(f'Decode: sample={sample.shape} invalid={nans} dtype={dtype} vae={vae} upcast={upcast} failed to validate')
|
||||
if upcast is not None and not upcast:
|
||||
setattr(shared.sd_model.vae.config, 'force_upcast', True) # noqa: B010
|
||||
shared.log.warning('Decode: upcast=True set, retry operation')
|
||||
|
||||
Reference in New Issue
Block a user