Pytorch-UNet icon indicating copy to clipboard operation
Pytorch-UNet copied to clipboard

a problem in predict.py

Open chendsome opened this issue 3 years ago • 2 comments

Hi,i have a problem,i use VOC segmentation dataset to train a 21 classes net,but i meet the bellow problem。in predict.py i change the ‘n_classes=21’。Look forward to your reply Traceback (most recent call last): File "predict.py", line 124, in mask = predict_img(net=net, File "predict.py", line 44, in predict_img full_mask = tf(probs.cpu()).squeeze() File "D:\software\anaconda3\envs\yolov5\lib\site-packages\torchvision\transforms\transforms.py", line 61, in call img = t(img) File "D:\software\anaconda3\envs\yolov5\lib\site-packages\torchvision\transforms\transforms.py", line 184, in call return F.to_pil_image(pic, self.mode) File "D:\software\anaconda3\envs\yolov5\lib\site-packages\torchvision\transforms\functional.py", line 243, in to_pil_image raise ValueError('pic should not have > 4 channels. Got {} channels.'.format(pic.shape[-3])) ValueError: pic should not have > 4 channels. Got 21 channels.

chendsome avatar Dec 09 '22 10:12 chendsome

maybe i need to write script for multiple predict...

chendsome avatar Dec 09 '22 10:12 chendsome

Hi, can you try the latest master? I pushed a fix

milesial avatar Dec 09 '22 14:12 milesial