From 2f2880260128f1680e33e43f473190687ce0a78c Mon Sep 17 00:00:00 2001 From: wxywb Date: Fri, 8 Apr 2022 16:06:20 +0800 Subject: [PATCH] update. Signed-off-by: wxywb --- __init__.py | 2 +- image_crop_cv2.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/__init__.py b/__init__.py index e0001d4..e206c90 100644 --- a/__init__.py +++ b/__init__.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from .image_crop_cv2 import ImageDecodeCV2 +from .image_crop_cv2 import ImageCropCV2 # The factory method diff --git a/image_crop_cv2.py b/image_crop_cv2.py index eb0e9c6..6eca7a9 100644 --- a/image_crop_cv2.py +++ b/image_crop_cv2.py @@ -17,7 +17,7 @@ import logging import cv2 import requests import numpy as np -from typing import List +from typing import List, Tuple from towhee import register from towhee.operator import PyOperator, OperatorFlag @@ -29,14 +29,14 @@ log = logging.getLogger() @register(output_schema=['img'], flag=OperatorFlag.STATELESS | OperatorFlag.REUSEABLE) class ImageCropCV2(PyOperator): - def __init__(self, clamp = False) + def __init__(self, clamp = False): self.clamp = clamp @staticmethod - def _clamp(x, minimum, maximum) + def _clamp(x, minimum, maximum): return max(minimum, min(x, maximum)) - def __call__(self, img: np.ndarray, bboxes: List[(int, int, int, int)]): + def __call__(self, img: np.ndarray, bboxes: List[Tuple]): h, w, _ = img.shape res = [] for box in bboxes: @@ -45,6 +45,6 @@ class ImageCropCV2(PyOperator): x2 = ImageCropCV2._clamp(x2, 0, w) y1 = ImageCropCV2._clamp(y1, 0, h) y2 = ImageCropCV2._clamp(y2, 0, h) - res.append(Image[y1:y2,x1:x2,:]) + res.append(img[y1:y2,x1:x2,:]) return res