JoePenna/Dreambooth-Stable-Diffusion

num_samples should be a positive integer value, but got num_samples=0

carlospum opened this issue · 1 comments

In the training step i am having this all the times, i tried to change some options but nothing worked

This is what i got:

| Name | Type | Params

0 | model | DiffusionWrapper | 859 M
1 | first_stage_model | AutoencoderKL | 83.7 M
2 | cond_stage_model | FrozenCLIPEmbedder | 123 M

982 M Trainable params
83.7 M Non-trainable params
1.1 B Total params
4,264.941 Total estimated model params size (MB)
Sanity Checking: 0it [00:00, ?it/s]/workspace/stable-diffusion-webui/venv/lib/python3.10/site-packages/pytorch_lightning/trainer/connectors/data_connector.py:236: PossibleUserWarning: The dataloader, val_dataloader 0, does not have many workers which may be a bottleneck. Consider increasing the value of the num_workers argument(try 32 which is the number of cpus on this machine) in theDataLoader` init to improve performance.
rank_zero_warn(
Error training at step 0.
num_samples should be a positive integer value, but got num_samples=0
Error training at step 0
Traceback (most recent call last):
File "/workspace/Dreambooth-Stable-Diffusion/main.py", line 226, in
trainer.fit(model, data)
File "/workspace/stable-diffusion-webui/venv/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py", line 696, in fit
self._call_and_handle_interrupt(
File "/workspace/stable-diffusion-webui/venv/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py", line 650, in _call_and_handle_interrupt
return trainer_fn(*args, **kwargs)
File "/workspace/stable-diffusion-webui/venv/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py", line 735, in _fit_impl
results = self._run(model, ckpt_path=self.ckpt_path)
File "/workspace/stable-diffusion-webui/venv/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py", line 1166, in _run
results = self._run_stage()
File "/workspace/stable-diffusion-webui/venv/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py", line 1252, in _run_stage
return self._run_train()
File "/workspace/stable-diffusion-webui/venv/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py", line 1283, in _run_train
self.fit_loop.run()
File "/workspace/stable-diffusion-webui/venv/lib/python3.10/site-packages/pytorch_lightning/loops/loop.py", line 195, in run
self.on_run_start(*args, **kwargs)
File "/workspace/stable-diffusion-webui/venv/lib/python3.10/site-packages/pytorch_lightning/loops/fit_loop.py", line 211, in on_run_start
self.trainer.reset_train_dataloader(self.trainer.lightning_module)
File "/workspace/stable-diffusion-webui/venv/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py", line 1812, in reset_train_dataloader
self.train_dataloader = self._data_connector._request_dataloader(RunningStage.TRAINING)
File "/workspace/stable-diffusion-webui/venv/lib/python3.10/site-packages/pytorch_lightning/trainer/connectors/data_connector.py", line 453, in _request_dataloader
dataloader = source.dataloader()
File "/workspace/stable-diffusion-webui/venv/lib/python3.10/site-packages/pytorch_lightning/trainer/connectors/data_connector.py", line 530, in dataloader
return method()
File "/workspace/Dreambooth-Stable-Diffusion/main.py", line 99, in _train_dataloader
return DataLoader(train_set, batch_size=self.batch_size,
File "/workspace/stable-diffusion-webui/venv/lib/python3.10/site-packages/pytorch_lightning/utilities/data.py", line 516, in wrapper
init(obj, *args, **kwargs)
File "/workspace/stable-diffusion-webui/venv/lib/python3.10/site-packages/torch/utils/data/dataloader.py", line 351, in init
sampler = RandomSampler(dataset, generator=generator) # type: ignore[arg-type]
File "/workspace/stable-diffusion-webui/venv/lib/python3.10/site-packages/torch/utils/data/sampler.py", line 107, in init
raise ValueError("num_samples should be a positive integer "
ValueError: num_samples should be a positive integer value, but got num_samples=0

I think your regularization images folder is empty, or it can't find them.

after setup cell, it should display your config which includes the paths it is expecting, example :

{
    "class_word": "person",
    "config_date_time": "2023-04-18T12-03-28",
    "debug": false,
    "flip_percent": 0.0,
    "gpu": 0,
    "learning_rate": 1e-06,
    "max_training_steps": 2000,
    "model_path": "sd_v1-5_vae.ckpt",
    "model_repo_id": "panopstor/EveryDream",
    "project_config_filename": "2023-04-18T12-03-28-ProjectName-config.json",
    "project_name": "ProjectName",
    "regularization_images_folder_path": "Stable-Diffusion-Regularization-Images-person_ddim/person_ddim",
    "save_every_x_steps": 0,
    "schema": 1,
    "seed": 23,
    "token": "firstNameLastName",
    "token_only": false,
    "training_images": [
        "00.png",
        "01.png",
        "02.png",
        "03.png",
        "04.png",
        "05.png",
        "06.png",
        "07.png",
        "08.png",
        "09.png"
    ],
    "training_images_count": 10,
    "training_images_folder_path": "./training_images"
}