mirror of
https://github.com/Bing-su/adetailer.git
synced 2026-05-01 11:41:41 +00:00
fix: revert ad_model None, dtype bool, annotation
This commit is contained in:
@@ -1 +1 @@
|
|||||||
__version__ = "23.5.3.post1"
|
__version__ = "23.5.3.post2"
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import importlib
|
import importlib
|
||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import platform
|
import platform
|
||||||
import sys
|
import sys
|
||||||
from copy import copy
|
from copy import copy
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
import gradio as gr
|
import gradio as gr
|
||||||
import torch
|
import torch
|
||||||
@@ -19,6 +22,14 @@ from modules.processing import (
|
|||||||
)
|
)
|
||||||
from modules.shared import cmd_opts, opts
|
from modules.shared import cmd_opts, opts
|
||||||
|
|
||||||
|
try:
|
||||||
|
from rich import print
|
||||||
|
from rich.traceback import install
|
||||||
|
|
||||||
|
install(show_locals=True)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
AFTER_DETAILER = "After Detailer"
|
AFTER_DETAILER = "After Detailer"
|
||||||
adetailer_dir = Path(models_path, "adetailer")
|
adetailer_dir = Path(models_path, "adetailer")
|
||||||
model_mapping = get_models(adetailer_dir)
|
model_mapping = get_models(adetailer_dir)
|
||||||
@@ -85,12 +96,20 @@ class ADetailerArgs:
|
|||||||
for i, (attr, _, dtype) in enumerate(ALL_ARGS):
|
for i, (attr, _, dtype) in enumerate(ALL_ARGS):
|
||||||
if not isinstance(args[i], dtype):
|
if not isinstance(args[i], dtype):
|
||||||
try:
|
try:
|
||||||
args[i] = dtype(args[i])
|
if dtype is bool:
|
||||||
|
args[i] = self.is_true(args[i])
|
||||||
|
else:
|
||||||
|
args[i] = dtype(args[i])
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
msg = f"Error converting {args[i]!r}({attr}) to {dtype}: {e}"
|
msg = f"Error converting {args[i]!r}({attr}) to {dtype}: {e}"
|
||||||
raise ValueError(msg) from e
|
raise ValueError(msg) from e
|
||||||
return args
|
return args
|
||||||
|
|
||||||
|
def is_true(self, value: Any):
|
||||||
|
if isinstance(value, bool):
|
||||||
|
return value
|
||||||
|
return str(value).lower() == "true"
|
||||||
|
|
||||||
|
|
||||||
class Widgets:
|
class Widgets:
|
||||||
def tolist(self):
|
def tolist(self):
|
||||||
@@ -123,7 +142,7 @@ class AfterDetailerScript(scripts.Script):
|
|||||||
return scripts.AlwaysVisible
|
return scripts.AlwaysVisible
|
||||||
|
|
||||||
def ui(self, is_img2img):
|
def ui(self, is_img2img):
|
||||||
model_list = list(model_mapping.keys())
|
model_list = ["None"] + list(model_mapping.keys())
|
||||||
|
|
||||||
w = Widgets()
|
w = Widgets()
|
||||||
|
|
||||||
@@ -303,7 +322,7 @@ class AfterDetailerScript(scripts.Script):
|
|||||||
print("[-] ADetailer: ControlNetExt init failed.", file=sys.stderr)
|
print("[-] ADetailer: ControlNetExt init failed.", file=sys.stderr)
|
||||||
|
|
||||||
def is_ad_enabled(self, args: ADetailerArgs):
|
def is_ad_enabled(self, args: ADetailerArgs):
|
||||||
return args.ad_enable and args.ad_model != "None"
|
return args.ad_enable is True and args.ad_model != "None"
|
||||||
|
|
||||||
def extra_params(self, args: ADetailerArgs):
|
def extra_params(self, args: ADetailerArgs):
|
||||||
params = {name: getattr(args, attr) for attr, name, *_ in ALL_ARGS[1:]}
|
params = {name: getattr(args, attr) for attr, name, *_ in ALL_ARGS[1:]}
|
||||||
|
|||||||
Reference in New Issue
Block a user