DataAugmentation.jl icon indicating copy to clipboard operation
DataAugmentation.jl copied to clipboard

DataAugmentation error with masks

Open cirobr opened this issue 2 months ago • 4 comments

Cheers,

I’m receiving an error when augmenting masks prior to training a model for semantic segmentation. Consider img as RGB image matrix. Consider mask as a matrix with integer elements from 1 to 11. Code is as follows:

item1 = Image(img)
item2 = MaskMulti(mask)

tfm = Maybe(FlipX{2}()) |> Rotate(15) |> Zoom((1.0, 1.2)) |>
      AdjustBrightness(0.3) |> AdjustContrast(0.3) |>
      CenterCrop((256,256))
img_tf = apply(tfm, (item1, item2))

Error message as follows:

ERROR: MethodError: no method matching length(::DataAugmentation.MaskMulti{2, Int64, Int64})
The function `length` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  length(::LLVM.ArrayType)
   @ LLVM ~/.julia/packages/LLVM/iza6e/src/core/type.jl:343
  length(::DataStructures.EnumerateAll)
   @ DataStructures ~/.julia/packages/DataStructures/IrAJn/src/multi_dict.jl:96
  length(::LLVM.ConstantArray)
   @ LLVM ~/.julia/packages/LLVM/iza6e/src/core/value/constant.jl:421
  ...

The error disappears in the following conditions:

  1. If the transformation is restricted to the image only.
  2. If the transformation is applied to image and mask, but the command line corresponding to AdjustBrightness and AdjustContrast is commented out.

Thanks for advising.

cirobr avatar Nov 01 '25 08:11 cirobr