Giter VIP home page Giter VIP logo

Comments (9)

bodokaiser avatar bodokaiser commented on June 27, 2024

Hi Andrew,

Can you change in main.py

if args.cuda:
    criterion = CrossEntropyLoss2d(weight.cuda())
else:
    criterion = CrossEntropyLoss2d(weight)

to

criterion = CrossEntropyLoss2d()

also you might want to read this for binary segmentation.

from piwise.

andrewssobral avatar andrewssobral commented on June 27, 2024

Thank you @bodokaiser !

from piwise.

andrewssobral avatar andrewssobral commented on June 27, 2024

Hi @bodokaiser again,
Just a small question, why the number of class is defined as 22 if PascalVoc has 20 classes?

from piwise.

bodokaiser avatar bodokaiser commented on June 27, 2024

I think VOC before 2012 had less classes, however according to segmentation examples

pixel indices correspond to classes in alphabetical order (1=aeroplane, 2=bicycle, 3=bird, 4=boat, 5=bottle, 6=bus, 7=car , 8=cat, 9=chair, 10=cow, 11=diningtable, 12=dog, 13=horse, 14=motorbike, 15=person, 16=potted plant, 17=sheep, 18=sofa, 19=train, 20=tv/monitor)
For both types of segmentation image, index 0 corresponds to background and index 255 corresponds to 'void' or unlabelled.

from piwise.

andrewssobral avatar andrewssobral commented on June 27, 2024

Thank you @bodokaiser !
So, if I have only 2 classes on my dataset (0 = background, 255 = foreground), I need to set NUM_CLASSES = 2 ?

from piwise.

bodokaiser avatar bodokaiser commented on June 27, 2024

NUM_CLASSES = 2 basically just says how much output channels to use in the last layer(s) of the chosen network architecture.

There is also another VOC specific transform which convert the color codes of the VOC images to class labels numbered from 1 to 22 so you might want to change this according to your dataset.

from piwise.

andrewssobral avatar andrewssobral commented on June 27, 2024

Solved!

from piwise.

numancelik34 avatar numancelik34 commented on June 27, 2024

I am trying to solve a binary mask segmentation as well for my dataset in this VOC format.. however getting a NaN value for segmentation loss.. could you please help me here??
Thanks!

from piwise.

andrewssobral avatar andrewssobral commented on June 27, 2024

Hello @numancelik34 ,
I am sorry for the late reply, and thank you for the contact!
Yes, my solution for this issue can be found here:
https://github.com/andrewssobral/deep-learning-pytorch/tree/master/segmentation
I created a git repository with some codes showing how to do binary segmentation with pytorch.
Please, let me know if it helps you, and feel free to contact me if you have any questions.
Best regards,
Andrews

from piwise.

Related Issues (20)

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.