mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 01:04:32 +02:00
clean and propagate tracebacks to ui
Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
- sdnq separate dit/te settings
|
||||
- **Features**
|
||||
- SeedVR enhanced support
|
||||
- Propagate server tracebacks to client
|
||||
- **Fixes**
|
||||
- upscaler auto-refresh to catch chainner upscalers that are not loaded on first attempt
|
||||
- lora support diffusers trainer
|
||||
|
||||
+20
-6
@@ -108,15 +108,29 @@ def setup_logging(debug=None, trace=None, filename=None):
|
||||
return ansi_escape.sub('', str(line))
|
||||
|
||||
def emit(self, record):
|
||||
if record.msg is not None and not isinstance(record.msg, str):
|
||||
record.msg = str(record.msg)
|
||||
if record.msg is None:
|
||||
record.msg = ""
|
||||
msg = record.getMessage()
|
||||
msg = msg.replace('"', "'")
|
||||
msg = self.strip(msg)
|
||||
try:
|
||||
record.msg = record.msg.replace('"', "'")
|
||||
if '❱ ' in msg: # only last 3 lines of traceback
|
||||
lines = [l.strip() for l in msg.splitlines() if l.strip() and not l.startswith(' ')]
|
||||
if len(lines) > 3:
|
||||
lines = lines[-3:]
|
||||
lines = [l.replace('│ ', '').strip() for l in lines]
|
||||
lines.insert(0, 'Exception traceback:')
|
||||
msg = '\n'.join(lines)
|
||||
except Exception:
|
||||
pass
|
||||
line = self.format(record)
|
||||
line = self.strip(line)
|
||||
self.buffer.append(line[:1024])
|
||||
try:
|
||||
if len(msg) > 1024:
|
||||
msg = msg[:1024] + '...'
|
||||
except Exception:
|
||||
pass
|
||||
record.msg = msg
|
||||
formatted = self.format(record)
|
||||
self.buffer.append(formatted)
|
||||
if len(self.buffer) > self.capacity:
|
||||
self.buffer.pop(0)
|
||||
|
||||
|
||||
@@ -77,23 +77,19 @@ class NaPatchIn(PatchIn):
|
||||
self,
|
||||
vid: torch.Tensor, # l c
|
||||
vid_shape: torch.LongTensor,
|
||||
cache: Cache = Cache(disable=True),
|
||||
) -> torch.Tensor:
|
||||
cache = cache.namespace("patch")
|
||||
vid_shape_before_patchify = cache("vid_shape_before_patchify", lambda: vid_shape)
|
||||
t, h, w = self.patch_size
|
||||
if not t == h == w == 1:
|
||||
vid = na.unflatten(vid, vid_shape)
|
||||
vid, vid_shape = na.rearrange(
|
||||
vid, vid_shape, "(T t) (H h) (W w) c -> T H W (t h w c)", t=t, h=h, w=w
|
||||
)
|
||||
for i in range(len(vid)):
|
||||
if t > 1 and vid_shape_before_patchify[i, 0] % t != 0:
|
||||
vid[i] = torch.cat([vid[i][:1]] * (t - vid[i].size(0) % t) + [vid[i]], dim=0)
|
||||
if h > 1 and vid_shape_before_patchify[i, 1] % h != 0:
|
||||
if h > 1 and vid_shape[i, 1] % h != 0:
|
||||
vid[i] = torch.cat([vid[i][:, :1]] * (h - vid[i].size(1) % h) + [vid[i]], dim=1)
|
||||
if w > 1 and vid_shape_before_patchify[i, 2] % w != 0:
|
||||
if w > 1 and vid_shape[i, 2] % w != 0:
|
||||
vid[i] = torch.cat([vid[i][:, :, :1]] * (w - vid[i].size(2) % w) + [vid[i]], dim=2)
|
||||
vid[i] = rearrange(vid[i], "(T t) (H h) (W w) c -> T H W (t h w c)", t=t, h=h, w=w)
|
||||
vid, vid_shape = na.flatten(vid)
|
||||
# slice vid after patchting in when using sequence parallelism
|
||||
# slice vid after patching in when using sequence parallelism
|
||||
vid = slice_inputs(vid, dim=0)
|
||||
if vid.dtype != self.proj.weight.dtype:
|
||||
vid = vid.to(self.proj.weight.dtype)
|
||||
@@ -111,8 +107,6 @@ class NaPatchOut(PatchOut):
|
||||
torch.FloatTensor,
|
||||
torch.LongTensor,
|
||||
]:
|
||||
cache = cache.namespace("patch")
|
||||
vid_shape_before_patchify = cache.get("vid_shape_before_patchify")
|
||||
t, h, w = self.patch_size
|
||||
if vid.dtype != self.proj.weight.dtype:
|
||||
vid = vid.to(self.proj.weight.dtype)
|
||||
@@ -126,14 +120,12 @@ class NaPatchOut(PatchOut):
|
||||
cache=cache.namespace("vid"),
|
||||
)
|
||||
if not t == h == w == 1:
|
||||
vid = na.unflatten(vid, vid_shape)
|
||||
vid, vid_shape = na.rearrange(
|
||||
vid, vid_shape, "T H W (t h w c) -> (T t) (H h) (W w) c", t=t, h=h, w=w
|
||||
)
|
||||
for i in range(len(vid)):
|
||||
vid[i] = rearrange(vid[i], "T H W (t h w c) -> (T t) (H h) (W w) c", t=t, h=h, w=w)
|
||||
if t > 1 and vid_shape_before_patchify is not None and vid_shape_before_patchify[i, 0] % t != 0:
|
||||
vid[i] = vid[i][(t - vid_shape_before_patchify[i, 0] % t) :]
|
||||
if h > 1 and vid_shape_before_patchify is not None and vid_shape_before_patchify[i, 1] % h != 0:
|
||||
vid[i] = vid[i][:, (h - vid_shape_before_patchify[i, 1] % h) :]
|
||||
if w > 1 and vid_shape_before_patchify is not None and vid_shape_before_patchify[i, 2] % w != 0:
|
||||
vid[i] = vid[i][:, :, (w - vid_shape_before_patchify[i, 2] % w) :]
|
||||
vid, vid_shape = na.flatten(vid)
|
||||
if h > 1 and vid_shape[i, 1] % h != 0:
|
||||
vid[i] = vid[i][:, (h - vid_shape[i, 1] % h) :]
|
||||
if w > 1 and vid_shape[i, 2] % w != 0:
|
||||
vid[i] = vid[i][:, :, (w - vid_shape[i, 2] % w) :]
|
||||
return vid, vid_shape
|
||||
|
||||
@@ -13,12 +13,11 @@
|
||||
# // limitations under the License.
|
||||
|
||||
from typing import Optional, Tuple, Union
|
||||
from itertools import chain
|
||||
import torch
|
||||
from einops import rearrange
|
||||
from torch import nn
|
||||
from torch.nn import functional as F
|
||||
from torch.nn.modules.utils import _triple
|
||||
|
||||
from .....common.cache import Cache
|
||||
from .....common.distributed.ops import gather_heads_scatter_seq, gather_seq_scatter_heads_qkv
|
||||
from .....common.half_precision_fixes import safe_pad_operation
|
||||
@@ -29,7 +28,6 @@ from ...mm import MMArg, MMModule
|
||||
from ...normalization import norm_layer_type
|
||||
from ...rope import get_na_rope
|
||||
from ...window import get_window_op
|
||||
from itertools import chain
|
||||
|
||||
|
||||
class NaMMAttention(nn.Module):
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
from typing import TYPE_CHECKING
|
||||
import gradio as gr
|
||||
from modules import scripts_postprocessing
|
||||
if TYPE_CHECKING:
|
||||
from modules.postprocess.seedvr_model import UpscalerSeedVR
|
||||
|
||||
|
||||
class ScriptSeedVR(scripts_postprocessing.ScriptPostprocessing):
|
||||
@@ -17,7 +20,7 @@ class ScriptSeedVR(scripts_postprocessing.ScriptPostprocessing):
|
||||
seedvr_seed = gr.Number(step=1, value=-1, label="SeedVR seed", elem_id="extras_seedvr_seed")
|
||||
seedvr_steps = gr.Number(step=1, value=1, minimum=1, maximum=99, label="SeedVR steps", elem_id="extras_seedvr_steps", visible=False)
|
||||
with gr.Row():
|
||||
seedvr_cfg_scale = gr.Slider(minimum=0.0, maximum=15.0, step=0.01, value=3.5, label="SeedVR guidance scale", elem_id="extras_seedvr_cfg_scale")
|
||||
seedvr_cfg_scale = gr.Slider(minimum=0.0, maximum=15.0, step=0.01, value=1.5, label="SeedVR guidance scale", elem_id="extras_seedvr_cfg_scale")
|
||||
seedvr_cfg_rescale = gr.Slider(minimum=0.0, maximum=15.0, step=0.01, value=0.0, label="SeedVR guidance rescale", elem_id="extras_seedvr_cfg_rescale")
|
||||
with gr.Row():
|
||||
seedvr_tile_size = gr.Slider(minimum=64, maximum=4096, step=8, value=1024, label="SeedVR tile size", elem_id="extras_seedvr_tile_size")
|
||||
@@ -52,7 +55,7 @@ class ScriptSeedVR(scripts_postprocessing.ScriptPostprocessing):
|
||||
from modules.logger import log
|
||||
image = pp.image
|
||||
instance: upscaler.UpscalerData = next(iter([x for x in shared.sd_upscalers if x.name == seedvr_selected]), None)
|
||||
scaler: upscaler.Upscaler = instance.scaler
|
||||
scaler: UpscalerSeedVR = instance.scaler
|
||||
|
||||
log.info(f'Upscaler: type="SeedVR" model="{seedvr_selected}" scale={seedvr_scale} seed={seedvr_seed} steps={seedvr_steps} cfg_scale={seedvr_cfg_scale} cfg_rescale={seedvr_cfg_rescale} tile_size={seedvr_tile_size} tile_overlap={seedvr_tile_overlap}')
|
||||
|
||||
|
||||
Vendored
-1
@@ -13774,7 +13774,6 @@ async function gallerySort(key) {
|
||||
rootFiles.forEach((node) => fragment.appendChild(node));
|
||||
const folderNames = Array.from(folderGroups.keys());
|
||||
const sortedFolderNames = currentSort.endsWith("A") ? folderNames.sort((a, b) => a.localeCompare(b)) : folderNames.sort((a, b) => b.localeCompare(a));
|
||||
console.log("HERE", sortedFolderNames);
|
||||
for (const folderName of sortedFolderNames) {
|
||||
const files = folderGroups.get(folderName);
|
||||
files.sort(sortMode.func);
|
||||
|
||||
Vendored
+2
-2
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user