Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow decode method for images tensor in mmseg #2900

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions deeplake/integrations/mmseg/mmseg_.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,16 +155,15 @@
import warnings
import torch
import numpy as np
import os
import io

Check warning on line 158 in deeplake/integrations/mmseg/mmseg_.py

View check run for this annotation

Codecov / codecov/patch

deeplake/integrations/mmseg/mmseg_.py#L158

Added line #L158 was not covered by tests
import math
import types
import tempfile
from functools import partial
from collections import OrderedDict

from typing import Callable, Optional, List, Dict
from prettytable import PrettyTable # type: ignore
from PIL import Image, ImageDraw # type: ignore
from PIL import Image # type: ignore

Check warning on line 166 in deeplake/integrations/mmseg/mmseg_.py

View check run for this annotation

Codecov / codecov/patch

deeplake/integrations/mmseg/mmseg_.py#L166

Added line #L166 was not covered by tests

from mmseg.core import DistEvalHook, EvalHook # type: ignore
from mmseg.core import build_optimizer
Expand Down Expand Up @@ -438,7 +437,9 @@
pipeline: Callable,
):
img = sample_in[images_tensor]
if not isinstance(img, np.ndarray):
if isinstance(img, (bytes, bytearray)):
img = np.array(Image.open(io.BytesIO(img)))
elif not isinstance(img, np.ndarray):

Check warning on line 442 in deeplake/integrations/mmseg/mmseg_.py

View check run for this annotation

Codecov / codecov/patch

deeplake/integrations/mmseg/mmseg_.py#L440-L442

Added lines #L440 - L442 were not covered by tests
img = np.array(img)

mask = sample_in[masks_tensor]
Expand Down Expand Up @@ -899,7 +900,9 @@

collate_fn = partial(collate, samples_per_gpu=batch_size)

decode_method = {images_tensor: "numpy"}
decode_method = train_loader_config.get("decode_method") or {

Check warning on line 903 in deeplake/integrations/mmseg/mmseg_.py

View check run for this annotation

Codecov / codecov/patch

deeplake/integrations/mmseg/mmseg_.py#L903

Added line #L903 was not covered by tests
"images_tensor": "numpy"
}

mmseg_ds = MMSegDataset(
dataset=dataset,
Expand Down
Loading