Skip to content

Commit

Permalink
Merge pull request #2900 from activeloopai/decode_method
Browse files Browse the repository at this point in the history
allow decode method for images tensor in mmseg
  • Loading branch information
activesoull authored Jul 10, 2024
2 parents 1fb3ff0 + bc87e38 commit cd1fbf3
Showing 1 changed file with 8 additions and 5 deletions.
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
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

from mmseg.core import DistEvalHook, EvalHook # type: ignore
from mmseg.core import build_optimizer
Expand Down Expand Up @@ -438,7 +437,9 @@ def transform(
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):
img = np.array(img)

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

collate_fn = partial(collate, samples_per_gpu=batch_size)

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

mmseg_ds = MMSegDataset(
dataset=dataset,
Expand Down

0 comments on commit cd1fbf3

Please sign in to comment.