-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Unet fix #4769
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
Unet fix #4769
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. |
Will merge once the CI is green :-) Thanks a lot for spotting out the bug and for your contribution. |
Would you like me to apply the black code formatter, and push it again? |
Once the CI is green, we can merge :-) |
* Optional images variable train_custom_diffusion.py * Fixed train_custom_diffusion.py * Revert accidental changes to unet_2d_condition.py * "Format code with black"
What does this PR do?
I was doing the CustomDiffusion tutorial, and I started receiving an
UnboundLocalError
at the end of the training.The line (1312) is referring inside the conditional block
if args.push_to_hub:
. This error error occurs because theimages
variable is defined inside two nested conditional blocks (lines 1232 and 1290), but is later referenced without being assigned if certain conditions are not met.Here's how
images
is defined:line 1232
line 1290
This issue arises if you try to push your model to the hub without, setting the num_validation_images, and it will lead to a "UnboundLocalError" when the code tries to access
images
without having defined it first.To ensure that the images variable is always initialized, we can declare an empty list at the beginning of the code block where the main process is checked. This will prevent the UnboundLocalError when you reference images when pushing your model to the hub, and don't define the num_validation_images
Referring to these: #4704 #4707
Before submitting
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
@sayakpaul @patrickvonplaten