mirror of
https://github.com/Bing-su/adetailer.git
synced 2026-01-26 11:19:53 +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 dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import importlib
|
||||
from functools import lru_cache
|
||||
from pathlib import Path
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import platform
|
||||
import sys
|
||||
from copy import copy
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
import gradio as gr
|
||||
import torch
|
||||
@@ -19,6 +22,14 @@ from modules.processing import (
|
||||
)
|
||||
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"
|
||||
adetailer_dir = Path(models_path, "adetailer")
|
||||
model_mapping = get_models(adetailer_dir)
|
||||
@@ -85,12 +96,20 @@ class ADetailerArgs:
|
||||
for i, (attr, _, dtype) in enumerate(ALL_ARGS):
|
||||
if not isinstance(args[i], dtype):
|
||||
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:
|
||||
msg = f"Error converting {args[i]!r}({attr}) to {dtype}: {e}"
|
||||
raise ValueError(msg) from e
|
||||
return args
|
||||
|
||||
def is_true(self, value: Any):
|
||||
if isinstance(value, bool):
|
||||
return value
|
||||
return str(value).lower() == "true"
|
||||
|
||||
|
||||
class Widgets:
|
||||
def tolist(self):
|
||||
@@ -123,7 +142,7 @@ class AfterDetailerScript(scripts.Script):
|
||||
return scripts.AlwaysVisible
|
||||
|
||||
def ui(self, is_img2img):
|
||||
model_list = list(model_mapping.keys())
|
||||
model_list = ["None"] + list(model_mapping.keys())
|
||||
|
||||
w = Widgets()
|
||||
|
||||
@@ -303,7 +322,7 @@ class AfterDetailerScript(scripts.Script):
|
||||
print("[-] ADetailer: ControlNetExt init failed.", file=sys.stderr)
|
||||
|
||||
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):
|
||||
params = {name: getattr(args, attr) for attr, name, *_ in ALL_ARGS[1:]}
|
||||
|
||||
Reference in New Issue
Block a user