Git Product home page Git Product logo

Comments (14)

yassouali avatar yassouali commented on September 12, 2024

Hi,

I've never encountered this problem, are you using torch 1.1.0 ? did you see if the script works in a new env ? I think there is some problem with the packages.

from pytorch-segmentation.

yassouali avatar yassouali commented on September 12, 2024

Hi, I think the problem lies in the data type of the labels, can you check the type of your labels, there must be some error when loading the labels, can you post the code you use for loading them.

from pytorch-segmentation.

rurubaobao avatar rurubaobao commented on September 12, 2024

Hello, I'm using voc data. When I tested on ubuntu, it worked fine, but when I tested on Windows, I had the above problem.I was wondering if you've ever tested Windows?

from pytorch-segmentation.

yassouali avatar yassouali commented on September 12, 2024

No not in windows unfortunately, maybe the numpy version is not the correct one (or torch), sadly I am not seeing the cause of the error, try loading some labels manually in a python shell / jupyter using the code in voc.py and base_dataset.py and see if you can find the root cause.

from pytorch-segmentation.

yassouali avatar yassouali commented on September 12, 2024

You need to create your dataloader, like the ones provided in dataloaders/, you'll need to implement two function _set_files: sets the file paths for the labels and the images, and _load_data loads the labels and images given an index.

And then create a loader and with the correct parameters (num classes = 2 for instance) and then change the config file and you're done.

from pytorch-segmentation.

rurubaobao avatar rurubaobao commented on September 12, 2024

Thank you, I have implemented it, however, I have a problem with the program when I replace Crossentropy with DiceLoss.
Traceback (most recent call last):
File "C:/Users/lenovo/PycharmProjects/fr/pytorch_segmentation-master/train.py", line 61, in
main(config, args.resume)
File "C:/Users/lenovo/PycharmProjects/fr/pytorch_segmentation-master/train.py", line 30, in main
loss = getattr(losses, config['loss'])(ignore_index = config['ignore_index'])
TypeError: init() got an unexpected keyword argument 'ignore_index'

By the way, my numclass is 2, do I need to modify the following function?

palette.py
def get_voc_palette(num_classes):
n = num_classes
palette = [0](n3)
for j in range(0,n):
lab = j
palette[j3+0] = 0
palette[j
3+1] = 0
palette[j3+2] = 0
i = 0
while (lab > 0):
palette[j
3+0] |= (((lab >> 0) & 1) << (7-i))
palette[j3+1] |= (((lab >> 1) & 1) << (7-i))
palette[j
3+2] |= (((lab >> 2) & 1) << (7-i))
i = i + 1
lab >>= 3
return palette

from pytorch-segmentation.

yassouali avatar yassouali commented on September 12, 2024

Just remove the ignore_index, given that dice loss in utils\losses.py doesn't take as input argument ignore_index, for the function creating the palette, you don't need to change it, unless you already have a specific palette you want to use

from pytorch-segmentation.

rurubaobao avatar rurubaobao commented on September 12, 2024

when I remove the ignore_index, I have another problem

Traceback (most recent call last):
File "C:/Users/lenovo/PycharmProjects/fr/pytorch_segmentation-master/train.py", line 61, in
main(config, args.resume)
File "C:/Users/lenovo/PycharmProjects/fr/pytorch_segmentation-master/train.py", line 40, in main
train_logger=train_logger)
File "C:\Users\lenovo\PycharmProjects\fr\pytorch_segmentation-master\trainer.py", line 14, in init
super(Trainer, self).init(model, loss, resume, config, train_loader, val_loader, train_logger)
File "C:\Users\lenovo\PycharmProjects\fr\pytorch_segmentation-master\base\base_trainer.py", line 35, in init
self.loss.to(self.device)
File "C:\Users\lenovo\AppData\Local\conda\conda\envs\fr\lib\site-packages\torch\nn\modules\module.py", line 386, in to
return self._apply(convert)
AttributeError: 'torch.device' object has no attribute '_apply'

from pytorch-segmentation.

yassouali avatar yassouali commented on September 12, 2024

I just took a look, there is indeed a problem with the loss when the ignore index is say 255, the one hot target is of different size than the output, which triggers a device error.

Just pushed a simple correction, might need to fix it for good with gradient stopping, but for now it works, this time don't remove ignore index.

from pytorch-segmentation.

yassouali avatar yassouali commented on September 12, 2024

Did you create you own dataloader, with the correct paths (for example for VOC, the images are in VOCdevkit/VOC2012/JPEGImages and the labels in VOCdevkit/VOC2012/SegmentationClass) you need to adjust the variables for you dataset.

from pytorch-segmentation.

yassouali avatar yassouali commented on September 12, 2024

For the number of classes, there is a class attribute in class VOCDataset called self.num_classes, set it to 2, other that that you're good to go (you might also want to calculate the mean and std of your dataset, but you can do it afterwards)

from pytorch-segmentation.

rurubaobao avatar rurubaobao commented on September 12, 2024

OK,Thanks.

from pytorch-segmentation.

Erichen911 avatar Erichen911 commented on September 12, 2024

Hello, recently I meet the same problem like yours.My research is extremely same as your research.I use the same model ,the same loss function,And it's also a two class segmentation.My problem is the same as yours.Even if the losses keep going down,but the Pixel_acc and mean_Iou didn't change from 5th epoch to 50th epoch.The evaluation didn't change too much.I don't know why.Could you tell is this a bug of code or I do something wrong ?
Waiting for your reply.Thank you!

from pytorch-segmentation.

rurubaobao avatar rurubaobao commented on September 12, 2024

Hello, I just saw it recently. Have you solved this problem?

from pytorch-segmentation.

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.