Skip to content

Conversation

@Mr-Philo
Copy link
Contributor

@Mr-Philo Mr-Philo commented Feb 6, 2023

Recently the code in class DreamboothDataset will directly make num of class_images to the length of the class_images folder:

self.num_class_images = len(self.class_images_path)

However, if user want to test different effects with different class images (for example user want to test 50 but the folder contains 100), it will ignore the number 50 and still use 100, thus fail to handle it. So, it seems better to modify the code to:

self.num_class_images = min(len(self.class_images_path), class_num)

All three dreambooth training scripts in this PR have been modified in the same way.

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Feb 6, 2023

The documentation is not available anymore as the PR was closed or merged.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 8, 2023

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the contributing guidelines are likely to be ignored.

@github-actions github-actions bot added the stale Issues that haven't received updates label Mar 8, 2023
@patrickvonplaten
Copy link
Contributor

From a quick glance this makes sense to me - @patil-suraj could you quickly check this?

Copy link
Contributor

@patil-suraj patil-suraj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry to be so late here, makes sense, looks good!

tokenizer,
class_data_root=None,
class_prompt=None,
class_num=None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be None actually, otherwise the min call will fail. When it's None we should set it to the value of len(self.class_images_path)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's my mistake. Change the code like this:

if class_num is not None:
    self.num_class_images = min(len(self.class_images_path), class_num)
else:
    self.num_class_images = len(self.class_images_path)

@Mr-Philo
Copy link
Contributor Author

Hi all, thanks for checking this PR and reviewing the code! I have committed the new code😊

@patrickvonplaten
Copy link
Contributor

Cool, good for merge then!

@patrickvonplaten patrickvonplaten merged commit ce08cb7 into huggingface:main Mar 10, 2023
w4ffl35 pushed a commit to w4ffl35/diffusers that referenced this pull request Apr 14, 2023
* [Dreambooth] Editable number of class images

* 'class_num=None' bug fix

---------

Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>
AmericanPresidentJimmyCarter pushed a commit to AmericanPresidentJimmyCarter/diffusers that referenced this pull request Apr 26, 2024
* [Dreambooth] Editable number of class images

* 'class_num=None' bug fix

---------

Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale Issues that haven't received updates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants