Tramac / Lightweight-Segmentation

Lightweight models for real-time semantic segmentation(include mobilenetv1-v3, shufflenetv1-v2, igcv3, efficientnet).
Apache License 2.0
356 stars 77 forks source link

我想知道验证的时候如何获取对应的图片名称?我一直获取不到 #12

Open mei123hao opened 5 years ago

mei123hao commented 5 years ago
    for i, (image, target) in enumerate(self.val_loader):
        image = image.to(self.device)
        target = target.to(self.device)

        with torch.no_grad():
            outputs = model(image)
        self.metric.update(outputs[0], target)
        pixAcc, mIoU = self.metric.get()
        logger.info("Sample: {:d}, validation pixAcc: {:.3f}, mIoU: {:.3f}".format(
            i + 1, pixAcc * 100, mIoU * 100))

        if self.args.save_pred:
            pred = torch.argmax(outputs[0], 1)
            pred = pred.cpu().data.numpy()

            predict = pred.squeeze(0)
            mask = get_color_pallete(predict, self.args.dataset)
            mask.save(os.path.join(outdir,  str(i) + '.png'))
    synchronize()

就这一段代码里面,原来for循环里面不是有一个filename的吗?然后他总是报错。后来我就迫不得已把他删掉, mask.save(os.path.join(outdir, str(i) + '.png'))改成用i循环命名的方法?有什么办法可以解决吗?求助了!

mei123hao commented 5 years ago

2019-11-23 22:45:28,078 mobilenetv3_large INFO: Start validation, Total sample: 500 Traceback (most recent call last): File "eval.py", line 108, in evaluator.eval() File "eval.py", line 60, in eval for i, (image, target, filename) in enumerate(self.val_loader): ValueError: not enough values to unpack (expected 3, got 2) 现在他一运行总是报这个错误

Tramac commented 4 years ago

Please check the dataloader script.