Skip to content

Commit 8ed43eb

Browse files
committed
Fix for "image closed" in get_image
1 parent 72903a5 commit 8ed43eb

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎src/SDK/Python/request_data.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,11 @@ def get_image(self, index : int, module: str = 'pil') -> "Union[Image, np.ndarra
174174
return cv.imdecode(np.frombuffer(img_bytes, dtype=np.uint8), cv.IMREAD_COLOR)
175175

176176
with io.BytesIO(img_bytes) as img_stream:
177+
# return Image.open(img_stream).convert("RGB")
178+
177179
img = Image.open(img_stream)
178-
# Only convert if it needs conversion
179-
return img if img.mode == 'RGB' else img.convert('RGB')
180+
# Only convert if it needs conversion. Otherwise we need to return a copy
181+
return img.copy() if img.mode == 'RGB' else img.convert('RGB')
180182

181183

182184
except Exception as ex:

0 commit comments

Comments
 (0)