File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file.
88
99- Update ModelAPI configuration(< https://github.com/openvinotoolkit/training_extensions/pull/2564 > )
1010- Add Anomaly modelAPI changes (< https://github.com/openvinotoolkit/training_extensions/pull/2563 > )
11+ - Update Image numpy access (< https://github.com/openvinotoolkit/training_extensions/pull/2586 > )
1112
1213### Bug fixes
1314
Original file line number Diff line number Diff line change 1010import cv2
1111import imagesize
1212import numpy as np
13+ from PIL import Image as PILImage
1314
1415from otx .api .entities .annotation import Annotation
1516from otx .api .entities .media import IMedia2DEntity
@@ -91,7 +92,12 @@ def numpy(self) -> np.ndarray:
9192 np.ndarray: NumPy representation of the image.
9293 """
9394 if self .__data is None :
94- return cv2 .cvtColor (cv2 .imread (self .__file_path ), cv2 .COLOR_BGR2RGB )
95+ try :
96+ image = PILImage .open (self .__file_path )
97+ image = np .asarray (image .convert ("RGB" ))
98+ except ValueError :
99+ image = cv2 .cvtColor (cv2 .imread (self .__file_path ), cv2 .COLOR_BGR2RGB )
100+ return image
95101 if callable (self .__data ):
96102 return self .__data ()
97103 return self .__data
You can’t perform that action at this time.
0 commit comments