Browse Source
Update
Signed-off-by: Jael Gu <mengjia.gu@zilliz.com>
test
1 changed files with
2 additions and
3 deletions
-
timm_image.py
|
|
@ -57,7 +57,7 @@ class TimmImage(NNOperator): |
|
|
|
def __call__(self, img: numpy.ndarray) -> numpy.ndarray: |
|
|
|
if hasattr(img, 'mode'): |
|
|
|
if img.mode not in ['RGB', 'BGR']: |
|
|
|
log.error(f'Invalid image mode: expect "RGB" but receive "{img.mode}".') |
|
|
|
log.error(f'Invalid image mode: expect "RGB" or "BGR" but receive "{img.mode}".') |
|
|
|
raise AssertionError(f'Invalid image mode "{img.mode}".') |
|
|
|
elif img.mode == 'BGR': |
|
|
|
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) |
|
|
@ -79,14 +79,13 @@ class TimmImage(NNOperator): |
|
|
|
|
|
|
|
|
|
|
|
# if __name__ == '__main__': |
|
|
|
# import cv2 |
|
|
|
# from towhee._types import Image |
|
|
|
# |
|
|
|
# |
|
|
|
# path = '/path/to/image' |
|
|
|
# img = cv2.imread(path) |
|
|
|
# img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) |
|
|
|
# img = Image(img, 'RGB') |
|
|
|
# img = Image(img) |
|
|
|
# |
|
|
|
# op = TimmImage('resnet50') |
|
|
|
# out = op(img) |
|
|
|