@@ -32,10 +32,6 @@ class BaseCVResult(BaseResult, StrMixin, JsonMixin, ImgMixin):
Raises:
AssertionError: If the required key (`BaseCVResult.INPUT_IMG_KEY`) are not found in the data.
"""
- assert (
- BaseCVResult.INPUT_IMG_KEY in data
- ), f"`{BaseCVResult.INPUT_IMG_KEY}` is needed, but not found in `{list(data.keys())}`!"
- self._input_img = data.pop("input_img", None)
self._img_writer = ImageWriter(backend="pillow")
super().__init__(data)
@@ -37,7 +37,7 @@ class FormulaRecResult(BaseCVResult):
self,
):
"""Draw formula on image"""
- image = Image.fromarray(self._input_img)
+ image = Image.fromarray(self["input_img"])
try:
env_valid()
except subprocess.CalledProcessError as e:
@@ -29,7 +29,7 @@ class TopkResult(BaseCVResult):
labels = self.get("label_names", self["class_ids"])
label_str = f"{labels[0]} {self['scores'][0]:.2f}"
image_size = image.size
draw = ImageDraw.Draw(image)
min_font_size = int(image_size[0] * 0.02)
@@ -21,5 +21,5 @@ class IdentityResult(BaseCVResult):
def _to_img(self):
"""This module does not support visualization; it simply outputs the input images"""
return image
@@ -25,7 +25,7 @@ from ...common.result import BaseCVResult
class MLClassResult(BaseCVResult):
"""Draw label on image"""
label_names = self["label_names"]
scores = self["scores"]
image = image.convert("RGB")
@@ -137,7 +137,7 @@ class InstanceSegResult(BaseCVResult):
"""apply"""
# image = self._img_reader.read(self["input_path"])
ori_img_size = list(image.size)[::-1]
boxes = self["boxes"]
masks = self["masks"]
@@ -99,5 +99,5 @@ class DetResult(BaseCVResult):
def _to_img(self) -> Image.Image:
return draw_box(image, boxes)
@@ -26,7 +26,7 @@ class TextDetResult(BaseCVResult):
"""draw rectangle"""
boxes = self["dt_polys"]
- image = self._input_img
+ image = self["input_img"]
for box in boxes:
box = np.reshape(np.array(box).astype(int), [-1, 1, 2]).astype(np.int64)
cv2.polylines(image, [box], True, (0, 0, 255), 2)
@@ -23,7 +23,7 @@ class TextRecResult(BaseCVResult):
rec_text = self["rec_text"]
rec_score = self["rec_score"]