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

Fix Incorrect Default Parameters in NoiseScheduler for StableDiffusion #2065

Open
wants to merge 118 commits into
base: master
Choose a base branch
from

Conversation

yuvraj-wale
Copy link

@yuvraj-wale yuvraj-wale commented Sep 8, 2023

What does this PR do?

Fixes #2049

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue? Please add a link
    to it if that's the case
    --> NoiseScheduler parameters for StableDiffusion are wrong #2049
  • Did you write any new necessary tests?
  • If this adds a new model, can you run a few training steps on TPU in Colab to ensure that no XLA incompatible OP are used?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@google-cla
Copy link

google-cla bot commented Sep 8, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@jbischof
Copy link
Contributor

jbischof commented Sep 12, 2023

Thank you @yuvraj-wale!

Have you tested our API with these new parameters? Do you see any impact on image generation? You can try this notebook gist.

By the way, we will need to update our "golden value" SD test with this change (link). I recommend running the following command in your branch to verify:

pytest keras_cv/models/stable_diffusion --run_extra_large

@ianstenbit ianstenbit self-requested a review September 12, 2023 03:14
@ianstenbit
Copy link
Contributor

Thank you @yuvraj-wale!

Have you tested our API with these new parameters? Do you see any impact on image generation? You can try this notebook gist.

By the way, we will need to update our "golden value" SD test with this change (link). I recommend running the following command in your branch to verify:

pytest keras_cv/models/stable_diffusion --run_extra_large

This won't change our golden values, because the NoiseScheduler is only relevant for training, not the forward pass.
I think the best thing to verify is one of the fine-tuning flows (e.g. Textual Inversion)

@jbischof
Copy link
Contributor

Thanks for the clarification @ianstenbit

@divyashreepathihalli
Copy link
Collaborator

@yuvraj-wale have you tested with a fine tuning workflow like Textual inversion? - #2065 (comment)

here is the link to it - https://keras.io/examples/generative/fine_tune_via_textual_inversion/

@divyashreepathihalli
Copy link
Collaborator

@yuvraj-wale can you please rebase the branch with master? and check if the golden values still remain the same?

@divyashreepathihalli divyashreepathihalli added the kokoro:force-run Runs Tests on GPU label Dec 16, 2023
@kokoro-team kokoro-team removed the kokoro:force-run Runs Tests on GPU label Dec 16, 2023
ianstenbit and others added 20 commits February 9, 2024 02:16
)

* Update PULL_REQUEST_TEMPLATE.md

* Update CONTRIBUTING.md

* Update CONTRIBUTING.md

* Update basic_training.py

* More namex fixes
We need to cut a release to get the namex fixes deployed.
Need to cut another minor release for bugfix.
…s-team#2071)

* Update deeplab_v3_plus.py

Update the comment of the `num_classes`parameter which contains the background class and the classes from the data.

* Update deeplab_v3_plus_test.py

Update the tests following the updating of 'num_classes' parameter (now including the background class)
* Start adding components for the segment anything model

* SAMLayerNormalization -> keras.layers.LayerNormalization

They both behave exactly the same when moving_mean and moving_variance are None and epsilon is 1e-6

* Move the image encoder to detectron2 backbone and fix for tf.keras backend

* Address review comments and address saving bug

- Use `keras_cv.export_api.keras_cv_export` instead of `keras.saving.register_keras_serializable`.
- Add a `SerializableSequential` class to address the saving bug with the `Sequential` model.
- Push the helper functions in `keras_cv/layers/detectron2_layers.py` to the bottom of the file.
- Add the detectron2 layers to the `keras_cv/layers/__init__.py` file.
- Add a test for the `ViTDetPatchingAndEmbedding` layer.

* Make the backbone functional; unite MLP and MLPBlock

* Address David's review comments

* Add SAM Task model; make MaskDecoder and PromptEncoder XLA compatible

* Remove a stray file

* Add docs for the Task model

* Add more references

[skip ci]

* Remove SerializableSequential layer

* detectron2 -> vit_det; add SAM presets; fix ViTDet presets

* Increse test tolerence for GCB Run
* Export SD submodels

* Remove empty folder
* adding deeplab_v3_plus_presets

* update formatting

* fixed error

* reformatted

* fix errors

* added num_classses arg

* add input_shape arg

* update test

* update input_shape

* updated preset

* update test

* move update to from_preset to task.py

* reformatted code

* updated doc string

* Update assert

* Update deeplab_v3_plus_test.py test

* Update task.py

* Update deeplab_v3_plus_test.py

* Update deeplab_v3_plus_test.py
* fix example in docstring

