addressing #30

pull/32/head
Haoming 2024-09-18 10:58:04 +08:00
parent 2918e22021
commit a7e25e9714
5 changed files with 57 additions and 9 deletions

View File

@ -1,3 +1,6 @@
### v2.2.6 - 2024 Sep.18
- Allow disabling `do_not_save_to_config` to use **Defaults**
### v2.2.5 - 2024 Aug.30
- Correct Y'CbCr **Conversion**?

View File

@ -1,2 +0,0 @@
from .callback import *
from .settings import *

View File

@ -1,10 +1,11 @@
from modules.sd_samplers_kdiffusion import KDiffusionSampler
from modules.script_callbacks import on_script_unloaded
from modules.script_callbacks import on_script_unloaded, on_ui_settings
from functools import wraps
from random import random
import torch
from .scaling import apply_scaling
from .settings import settings
class NoiseMethods:
@ -177,3 +178,4 @@ def restore_callback():
on_script_unloaded(restore_callback)
on_ui_settings(settings)

View File

@ -1,5 +1,9 @@
from modules.script_callbacks import on_ui_settings
from modules.shared import OptionInfo, opts
from modules import scripts
from json import load, dump
import os
section = ("cc", "Vectorscope CC")
def settings():
@ -8,9 +12,37 @@ def settings():
OptionInfo(
True,
"Append Vectorscope CC parameters to generation information",
section=("infotext", "Infotext"),
section=section,
category_id="sd",
),
)
opts.add_option(
"cc_no_defaults",
OptionInfo(
True,
'Add the "do_not_save_to_config" flag to all components',
section=section,
category_id="sd",
onchange=reset_ui_config,
)
.needs_reload_ui()
.info(
"Uncheck this option if you wish to use the built-in Defaults function) (enable this option again if the extension is not functioning correctly after an update"
),
)
on_ui_settings(settings)
def reset_ui_config():
extension = "cc.py"
ui_config = os.path.join(scripts.basedir(), "ui-config.json")
with open(ui_config, "r", encoding="utf-8") as json_file:
configs = load(json_file)
cleaned_configs = {
key: value for key, value in configs.items() if extension not in key
}
with open(ui_config, "w", encoding="utf-8") as json_file:
dump(cleaned_configs, json_file)

View File

@ -4,14 +4,14 @@ from modules import shared, scripts
from lib_cc.colorpicker import create_colorpicker
from lib_cc.style import StyleManager
from lib_cc.xyz import xyz_support
from lib_cc import callback
from lib_cc import const
from random import seed
import gradio as gr
import lib_cc
VERSION = "2.2.5"
VERSION = "2.2.6"
style_manager = StyleManager()
@ -131,6 +131,18 @@ class VectorscopeCC(scripts.Script):
)
delete_btn = gr.Button(value="Delete Style", scale=2)
[
setattr(comp, "do_not_save_to_config", True)
for comp in (
style_choice,
apply_btn,
refresh_btn,
style_name,
save_btn,
delete_btn,
)
]
with gr.Accordion("Advanced Settings", open=False):
with gr.Row():
doHR = gr.Checkbox(label="Process Hires. fix")
@ -269,7 +281,8 @@ class VectorscopeCC(scripts.Script):
]
for comp, name in self.infotext_fields:
comp.do_not_save_to_config = True
if getattr(shared.opts, "cc_no_defaults", True):
comp.do_not_save_to_config = True
self.paste_field_names.append(name)
return [enable, *comps]