fix: example → preview

This commit is contained in:
Bingsu
2023-04-26 15:40:09 +09:00
parent 3079400d2f
commit 5819cafdae
3 changed files with 10 additions and 10 deletions

View File

@@ -12,7 +12,7 @@ from PIL import Image, ImageDraw
class PredictOutput:
bboxes: list[list[int]] | None = None
masks: list[Image.Image] | None = None
example: Image.Image | None = None
preview: Image.Image | None = None
def get_models(model_dir: str | Path) -> OrderedDict[str, str | None]:

View File

@@ -1,7 +1,7 @@
from __future__ import annotations
import numpy as np
import mediapipe as mp
import numpy as np
from PIL import Image
from adetailer import PredictOutput
@@ -26,11 +26,11 @@ def mediapipe_predict(
if pred.detections is None:
return PredictOutput()
example_array = img_array.copy()
preview_array = img_array.copy()
bboxes = []
for detection in pred.detections:
draw_util.draw_detection(example_array, detection)
draw_util.draw_detection(preview_array, detection)
bbox = detection.location_data.relative_bounding_box
x1 = bbox.xmin * img_width
@@ -43,6 +43,6 @@ def mediapipe_predict(
bboxes.append([x1, y1, x2, y2])
masks = create_mask_from_bbox(image, bboxes)
example = Image.fromarray(example_array)
preview = Image.fromarray(preview_array)
return PredictOutput(bboxes=bboxes, masks=masks, example=example)
return PredictOutput(bboxes=bboxes, masks=masks, preview=preview)

View File

@@ -23,8 +23,8 @@ def ultralytics_predict(
return PredictOutput()
masks = create_mask_from_bbox(image, bboxes)
example = pred[0].plot()
example = cv2.cvtColor(example, cv2.COLOR_BGR2RGB)
example = Image.fromarray(example)
preview = pred[0].plot()
preview = cv2.cvtColor(preview, cv2.COLOR_BGR2RGB)
preview = Image.fromarray(preview)
return PredictOutput(bboxes=bboxes, masks=masks, example=example)
return PredictOutput(bboxes=bboxes, masks=masks, preview=preview)