UNeXt-pytorch icon indicating copy to clipboard operation
UNeXt-pytorch copied to clipboard

sigmoid(): argument 'input' (position 1) must be Tensor, not numpy.ndarray

Open liuyx599 opened this issue 2 years ago • 1 comments

In post_process.py

 with torch.no_grad():
        for input, target, meta in tqdm(val_loader, total=len(val_loader)):
            input = input.cuda()
            target = target.cuda()
            model = model.cuda()
            # compute output

            if count<=5:
                start = time.time()
                if config['deep_supervision']:
                    output = model(input)[-1]
                else:
                    output = model(input)
                stop = time.time()

                gput.update(stop-start, input.size(0))

                start = time.time()
                model = model.cpu()
                input = input.cpu()
                output = model(input)
                stop = time.time()

                cput.update(stop-start, input.size(0))
                count=count+1

            iou,dice = iou_score(output, target)
            iou_avg_meter.update(iou, input.size(0))
            dice_avg_meter.update(dice, input.size(0))

            output = torch.sigmoid(output).cpu().numpy()   # error

I finished the training on BUSI and no error message was reported; then I verified in post_process.py and an error was reported when count exceeded 5. I found that output is only within the range of if, which means that when count exceeds 5, it does not feed input into the model to get output, so when the statement runs to output = torch.sigmoid(output).cpu().numpy() it generates an error?

liuyx599 avatar May 03 '22 14:05 liuyx599

Hello, I also encountered this problem, please do you solve it?

Zzs0720 avatar Sep 18 '22 07:09 Zzs0720

Hello, I also encountered the same problem, could you please solve the code?

demondemoliu avatar Dec 06 '22 04:12 demondemoliu

I did not use the postprocess.py; It was from the UNET++ code base upon which this code is built on.

jeya-maria-jose avatar Dec 21 '22 23:12 jeya-maria-jose