Giter Club home page Giter Club logo

Comments (7)

yswe avatar yswe commented on September 26, 2024 2

Hi @John1231983 , you can apply some small changes to your code simply defining a custom reading method and passing it to the ImageCollection class constructor. I've fixed it this way:

def _imread_mask(f):
    mask = skimage.io.imread(f)
    if len(mask.shape) > 2:
        mask = mask[:,:,0]
    return mask

...   

masks = skimage.io \
    .ImageCollection(masks_path, load_func = _imread_mask) \
    .concatenate()

from kaggle-dsbowl-2018-dataset-fixes.

ebouteillon avatar ebouteillon commented on September 26, 2024 1

I'm using imread and not imread_collection from skimage. That's probably why I don't have this problem. Two solutions:

  • Alter the images directly (and do a pull request :) ).
  • Don't use concatenate() and perform concatenation yourself after using the trick above

from kaggle-dsbowl-2018-dataset-fixes.

therahulkumar avatar therahulkumar commented on September 26, 2024

Hi @ebouteillon You can take the top layer of the mask (mask[:,:,0]), layers (0,1,2) has max pixel set for the mask.

from kaggle-dsbowl-2018-dataset-fixes.

ebouteillon avatar ebouteillon commented on September 26, 2024

Hi @PrinceRK , It is already what I am doing ;)
It is just a notice that these masks are not consistent with others (and the originals by the way).
Regards

from kaggle-dsbowl-2018-dataset-fixes.

John1231983 avatar John1231983 commented on September 26, 2024

@ebouteillon : How do you solve it? I am run the code to classify the dataset into 2 cluster but I got the error about masks mismatch dimension of these above ids. This is what I am doing


# Get image width, height and count masks available.
def read_image_labels(image_id, space="rgb"):
    image = read_image(image_id, space=space)
    mask_file = STAGE1_TRAIN_MASK_PATTERN.format(image_id)
    print (mask_file)
    
    masks = skimage.io.imread_collection(mask_file).concatenate()
    height, width, _ = image.shape
    num_masks = masks.shape[0]
    labels = np.zeros((height, width), np.uint16)
    for index in range(0, num_masks):
        labels[masks[index] > 0] = 255  # index + 1
    return image, labels, num_masks

from kaggle-dsbowl-2018-dataset-fixes.

ebouteillon avatar ebouteillon commented on September 26, 2024

Instead of using masks[index] directly, I'm using an intermediate object. Let's call it m, then it would give you something like:

m = masks[index]
if(len(m.shape) > 2):
    m = m[..., 0]

You may have to use np.squeeze too if the extra dimension annoys you.

from kaggle-dsbowl-2018-dataset-fixes.

John1231983 avatar John1231983 commented on September 26, 2024

Thanks for your solution. But the error come from the line

 masks = skimage.io.imread_collection(mask_file).concatenate()

from kaggle-dsbowl-2018-dataset-fixes.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.