Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in diffusers basic training tutorial #7991

Closed
yue-here opened this issue May 20, 2024 · 5 comments
Closed

Bug in diffusers basic training tutorial #7991

yue-here opened this issue May 20, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@yue-here
Copy link
Contributor

Describe the bug

In the diffusers basic training tutorial, setting the manual seed argument (generator=torch.manual_seed(config.seed)) in the pipeline call inside evaluate() function rewinds the dataloader shuffling, leading to overfitting due to the model see same sequence of training examples after every evaluation call. This can be tested by running the code without this argument. In the former case the training loss is lower but quality of sampled images are worse to the human eye.

images = pipeline(
        batch_size=config.eval_batch_size,
        generator=torch.manual_seed(config.seed),
    ).images 

Reproduction

images = pipeline(
batch_size=config.eval_batch_size,
# generator=torch.manual_seed(config.seed), # Dataloader shuffling works fine once this is removed
).images

Logs

No response

System Info

  • diffusers version: 0.28.0.dev0
  • Platform: Windows-10-10.0.22631-SP0
  • Python version: 3.11.9
  • PyTorch version (GPU?): 2.1.2 (True)
  • Huggingface_hub version: 0.22.2
  • Transformers version: 4.40.1
  • Accelerate version: 0.29.3
  • xFormers version: not installed

Who can help?

@stevhliu

@yue-here yue-here added the bug Something isn't working label May 20, 2024
@bghira
Copy link
Contributor

bghira commented May 21, 2024

try instead using generator=torch.Generator(device='cpu').manual_seed(config.seed)

@yue-here
Copy link
Contributor Author

Thanks, this worked perfectly!

@bghira
Copy link
Contributor

bghira commented May 21, 2024

would you like to open a pull request with an adjustment to the doc! i think @stevhliu would love that :D

@yue-here
Copy link
Contributor Author

I would but I couldn't find where the repo for the doc was!

@bghira
Copy link
Contributor

bghira commented May 21, 2024

in diffusers/docs/source/en/tutorials/basic_training.md (link)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants