Skip to content

Commit

Permalink
bugfix: DecodeImage
Browse files Browse the repository at this point in the history
  • Loading branch information
flytocc committed Mar 1, 2023
1 parent 995c8b2 commit 4da55fe
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ppcls/data/preprocess/ops/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def __call__(self, img):
elif isinstance(img, bytes):
if self.backend == "pil":
data = io.BytesIO(img)
img = Image.open(data)
img = Image.open(data).convert("RGB")
else:
data = np.frombuffer(img, dtype="uint8")
img = cv2.imdecode(data, 1)
Expand All @@ -197,7 +197,7 @@ def __call__(self, img):

if self.to_np:
if self.backend == "pil":
assert img.mode == "RGB", f"invalid shape of image[{img.shape}]"
assert img.mode == "RGB", f"invalid mode of image[{img.mode}]"
img = np.asarray(img)[:, :, ::-1] # BRG

if self.to_rgb:
Expand Down Expand Up @@ -742,8 +742,8 @@ def _parse_fill(self, fill, img, min_pil_version, name="fillcolor"):
# Process fill color for affine transforms
major_found, minor_found = (int(v)
for v in PILLOW_VERSION.split('.')[:2])
major_required, minor_required = (int(v) for v in
min_pil_version.split('.')[:2])
major_required, minor_required = (
int(v) for v in min_pil_version.split('.')[:2])
if major_found < major_required or (major_found == major_required and
minor_found < minor_required):
if fill is None:
Expand Down

0 comments on commit 4da55fe

Please sign in to comment.