Heron0625 / PBT

20 stars 2 forks source link

请问作者是怎么保存推理结果图片的? #3

Open zoucap opened 4 hours ago

zoucap commented 4 hours ago

我在train.py里加了这么一段代码试图将原始图片和推理结果保存起来,但结果却是这样的

    if inffer:
        l = 0
        model.eval()
        with torch.inference_mode():
            for step,data in enumerate(val_data):
                images, labels = data
                labels[labels > 0] = 1
                labels = torch.Tensor(labels).long().to(device)
                pred = model(images.to(device))
                pred,labels=pred.cpu(),labels.cpu()

                for i in range(images.size(0)):
                    pilImage = to_pil_image(images[i])
                    pilInfer = to_pil_image(pred[i])

                    pilImage.save(f'{infferPredictPath}/1/image{l}.png')
                    pilInfer.save(f'{infferPredictPath}/1/infer{l}.png')

                    l += 1

        return

image0 infer0

zoucap commented 4 hours ago

我猜作者应该有一个保存推理结果的函数,但是没注释,我找不到。

Heron0625 commented 2 hours ago

请参考test.py