mirror of
https://github.com/Bing-su/adetailer.git
synced 2026-04-30 19:21:33 +00:00
fix: remove 0 offset param, ultralytics check
This commit is contained in:
@@ -87,6 +87,11 @@ class ADetailerArgs(BaseModel, extra=Extra.forbid):
|
|||||||
if not params["ADetailer negative prompt"]:
|
if not params["ADetailer negative prompt"]:
|
||||||
params.pop("ADetailer negative prompt")
|
params.pop("ADetailer negative prompt")
|
||||||
|
|
||||||
|
if params["ADetailer x offset"] == 0:
|
||||||
|
params.pop("ADetailer x offset")
|
||||||
|
if params["ADetailer y offset"] == 0:
|
||||||
|
params.pop("ADetailer y offset")
|
||||||
|
|
||||||
if not params["ADetailer use inpaint width/height"]:
|
if not params["ADetailer use inpaint width/height"]:
|
||||||
params.pop("ADetailer inpaint width")
|
params.pop("ADetailer inpaint width")
|
||||||
params.pop("ADetailer inpaint height")
|
params.pop("ADetailer inpaint height")
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import platform
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Union
|
from typing import Union
|
||||||
|
|
||||||
@@ -10,8 +9,6 @@ from PIL import Image
|
|||||||
from adetailer import PredictOutput
|
from adetailer import PredictOutput
|
||||||
from adetailer.common import create_mask_from_bbox
|
from adetailer.common import create_mask_from_bbox
|
||||||
|
|
||||||
checked = False
|
|
||||||
|
|
||||||
|
|
||||||
def ultralytics_predict(
|
def ultralytics_predict(
|
||||||
model_path: Union[str, Path],
|
model_path: Union[str, Path],
|
||||||
@@ -19,15 +16,12 @@ def ultralytics_predict(
|
|||||||
confidence: float = 0.3,
|
confidence: float = 0.3,
|
||||||
device: str = "",
|
device: str = "",
|
||||||
) -> PredictOutput:
|
) -> PredictOutput:
|
||||||
if not checked:
|
|
||||||
ultralytics_check()
|
|
||||||
|
|
||||||
from ultralytics import YOLO
|
from ultralytics import YOLO
|
||||||
|
|
||||||
model_path = str(model_path)
|
model_path = str(model_path)
|
||||||
|
|
||||||
model = YOLO(model_path)
|
model = YOLO(model_path)
|
||||||
pred = model(image, conf=confidence, show_labels=False, device=device)
|
pred = model(image, conf=confidence, device=device)
|
||||||
|
|
||||||
bboxes = pred[0].boxes.xyxy.cpu().numpy()
|
bboxes = pred[0].boxes.xyxy.cpu().numpy()
|
||||||
if bboxes.size == 0:
|
if bboxes.size == 0:
|
||||||
@@ -45,19 +39,6 @@ def ultralytics_predict(
|
|||||||
return PredictOutput(bboxes=bboxes, masks=masks, preview=preview)
|
return PredictOutput(bboxes=bboxes, masks=masks, preview=preview)
|
||||||
|
|
||||||
|
|
||||||
def ultralytics_check():
|
|
||||||
global checked
|
|
||||||
|
|
||||||
checked = True
|
|
||||||
if platform.system() != "Windows":
|
|
||||||
return
|
|
||||||
|
|
||||||
p = str(Path.cwd().parent)
|
|
||||||
if p == "C:\\":
|
|
||||||
message = "[-] ADetailer: if you get stuck here, try moving the stable-diffusion-webui to a different directory, or try running as administrator."
|
|
||||||
print(message)
|
|
||||||
|
|
||||||
|
|
||||||
def mask_to_pil(masks, shape: tuple[int, int]) -> list[Image.Image]:
|
def mask_to_pil(masks, shape: tuple[int, int]) -> list[Image.Image]:
|
||||||
"""
|
"""
|
||||||
Parameters
|
Parameters
|
||||||
|
|||||||
Reference in New Issue
Block a user