--- created: 2025-08-03 21:19:11 tags: - "Research" - "复现" - "MDMS" - "报错" - "评估" --- # eval_diffusion.py ```bash $ python eval_diffusion.py Using device: cuda Note: Currently supports evaluations (restoration) when run only on a single GPU! => using dataset 'lowlight' => evaluating lowlight test set... filepath:/home/student/MDMS/datasets Traceback (most recent call last): File "eval_diffusion.py", line 83, in main() File "eval_diffusion.py", line 73, in main _, val_loader = DATASET.get_loaders(parse_patches=False, validation=args.test_set) File "/home/student/MDMS/datasets/lowlight.py", line 21, in get_loaders train_dataset = lowlightDataset(dir=os.path.join(self.config.data.data_dir, 'data', 'lowlight', 'train'), File "/home/student/MDMS/datasets/lowlight.py", line 69, in __init__ assert len(images) == 485 AssertionError ``` - 主要是加了断言, 改一下`lowlight.py`里面的结构 ```python class lowlightDataset(torch.utils.data.Dataset): def __init__(self, dir, patch_size, n, transforms, train, filelist=None, parse_patches=True): super().__init__() if filelist is None: lowlight_dir = dir input_names, gt_names = [], [] filepath = os.path.dirname(__file__) print(f"filepath:{filepath}") lowlight_dir = os.path.join(filepath, lowlight_dir) # lowlight train filelist lowlight_inputs = os.path.join(lowlight_dir, 'input') # 确保目录存在 if not os.path.exists(lowlight_inputs): os.makedirs(lowlight_inputs, exist_ok=True) print(f"Created directory: {lowlight_inputs}") images = [f for f in listdir(lowlight_inputs) if isfile(os.path.join(lowlight_inputs, f))] # 移除断言检查,改为打印信息 print(f"Found {len(images)} images in {lowlight_inputs}") input_names += [os.path.join(lowlight_inputs, i) for i in images] gt_names += [os.path.join(os.path.join(lowlight_dir, 'gt'), i) for i in images] print(f"Number of input images: {len(input_names)}") if len(images) == 0: raise RuntimeError(f"No images found in {lowlight_inputs}. Please ensure the dataset is properly set up.") x = list(enumerate(input_names)) random.shuffle(x) indices, input_names = zip(*x) gt_names = [gt_names[idx] for idx in indices] self.dir = None else: self.dir = dir filepath = os.path.dirname(__file__) dir = os.path.join(filepath, dir) train_list = os.path.join(dir, filelist) with open(train_list) as f: contents = f.readlines() input_names = [i.strip() for i in contents] gt_names = [i.strip().replace('input', 'gt') for i in input_names] self.input_names = input_names self.gt_names = gt_names self.patch_size = patch_size self.transforms = transforms self.n = n self.parse_patches = parse_patches self.batchnum = 0 self.batchsize = 1 self.train=train ``` - 刚改完又出问题... ```bash $ python eval_diffusion.py Using device: cuda Note: Currently supports evaluations (restoration) when run only on a single GPU! => using dataset 'lowlight' => evaluating lowlight test set... filepath:/home/student/MDMS/datasets Found 15 images in /home/student/MDMS/datasets/scratch/LLIE/data/lowlight/train/input Number of input images: 15 => creating denoising-diffusion model with wrapper... parameters: 213,144,003 Pre-trained diffusion model path is missing! Traceback (most recent call last): File "eval_diffusion.py", line 83, in main() File "eval_diffusion.py", line 79, in main model.restore(val_loader, validation=args.test_set, r=args.grid_r,use_align=True) File "/home/student/MDMS/models/restoration.py", line 34, in restore for i, (x, y,wd,ht) in enumerate(val_loader): File "/home/student/.conda/envs/MDMS/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 521, in __next__ data = self._next_data() File "/home/student/.conda/envs/MDMS/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 561, in _next_data data = self._dataset_fetcher.fetch(index) # may raise StopIteration File "/home/student/.conda/envs/MDMS/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 49, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "/home/student/.conda/envs/MDMS/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 49, in data = [self.dataset[idx] for idx in possibly_batched_index] File "/home/student/MDMS/datasets/lowlight.py", line 208, in __getitem__ res = self.get_images(index) File "/home/student/MDMS/datasets/lowlight.py", line 202, in get_images input_img = input_img.resize((wd_new, ht_new), PIL.Image.ANTIALIAS) AttributeError: module 'PIL.Image' has no attribute 'ANTIALIAS' ```