* review comments
* Bump python version requirement to 3.9

Keras-core now requires at least 3.9, and tf 2.14 (out imminently) will
require 3.9 as well.

We should follow suit for cv/nlp.

* Fix build errors with new keras-core version

* Update devcontainer to 3.9
* Use "masks" and "boxes" as prompt keys for SAM

* Fix tests
* Use "masks" and "boxes" as prompt keys for SAM

* Fix tests

* Support missing prompts for SAM

* Update docstrings

* Review fix

* Fix partial prompting for top-level model
…eam#2001 (keras-team#2077)

* Test to demonstrate failures in import

* Explicitly specify full package for more modules, as shown in keras-team#2001
* Update VITDet to conform to KerasCV scaling standards

* dtype fix
)

* Support importing Keras3 as Keras instead of Keras Core

* Fix version parsing

* Remove try/catch (not required)
…team#2093)

* Export task models as both models.task.Model and models.Model

* Same for ImageClassifier
nkovela1 and others added 28 commits February 9, 2024 02:16
* Add fixes for backwards compatibility for versions <2.15

* Bump version number for presets to version 2

* Port over RetinaNet custom metric fix

* Bump DeepLabV3Plus preset version after re-upload
* Modify kaggle handles to full path

* Modify preset handling

* Fix formatting
* Fix YOLOv8Detector deserialization

* Fix nit

* Deserialize preditction decoder
Bumps the python group with 4 updates: [tf-nightly-cpu](https://github.com/tensorflow/tensorflow), torch, torchvision and [tf-nightly[and-cuda]](https://github.com/tensorflow/tensorflow).


Updates `tf-nightly-cpu` from 2.16.0.dev20231221 to 2.16.0.dev20240104
- [Release notes](https://github.com/tensorflow/tensorflow/releases)
- [Changelog](https://github.com/tensorflow/tensorflow/blob/master/RELEASE.md)
- [Commits](https://github.com/tensorflow/tensorflow/commits)

Updates `torch` from 2.1.2 to 2.1.2+cu121

Updates `torchvision` from 0.16.2 to 0.16.2+cu121

Updates `tf-nightly[and-cuda]` from 2.16.0.dev20231221 to 2.16.0.dev20240104
- [Release notes](https://github.com/tensorflow/tensorflow/releases)
- [Changelog](https://github.com/tensorflow/tensorflow/blob/master/RELEASE.md)
- [Commits](https://github.com/tensorflow/tensorflow/commits)

---
updated-dependencies:
- dependency-name: tf-nightly-cpu
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: python
- dependency-name: torch
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: python
- dependency-name: torchvision
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: python
- dependency-name: tf-nightly[and-cuda]
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: python
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: Pedro Kaj Kjellerup Nacht <[email protected]>
* fix nms serialization

* remove the default function

---------

Co-authored-by: Divyashree Sreepathihalli <divyashreepathihalli>
Co-authored-by: Divyashree Sreepathihalli <divyashreepathihalli>
Keras, KerasNLP and KerasTuner all store things liek the CONTRIBUTING.md
in the toplevel of the repo. We should do the same here.
* Unify `version` API with keras and keras_nlp

* Formatting

* Update to keep `version` parity with KerasNLP, support nightly version string

* Update version_utils.py

* Update version_utils.py
* Update random_crop_and_zoom.py

* Update description

* rename file
* BASNet model initial code structure

* adding test and initial preset details

* adding comments

* cleaning and formatting code

* keras 3 support added

* disabling preset test for BASNet
Fixed image.shape issue for tensorflow backend
…eras-team#2313)

* Create auto-assignment.yaml

* Create auto-assignment.js

* Create stale-issue-pr.yaml

* Rename auto-assignment.yaml to auto-assignment.yml

* Rename stale-issue-pr.yaml to stale-issue-pr.yml
Bumps the github-actions group with 3 updates: [actions/cache](https://github.com/actions/cache), [actions/upload-artifact](https://github.com/actions/upload-artifact) and [github/codeql-action](https://github.com/github/codeql-action).


Updates `actions/cache` from 3 to 4
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](actions/cache@v3...v4)

Updates `actions/upload-artifact` from 4.0.0 to 4.3.0
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](actions/upload-artifact@c7d193f...26f96df)

Updates `github/codeql-action` from 3.22.12 to 3.23.2
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](github/codeql-action@012739e...b7bf0a3)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github-actions
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@divyashreepathihalli divyashreepathihalli requested review from divyashreepathihalli and removed request for ianstenbit February 12, 2024 18:11
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.

NoiseScheduler parameters for StableDiffusion are wrong