diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e73825b3..c4d8c91ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -134,21 +134,23 @@ Models...And support for new models: **CogView-4**, **SANA 1.5**, - `torch.compile` is now available - Flash Attention 2 is now available - **Other** - - new command line option `--monitor PERIOD` to monitor CPU and GPU memory ever n seconds - - **upscale**: new [asymmetric vae v2](https://huggingface.co/Heasterian/AsymmetricAutoencoderKLUpscaler_v2) upscaling method - - **upscale**: new experimental support for `libvips` upscaling - - **quantization**: add support for `optimum-quanto` on-the-fly quantization during load for all models + - **Command line** new option `--monitor PERIOD` to monitor CPU and GPU memory ever n seconds + - **Upscale** new [asymmetric vae v2](https://huggingface.co/Heasterian/AsymmetricAutoencoderKLUpscaler_v2) upscaling method + - **Upscale** new experimental support for `libvips` upscaling + - **Quantization** add support for `optimum-quanto` on-the-fly quantization during load for all models note: previous method for quanto is still valid and is noted in settings as post-load quantization - - add quantization support to **CogView-3Plus** - - update `diffusers` and other requirements - - rename vae, unet and text-encoder settings *None* to *Default* to avoid confusion + - **Quantization** add support to **CogView-3Plus** + - **Default values** rename vae, unet and text-encoder settings *None* to *Default* to avoid confusion + - **Detailer**: add *renoise* option to increase/decrease noise during detailer pass + which can help with improving level of details - **CLI**: add `cli/api-grid.py` which can generate grids using params-from-file for x/y axis - **Samplers** add ability to set sigma adjustment for each sampler - **ModernUI** updates - **CSS** updates - - settings vertiocal/dirty indicator restores to default setting instead to previous value - - video interpolate do not skip duplicate frames - - **settings UI** full refactor + - **Video** interpolate do not skip duplicate frames + - **Settings UI** full refactor + - **Settings UI** vertical/dirty indicator restores to default setting instead to previous value + - update `diffusers` and other requirements - **Wiki/Docs** - updated [Models](https://github.com/vladmandic/sdnext/wiki/Models) info - new [Video](https://github.com/vladmandic/sdnext/wiki/Video) guide diff --git a/cli/image-exif.py b/cli/image-exif.py index 2e3754241..9a48d2dd7 100755 --- a/cli/image-exif.py +++ b/cli/image-exif.py @@ -4,6 +4,7 @@ import os import io import re import sys +import json import importlib.util from PIL import Image, ExifTags, TiffImagePlugin, PngImagePlugin from rich import print # pylint: disable=redefined-builtin @@ -95,6 +96,14 @@ class Exif: # pylint: disable=single-string-used-for-slots return raw +def print_json(data): + try: + for k, v in data.items(): + print(f'json: k={k}', json.loads(v)) + except Exception: + pass + + def read_exif(filename: str): if filename.lower().endswith('.heic'): from pi_heif import register_heif_opener @@ -103,8 +112,10 @@ def read_exif(filename: str): image = Image.open(filename) exif = Exif(image) print('image:', filename, 'format:', image) - print('exif:', vars(exif.exif)['_data']) + data = vars(exif.exif)['_data'] + print('exif:', data) print('info:', exif.parse()) + print_json(data) except Exception as e: print('metadata error reading:', filename, e) diff --git a/modules/postprocess/yolo.py b/modules/postprocess/yolo.py index 8054e03ea..d57d59e04 100644 --- a/modules/postprocess/yolo.py +++ b/modules/postprocess/yolo.py @@ -293,6 +293,12 @@ class YoloRestorer(Detailer): p.state = '' prev_state = shared.state.job pc = copy(p) + + orig_sigma_adjust: float = shared.opts.schedulers_sigma_adjust + orig_sigma_end: float = shared.opts.schedulers_sigma_adjust_max + shared.opts.schedulers_sigma_adjust = shared.opts.detailer_sigma_adjust + shared.opts.schedulers_sigma_adjust_max = shared.opts.detailer_sigma_adjust_max + for item in items: if item.mask is None: continue @@ -308,6 +314,9 @@ class YoloRestorer(Detailer): if len(pp.images) > 1: mask_all.append(pp.images[1]) + shared.opts.schedulers_sigma_adjust = orig_sigma_adjust + shared.opts.schedulers_sigma_adjust_max = orig_sigma_end + # restore pipeline if control_pipeline is not None: shared.sd_model = control_pipeline @@ -330,7 +339,7 @@ class YoloRestorer(Detailer): return np_image def ui(self, tab: str): - def ui_settings_change(detailers, classes, strength, padding, blur, min_confidence, max_detected, min_size, max_size, iou, steps): + def ui_settings_change(detailers, classes, strength, padding, blur, min_confidence, max_detected, min_size, max_size, iou, steps, renoise_value, renoise_end): shared.opts.detailer_models = detailers shared.opts.detailer_classes = classes shared.opts.detailer_padding = padding @@ -340,6 +349,8 @@ class YoloRestorer(Detailer): shared.opts.detailer_min_size = min_size shared.opts.detailer_max_size = max_size shared.opts.detailer_iou = iou + shared.opts.detailer_sigma_adjust = renoise_value + shared.opts.detailer_sigma_adjust_max = renoise_end shared.opts.save(shared.config_filename, silent=True) shared.log.debug(f'Detailer settings: models={detailers} classes={classes} strength={strength} conf={min_confidence} max={max_detected} iou={iou} size={min_size}-{max_size} padding={padding} steps={steps}') @@ -371,15 +382,18 @@ class YoloRestorer(Detailer): min_size = gr.Slider(label="Min size", elem_id=f"{tab}_detailer_min_size", value=min_size, minimum=0.0, maximum=1.0, step=0.05) max_size = shared.opts.detailer_max_size if shared.opts.detailer_max_size < 1 and shared.opts.detailer_max_size > 0 else 1.0 max_size = gr.Slider(label="Max size", elem_id=f"{tab}_detailer_max_size", value=max_size, minimum=0.0, maximum=1.0, step=0.05) - detailers.change(fn=ui_settings_change, inputs=[detailers, classes, strength, padding, blur, min_confidence, max_detected, min_size, max_size, iou, steps], outputs=[]) - classes.change(fn=ui_settings_change, inputs=[detailers, classes, strength, padding, blur, min_confidence, max_detected, min_size, max_size, iou, steps], outputs=[]) - padding.change(fn=ui_settings_change, inputs=[detailers, classes, strength, padding, blur, min_confidence, max_detected, min_size, max_size, iou, steps], outputs=[]) - blur.change(fn=ui_settings_change, inputs=[detailers, classes, strength, padding, blur, min_confidence, max_detected, min_size, max_size, iou, steps], outputs=[]) - min_confidence.change(fn=ui_settings_change, inputs=[detailers, classes, strength, padding, blur, min_confidence, max_detected, min_size, max_size, iou, steps], outputs=[]) - max_detected.change(fn=ui_settings_change, inputs=[detailers, classes, strength, padding, blur, min_confidence, max_detected, min_size, max_size, iou, steps], outputs=[]) - min_size.change(fn=ui_settings_change, inputs=[detailers, classes, strength, padding, blur, min_confidence, max_detected, min_size, max_size, iou, steps], outputs=[]) - max_size.change(fn=ui_settings_change, inputs=[detailers, classes, strength, padding, blur, min_confidence, max_detected, min_size, max_size, iou, steps], outputs=[]) - iou.change(fn=ui_settings_change, inputs=[detailers, classes, strength, padding, blur, min_confidence, max_detected, min_size, max_size, iou, steps], outputs=[]) + with gr.Row(elem_classes=['flex-break']): + renoise_value = gr.Slider(minimum=0.5, maximum=1.5, step=0.01, label='Renoiose', value=shared.opts.detailer_sigma_adjust, elem_id=f"{tab}_detailer_renoise") + renoise_end = gr.Slider(minimum=0.0, maximum=1.0, step=0.01, label='Renoise end', value=shared.opts.detailer_sigma_adjust_max, elem_id=f"{tab}_detailer_renoise_end") + detailers.change(fn=ui_settings_change, inputs=[detailers, classes, strength, padding, blur, min_confidence, max_detected, min_size, max_size, iou, steps, renoise_value, renoise_end], outputs=[]) + classes.change(fn=ui_settings_change, inputs=[detailers, classes, strength, padding, blur, min_confidence, max_detected, min_size, max_size, iou, steps, renoise_value, renoise_end], outputs=[]) + padding.change(fn=ui_settings_change, inputs=[detailers, classes, strength, padding, blur, min_confidence, max_detected, min_size, max_size, iou, steps, renoise_value, renoise_end], outputs=[]) + blur.change(fn=ui_settings_change, inputs=[detailers, classes, strength, padding, blur, min_confidence, max_detected, min_size, max_size, iou, steps, renoise_value, renoise_end], outputs=[]) + min_confidence.change(fn=ui_settings_change, inputs=[detailers, classes, strength, padding, blur, min_confidence, max_detected, min_size, max_size, iou, steps, renoise_value, renoise_end], outputs=[]) + max_detected.change(fn=ui_settings_change, inputs=[detailers, classes, strength, padding, blur, min_confidence, max_detected, min_size, max_size, iou, steps, renoise_value, renoise_end], outputs=[]) + min_size.change(fn=ui_settings_change, inputs=[detailers, classes, strength, padding, blur, min_confidence, max_detected, min_size, max_size, iou, steps, renoise_value, renoise_end], outputs=[]) + max_size.change(fn=ui_settings_change, inputs=[detailers, classes, strength, padding, blur, min_confidence, max_detected, min_size, max_size, iou, steps, renoise_value, renoise_end], outputs=[]) + iou.change(fn=ui_settings_change, inputs=[detailers, classes, strength, padding, blur, min_confidence, max_detected, min_size, max_size, iou, steps, renoise_value, renoise_end], outputs=[]) return enabled, prompt, negative, steps, strength diff --git a/modules/processing_callbacks.py b/modules/processing_callbacks.py index 0ab91baa6..599a77534 100644 --- a/modules/processing_callbacks.py +++ b/modules/processing_callbacks.py @@ -125,6 +125,7 @@ def diffusers_callback(pipe, step: int = 0, timestep: int = 0, kwargs: dict = {} shared.state.current_sigma_next = pipe.scheduler.sigmas[pipe.scheduler.step_index] if (shared.opts.schedulers_sigma_adjust != 1.0) and (timestep > 1000 * shared.opts.schedulers_sigma_adjust_min) and (timestep < 1000 * shared.opts.schedulers_sigma_adjust_max): pipe.scheduler.sigmas[pipe.scheduler.step_index+1] = pipe.scheduler.sigmas[pipe.scheduler.step_index+1] * shared.opts.schedulers_sigma_adjust + p.extra_generation_params["Sigma adjust"] = shared.opts.schedulers_sigma_adjust except Exception: pass except Exception as e: diff --git a/modules/shared.py b/modules/shared.py index 63d01446c..1db4c2935 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -829,6 +829,8 @@ options_templates.update(options_section(('postprocessing', "Postprocessing"), { "detailer_conf": OptionInfo(0.6, "Min confidence", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.05, "visible": False}), "detailer_max": OptionInfo(2, "Max detected", gr.Slider, {"minimum": 1, "maximum": 10, "step": 1, "visible": False}), "detailer_iou": OptionInfo(0.5, "Max overlap", gr.Slider, {"minimum": 0, "maximum": 1.0, "step": 0.05, "visible": False}), + "detailer_sigma_adjust": OptionInfo(1.0, "Detailer sigma adjust", gr.Slider, {"minimum": 0, "maximum": 1.0, "step": 0.05, "visible": False}), + "detailer_sigma_adjust_max": OptionInfo(1.0, "Detailer sigma end", gr.Slider, {"minimum": 0, "maximum": 1.0, "step": 0.05, "visible": False}), "detailer_min_size": OptionInfo(0.0, "Min object size", gr.Slider, {"minimum": 0.1, "maximum": 1, "step": 0.05, "visible": False}), "detailer_max_size": OptionInfo(1.0, "Max object size", gr.Slider, {"minimum": 0.1, "maximum": 1, "step": 0.05, "visible": False}), "detailer_padding": OptionInfo(20, "Item padding", gr.Slider, {"minimum": 0, "maximum": 100, "step": 1, "visible": False}),