PhotorealismEnhancement
PhotorealismEnhancement copied to clipboard
ValueError when saving model
I followed through the whole workflow with little trouble and after setting everything up I'm getting this error upon saving the model before training starts.
2022-11-09 17:15:04,408 Saving model to savegames/pfd2cs_ie2-0-break.
2022-11-09 17:15:07,098 Unexpected error: <class 'ValueError'>
Traceback (most recent call last):
File "code/epe/EPEExperiment.py", line 390, in <module>
experiment.run()
File "/mnt/b/Dev/cv-gta/code/epe/experiment/BaseExperiment.py", line 636, in run
self.__getattribute__(self.action)()
File "/mnt/b/Dev/cv-gta/code/epe/experiment/BaseExperiment.py", line 543, in train
for batch in self.loader:
File "/home/chanka/anaconda3/envs/torch/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 628, in __next__
data = self._next_data()
File "/home/chanka/anaconda3/envs/torch/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1333, in _next_data
return self._process_data(data)
File "/home/chanka/anaconda3/envs/torch/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1359, in _process_data
data.reraise()
File "/home/chanka/anaconda3/envs/torch/lib/python3.8/site-packages/torch/_utils.py", line 543, in reraise
raise exception
ValueError: Caught ValueError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "/home/chanka/anaconda3/envs/torch/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py", line 302, in _worker_loop
data = fetcher.fetch(index)
File "/home/chanka/anaconda3/envs/torch/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 58, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/home/chanka/anaconda3/envs/torch/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 58, in <listcomp>
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/mnt/b/Dev/cv-gta/code/epe/matching/paired.py", line 108, in __getitem__
idx = np.min(np.nonzero(p<self._cumsum)[0])
File "<__array_function__ internals>", line 180, in amin
File "/home/chanka/anaconda3/envs/torch/lib/python3.8/site-packages/numpy/core/fromnumeric.py", line 2918, in amin
return _wrapreduction(a, np.minimum, 'min', axis, None, out,
File "/home/chanka/anaconda3/envs/torch/lib/python3.8/site-packages/numpy/core/fromnumeric.py", line 86, in _wrapreduction
return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
ValueError: zero-size array to reduction operation minimum which has no identity
Help would be appreciated.
Correction: The exception happens before the model is saved. Saving is part of a try: except:
. The error occurs at
File "/mnt/b/Dev/cv-gta/code/epe/matching/paired.py", line 108, in __getitem__
idx = np.min(np.nonzero(p<self._cumsum)[0])
When you call compute_weights script before the training
python epe/matching/compute_weights.py matched_crops_PfD-Cityscapes.csv 526 957 crop_weights_PfD-Cityscapes.npz
please make sure that you have put height and width in the right order: (height, width).
For example, for fullHD it will be 1080 1920
.
I've got exactly same issue when I called this script with the wrong w,h order. Also, print some resulting weights and check does they look ok (not nans etc.)
hallo Chanka, so nice that you already at training step. i have however question at step matchong patches across dataset: python epe/matching/feature_based/collect_crops.py PfD pfd_files.csv
i have result num_sample = 0 at dataset, in the collect_crops.py there is command: dataset = ImageDataset(args.name, read_filelist(args.img_list, 1, False)) and at returns 0, thats why the script cannot go further and returns the error
i inspect line per line, the function read_filelist is okay. so my problem is in the class ImageDataset i dont know if the problem is how i created the csv file. i made a csv file just for trying, it consists only 5 lines: /Home/PEcon2/PfD/01_images/images/00001.png /Home/PEcon2/PfD/01_images/images/00002.png /Home/PEcon2/PfD/01_images/images/00003.png /Home/PEcon2/PfD/01_images/images/00004.png /Home/PEcon2/PfD/01_images/images/00005.png
can u please tell me how your step by step? thank you :)