vturrisi / solo-learn

solo-learn: a library of self-supervised methods for visual representation learning powered by Pytorch Lightning
MIT License
1.38k stars 181 forks source link

Custom data set usage issues #375

Closed Marrywithyou closed 7 months ago

Marrywithyou commented 7 months ago

First of all thank you very much for providing the code base, very useful I ran into a problem while working with custom datasets and reported the following error:【TypeError: An invalid dataloader was returned from PretrainDALIDataModule.val_dataloader(). Found None.】 Here is my configuration file boyl.yaml 【 data: dataset: "custom" train_path: "../datasets/fastMRI_png/new_data_50/train/10" format: "dali" # data format, supports "image_folder", "dali" or "h5" num_workers: 4 no_labels: True 】 I am using the command:【python3 main_pretrain.py --config-path scripts/pretrain/custom/ --config-name byol.yaml ++new_argument=VALUE】

Marrywithyou commented 7 months ago

This is the error log printed on the command line: /home/jupyter-huangxinhao/.local/lib/python3.9/site-packages/pytorch_lightning/loops/fit_loop.py:280: PossibleUserWarning: The number of training batches (6) is smaller than the logging interval Trainer(log_every_n_steps=50). Set a lower value for log_every_n_steps if you want to see logs for the training epoch. rank_zero_warn( Sanity Checking: 0it [00:00, ?it/s]Error executing job with overrides: ['++new_argument=VALUE'] Traceback (most recent call last): File "/home/jupyter-huangxinhao/.local/lib/python3.9/site-packages/pytorch_lightning/trainer/connectors/data_connector.py", line 383, in _check_dataloader_iterable iter(dataloader) # type: ignore[call-overload] TypeError: 'NoneType' object is not iterable

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/data2/hxh/SSL/solo-learn-main/main_pretrain.py", line 256, in main trainer.fit(model, ckpt_path=ckpt_path, datamodule=dali_datamodule) File "/home/jupyter-huangxinhao/.local/lib/python3.9/site-packages/pytorch_lightning/trainer/trainer.py", line 520, in fit call._call_and_handle_interrupt( File "/home/jupyter-huangxinhao/.local/lib/python3.9/site-packages/pytorch_lightning/trainer/call.py", line 42, in _call_and_handle_interrupt return trainer.strategy.launcher.launch(trainer_fn, *args, trainer=trainer, kwargs) File "/home/jupyter-huangxinhao/.local/lib/python3.9/site-packages/pytorch_lightning/strategies/launchers/subprocess_script.py", line 92, in launch return function(*args, *kwargs) File "/home/jupyter-huangxinhao/.local/lib/python3.9/site-packages/pytorch_lightning/trainer/trainer.py", line 559, in _fit_impl self._run(model, ckpt_path=ckpt_path) File "/home/jupyter-huangxinhao/.local/lib/python3.9/site-packages/pytorch_lightning/trainer/trainer.py", line 935, in _run results = self._run_stage() File "/home/jupyter-huangxinhao/.local/lib/python3.9/site-packages/pytorch_lightning/trainer/trainer.py", line 976, in _run_stage self._run_sanity_check() File "/home/jupyter-huangxinhao/.local/lib/python3.9/site-packages/pytorch_lightning/trainer/trainer.py", line 1005, in _run_sanity_check val_loop.run() File "/home/jupyter-huangxinhao/.local/lib/python3.9/site-packages/pytorch_lightning/loops/utilities.py", line 177, in _decorator return loop_run(self, args, kwargs) File "/home/jupyter-huangxinhao/.local/lib/python3.9/site-packages/pytorch_lightning/loops/evaluation_loop.py", line 98, in run self.setup_data() File "/home/jupyter-huangxinhao/.local/lib/python3.9/site-packages/pytorch_lightning/loops/evaluation_loop.py", line 168, in setup_data _check_dataloader_iterable(dl, source, trainer_fn) File "/home/jupyter-huangxinhao/.local/lib/python3.9/site-packages/pytorch_lightning/trainer/connectors/data_connector.py", line 399, in _check_dataloader_iterable raise TypeError( TypeError: An invalid dataloader was returned from PretrainDALIDataModule.val_dataloader(). Found None.

vturrisi commented 7 months ago

You can't use Dali in a dataset without labels. Only image_folder is supported.

Marrywithyou commented 7 months ago

Thank you very much for your reply. The problem has been solved