mirror of
https://github.com/Bing-su/adetailer.git
synced 2026-01-26 11:19:53 +00:00
feat: add controlnet union model
This commit is contained in:
@@ -2,6 +2,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
from itertools import chain
|
||||||
from types import SimpleNamespace
|
from types import SimpleNamespace
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
@@ -42,6 +43,9 @@ else:
|
|||||||
"depth": ["depth_midas", "depth_hand_refiner"],
|
"depth": ["depth_midas", "depth_hand_refiner"],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
union = list(chain.from_iterable(cn_module_choices.values()))
|
||||||
|
cn_module_choices["union"] = union
|
||||||
|
|
||||||
|
|
||||||
class Widgets(SimpleNamespace):
|
class Widgets(SimpleNamespace):
|
||||||
def tolist(self):
|
def tolist(self):
|
||||||
|
|||||||
@@ -8,4 +8,5 @@ cn_model_module = {
|
|||||||
"tile": "tile_resample",
|
"tile": "tile_resample",
|
||||||
"depth": "depth_midas",
|
"depth": "depth_midas",
|
||||||
}
|
}
|
||||||
cn_model_regex = re.compile("|".join(cn_model_module.keys()), flags=re.IGNORECASE)
|
_names = [*cn_model_module, "union"]
|
||||||
|
cn_model_regex = re.compile("|".join(_names), flags=re.IGNORECASE)
|
||||||
|
|||||||
@@ -61,13 +61,13 @@ class ControlNetExt:
|
|||||||
if (not self.cn_available) or model == "None":
|
if (not self.cn_available) or model == "None":
|
||||||
return
|
return
|
||||||
|
|
||||||
if module is None or module == "None":
|
if module == "None":
|
||||||
|
module = None
|
||||||
|
if module is None:
|
||||||
for m, v in cn_model_module.items():
|
for m, v in cn_model_module.items():
|
||||||
if m in model:
|
if m in model:
|
||||||
module = v
|
module = v
|
||||||
break
|
break
|
||||||
else:
|
|
||||||
module = None
|
|
||||||
|
|
||||||
cn_units = [
|
cn_units = [
|
||||||
self.external_cn.ControlNetUnit(
|
self.external_cn.ControlNetUnit(
|
||||||
|
|||||||
Reference in New Issue
Block a user