keras-io
keras-io copied to clipboard
Add textual inversion guide for StableDiffusion()
Some remaining TODOS:
- [x] load the VAEEncoder with weights ( could use some help porting the weights if @fchollet or @divamgupta would be willing to share their porting process)
- [x] add the actual training loop (trivial)
- [x] add the noise adder
- [x] figure out how to properly add new tokens to the tokenizer (I think the Keras NLP team will have a good answer for this)
- [ ] Merge add_tokens() method
- [ ] Remove extra code paths from noise scheduler that we don't need in this guide
- [ ] Remove shape assertions
- [ ] Figure out best way to construct a new text_encoder (and where to expose this API)
Really the VAE is the biggest remaining piece missing.
load the VAEEncoder with weights ( could use some help porting the weights if @fchollet or @divamgupta would be willing to share their porting process)
The way I do it, personally, is to make sure that the Keras-side implementation creates the weights in the same order (typically weights are always created at layer call, so you need to make sure that the layer call order is preserved), then inject a bit of code to collect the list of variables created by the Keras model in order of creation, as a flat list. Then match it 1:1 with the same list obtained from the reference model, and do assign() calls.
I can help you do that on the Keras side if you need. It's simple.
ok @ianstenbit @fchollet @tanzhenyu this is ready for another round
all addressed @ianstenbit
all addressed @ianstenbit
I think you moved the wrong guide to examples. It seems like you moved the original guide, not the one in this PR
@LukeWood
all addressed @ianstenbit
I think you moved the wrong guide to
examples. It seems like you moved the original guide, not the one in this PR @LukeWood
Good catch
ok @fchollet we are good to go!!!