Luchixiang / EMDiffuse

MIT License
27 stars 1 forks source link

Some name errors report and require help. #1

Closed mofatuzi closed 9 months ago

mofatuzi commented 9 months ago
  1. In the readme.md, [Dependency] pip install -r requirements.txt, "requirments" spell wrong.
  2. I am testing my tif, and findout that images folder name should be number, not letter. If name the folder by letter, it will show error. (emdiffuse) PS C:\Users\GD\EMDiffuse-master> python crop_single_file.py --path ./testem --task denoise (emdiffuse) PS C:\Users\GD\EMDiffuse-master> python run.py -p test -c config/EMDiffuse-n.json -g 0 -b 60 --path ./testem/denoise_test_crop_patches export CUDA_VISIBLE_DEVICES=0 run.py:28: UserWarning: You have chosen to use cudnn for accleration. torch.backends.cudnn.enabled=True warnings.warn('You have chosen to use cudnn for accleration. torch.backends.cudnn.enabled=True') {'data_root': './testem/denoise_test_crop_patches', 'norm': True, 'percent': False, 'phase': 'val'} in dataset: ./testem/denoise_test_crop_patches val network norm: True Traceback (most recent call last): File "run.py", line 97, in <module> main_worker(0, 1, opt) File "run.py", line 60, in main_worker model.test() File "C:\Users\GD\EMDiffuse-master\models\EMDiffuse_model.py", line 183, in test for phase_data in self.phase_loader: File "C:\Users\GD\anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 517, in __next__ data = self._next_data() File "C:\Users\GD\anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 1199, in _next_data return self._process_data(data) File "C:\Users\GD\anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 1225, in _process_data data.reraise() File "C:\Users\GD\anaconda3\lib\site-packages\torch\_utils.py", line 429, in reraise raise self.exc_type(msg) ValueError: Caught ValueError in DataLoader worker process 0. Original Traceback (most recent call last): File "C:\Users\GD\anaconda3\lib\site-packages\torch\utils\data\_utils\worker.py", line 202, in _worker_loop data = fetcher.fetch(index) File "C:\Users\GD\anaconda3\lib\site-packages\torch\utils\data\_utils\fetch.py", line 44, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "C:\Users\GD\anaconda3\lib\site-packages\torch\utils\data\_utils\fetch.py", line 44, in <listcomp> data = [self.dataset[idx] for idx in possibly_batched_index] File "C:\Users\GD\EMDiffuse-master\data\dataset.py", line 72, in __getitem__ ret['noise_level'] = torch.tensor([int(file_name.split('/')[-2].split('_')[-1])]) ValueError: invalid literal for int() with base 10: 'testem'
  3. When I modified the folder name into "123", it works. And running, but when it finished, shows save image name error. How to solve this? `(emdiffuse) PS C:\Users\GD\EMDiffuse-master> python crop_single_file.py --path ./123 --task denoise (emdiffuse) PS C:\Users\GD\EMDiffuse-master> python run.py -p test -c config/EMDiffuse-n.json -g 0 -b 60 --path ./123/denoise_test_crop_patches export CUDA_VISIBLE_DEVICES=0 run.py:28: UserWarning: You have chosen to use cudnn for accleration. torch.backends.cudnn.enabled=True warnings.warn('You have chosen to use cudnn for accleration. torch.backends.cudnn.enabled=True') {'data_root': './123/denoise_test_crop_patches', 'norm': True, 'percent': False, 'phase': 'val'} in dataset: ./123/denoise_test_crop_patches val network norm: True sampling loop time step: 100%|█████████████████████████████████████████████████████| 1000/1000 [30:05<00:00, 1.81s/it] sampling loop time step: 100%|█████████████████████████████████████████████████████| 1000/1000 [29:57<00:00, 1.80s/it] Traceback (most recent call last): File "C:\Users\GD\EMDiffuse-master\core\logger.py", line 114, in save_images Image.fromarray(outputs[i]).save(os.path.join(result_path, names[i])) File "C:\Users\GD\anaconda3\lib\site-packages\PIL\Image.py", line 2209, in save fp = builtins.open(filename, "w+b") FileNotFoundError: [Errno 2] No such file or directory: 'experiments\test_EMDiffuse-n_231020145939\results\test\0\GT._123_denoise_test_crop_patches\image1\0\0_0.tif'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "run.py", line 97, in main_worker(0, 1, opt) File "run.py", line 60, in main_worker model.test() File "C:\Users\GD\EMDiffuse-master\models\EMDiffuse_model.py", line 200, in test self.writer.save_images(self.save_current_results(), norm=self.opt['norm']) File "C:\Users\GD\EMDiffuse-master\core\logger.py", line 126, in save_images raise NotImplementedError('You must specify the context of name and result in save_current_results functions of model.') NotImplementedError: You must specify the context of name and result in save_current_results functions of model.`

Luchixiang commented 9 months ago

Hi !

  1. Thank you for your correction
  2. Can you show the name of your image? I'm wondering whether it has '/' in the image name, which will make the computer think it's the folder
  3. I find that your inference time is long. What's your image size and how many images do you have under the folder '123'
mofatuzi commented 9 months ago

The image name is "image1", only 1 image. The image size is 1024*1056, 1.7M. My compute card is Quadro P1000, with only 4G memory. folder

Luchixiang commented 9 months ago

I can't reproduce the error on my computer. I created a new folder named 123 and put an image called 'image1.tif' in the folder. It runs successfully. Can I have a look at your cropped folder and the name of the cropped images?

image
hmzawz2 commented 1 month ago

Hi! Recently I want to try vEM-i on testing vEM data, and I have met same problem as @mofatuzi (although I use vEMDiffuse-i instead of denoise). To solve upper problem, I have changed some code in dataset.py-class vEMDiffuseTestAnIsotropic:

    def read_dataset(self, data_root):
        # Previous
        # import os

        # z_depth = find_max_folder_number(data_root)
        # gt_paths = []
        # below_paths = []
        # for i in range(0, z_depth):
        #     for file in os.listdir(os.path.join(data_root, str(i))):
        #         gt_paths.append(os.path.join(data_root, str(i), file))
        #         below_paths.append(os.path.join(data_root, str(i + 1), file))
        #         # below_paths.append(os.path.join(data_root, str(i + 1), file))

        # My change
        from pathlib import Path

        gt_paths = list(Path(data_root).glob("*.tif"))
        below_paths = list(Path(data_root).glob("*.tif"))
        gt_paths = [str(p) for p in gt_paths]
        below_paths = [str(p) for p in below_paths]

        return gt_paths[:-1], below_paths[1:]

Although upper code can only deal with very simple and small dataset (like, gt_path and below_path are not sorted, and output image seems saved with folder name '0'), but it now works on my computer. I think it may work on others computer.

Best wishes!

BTW, my folder and images are like:


EMDiffuse_val
          |----  0.tif
          |----  1.tif
``