Skip to content

Textual inv make save log both steps #2178

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

Merged
merged 17 commits into from
Mar 2, 2023
Merged

Textual inv make save log both steps #2178

merged 17 commits into from
Mar 2, 2023

Conversation

isamu-isozaki
Copy link
Contributor

Based on this issue. Still a WIP. I'm trying to keep the logging functionality to be the same as the same functionality where every x amounts of steps, we log.

I was thinking of moving the logic of the logging to a function. But then I need a way to get wandb there. I was thinking of passing it in as a default parameter or if available, automatically import. Let me know if anyone has some ideas for this.

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Jan 31, 2023

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

@isamu-isozaki
Copy link
Contributor Author

isamu-isozaki commented Jan 31, 2023

will try fixing the checks. Bit confused why it failed though.

@@ -270,11 +270,11 @@ def parse_args():
help="Number of images that should be generated during validation with `validation_prompt`.",
)
parser.add_argument(
"--validation_epochs",
"--validation_steps",
Copy link
Contributor

Choose a reason for hiding this comment

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

Using steps here (and in dreambooth) script makes sense to me and also it aligns well with save_steps. But Removing the existing arg would be a breaking change,

Instead of changing the arg, maybe we could introduce an additional arg called validation_steps and allow only one of them to be set. Inside the script, we always use validation_steps , we can compute that easily using the epochs value. And to align saving and validating we could prefer the validation_steps argument in the docs.

wdyt @patrickvonplaten @williamberman @pcuenca ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@patil-suraj good point! One point that I have is to do this we might want to make the logging a function(because calling in 2 places)

But if we do that we need to pass wandb as an argument as we aren't doing the import in the global scope. I was thinking of doing this before but it felt a bit hacky. Happy to show what I mean!

Copy link
Contributor

Choose a reason for hiding this comment

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

Preferring config via steps over epochs makes sense to me 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

Steps also makes sense to me but let's deprecate validation_epochs nicely. Could we keep validation_epochs and just add a new validation_steps . Then will convert validation_epochs to validation_steps if used and throw a deprecation warning. Would that be ok for you @isamu-isozaki ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@patrickvonplaten yup sounds good! Then will move the code to a function so it's cleaner

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@patrickvonplaten Should be done!

@williamberman
Copy link
Contributor

@isamu-isozaki I'm not sure I see what logic would have to be moved to a function? Regardless, I do think importing wandb on the top level of the module is better as I don't think there's intention to scope the import to the function.

@isamu-isozaki
Copy link
Contributor Author

@williamberman Thanks for the review! Ah if we just going with steps then no worries! I was mainly talking about if we want to support logging either for steps or epochs

@isamu-isozaki
Copy link
Contributor Author

Will fix merge conflict

@patil-suraj
Copy link
Contributor

Hey @isamu-isozaki we just updated some style dependencies cf #2279 , so you'll need to update the diffusers with

pip install --upgrade -e .["quality"]

Rebase the branch and then run make style.

Let me know if you need any help with this.

@isamu-isozaki
Copy link
Contributor Author

Sounds good! Fixing merge conflict and style now

@isamu-isozaki
Copy link
Contributor Author

@patil-suraj @williamberman Should be fixed! One small note. When testing I noticed that the default train_batch_size is 16 which might be a bit tough for non-high-end gpus.

@isamu-isozaki
Copy link
Contributor Author

Interesting. I'll try fixing my version of black and fix the styles

@isamu-isozaki
Copy link
Contributor Author

I do have black version 23.1.0 which should be exactly the same. I'll see if I can figure out the issue.

Comment on lines 839 to 843
warnings.warn(
f"Future Warning: You are doing logging with validation_epochs={args.validation_epochs}."
" validation_epochs is being deprecated in favor of validation_steps.",
FutureWarning,
stacklevel=2,
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we move the warning to directly after parse_args

Copy link
Contributor

Choose a reason for hiding this comment

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

@williamberman
Copy link
Contributor

Looks basically there :)

help=(
"Run validation every X epochs. Validation consists of running the prompt"
"Deprecated in favor of validation_steps. Run validation every X epochs. Validation consists of running the prompt"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add the deprecation statement right below the argparsing like @williamberman mentioned below and do something like:

if args.validation_epochs is not None:
    warnings.warn(f"Deprecate ..... Please make sure to use `validation_steps` instead in the future. Setting `args.validation_steps` to {args.validation_epochs * num_samples_per_epoch}.")
    args.validation_steps = 

Copy link
Contributor

Choose a reason for hiding this comment

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

once this is done args.validation_epochs doesn't have to be used anymore and it'll also be much easier to remove in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@patrickvonplaten Great point! For the length of the validation steps, I put it after the dataset creation since that is where we count the number of images in the folder/find out the length of each epoch

@isamu-isozaki
Copy link
Contributor Author

@patrickvonplaten @williamberman Thanks a bunch for the reviews! Will fix now

@isamu-isozaki
Copy link
Contributor Author

isamu-isozaki commented Feb 13, 2023

@patrickvonplaten @williamberman Should be fixed! For the deprecation warning, I did it after the dataset creation because that's when we know the size of each epoch. For everything else should be fixed!

@isamu-isozaki
Copy link
Contributor Author

Testing now

@isamu-isozaki
Copy link
Contributor Author

Ok, I don't know if this is a bug with the code but for the first image, it doesn't log. But after the second one, it starts logging. Will double-check.

@isamu-isozaki
Copy link
Contributor Author

By not logging, I mean the pipeline gets run but it doesn't go to wandb.

@isamu-isozaki
Copy link
Contributor Author

Actually, I noticed this in general with wandb. Sorry, prob not relevant.

@isamu-isozaki
Copy link
Contributor Author

Anyways should be done!

FutureWarning,
stacklevel=2,
)
args.validation_steps = args.validation_epochs * len(train_dataset)
Copy link
Contributor

Choose a reason for hiding this comment

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

super!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@patrickvonplaten thank you!

Copy link
Contributor

@patrickvonplaten patrickvonplaten left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@patrickvonplaten
Copy link
Contributor

@williamberman could you check here?

@patrickvonplaten patrickvonplaten merged commit d9b9533 into huggingface:main Mar 2, 2023
@patrickvonplaten
Copy link
Contributor

Thanks a lot @isamu-isozaki

@isamu-isozaki
Copy link
Contributor Author

@patrickvonplaten np! Always happy to contribute

mengfei25 pushed a commit to mengfei25/diffusers that referenced this pull request Mar 27, 2023
* Initial commit

* removed images

* Made logging the same as save

* Removed logging function

* Quality fixes

* Quality fixes

* Tested

* Added support back for validation_epochs

* Fixing styles

* Did changes

* Change to log_validation

* Add extra space after wandb import

* Add extra space after wandb

Co-authored-by: Will Berman <[email protected]>

* Fixed spacing

---------

Co-authored-by: Will Berman <[email protected]>
AmericanPresidentJimmyCarter pushed a commit to AmericanPresidentJimmyCarter/diffusers that referenced this pull request Apr 26, 2024
* Initial commit

* removed images

* Made logging the same as save

* Removed logging function

* Quality fixes

* Quality fixes

* Tested

* Added support back for validation_epochs

* Fixing styles

* Did changes

* Change to log_validation

* Add extra space after wandb import

* Add extra space after wandb

Co-authored-by: Will Berman <[email protected]>

* Fixed spacing

---------

Co-authored-by: Will Berman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants