1
0
mirror of https://github.com/huggingface/diffusers.git synced 2026-01-29 07:22:12 +03:00
Commit Graph

2193 Commits

Author SHA1 Message Date
Patrick von Platen
cc1469037f Improve deprecation warnings (#3131) 2023-05-05 07:22:13 -07:00
Patrick von Platen
7fa3b6c1f1 [Bug fix] Make sure correct timesteps are chosen for img2img (#3128)
Make sure correct timesteps are chosen for img2img
2023-05-05 07:22:13 -07:00
Patrick von Platen
653b3c1a1a [Bug fix] Fix img2img processor with safety checker (#3127)
Fix img2img processor with safety checker
2023-05-05 07:22:13 -07:00
Patrick von Platen
c98e41dffe Add global pooling to controlnet (#3121) 2023-05-05 07:22:13 -07:00
Tommaso De Rossi
e9cb03edf0 Fix breaking change in pipeline_stable_diffusion_controlnet.py (#3118)
fix breaking change
2023-05-05 07:22:13 -07:00
Will Berman
a256f8446d ddpm custom timesteps (#3007)
add custom timesteps test

add custom timesteps descending order check

docs

timesteps -> custom_timesteps

can only pass one of num_inference_steps and timesteps
2023-05-05 07:22:13 -07:00
YiYi Xu
fa6a6b470d remvoe one line as requested by gc team (#3077)
remvoe one line
2023-05-05 07:22:13 -07:00
YiYi Xu
1184b36d2f fix default value for attend-and-excite (#3099)
* fix default
2023-05-05 07:22:13 -07:00
Takuma Mori
7f3cb6d29f Add to support Guess Mode for StableDiffusionControlnetPipleline (#2998)
* add guess mode (WIP)

* fix uncond/cond order

* support guidance_scale=1.0 and batch != 1

* remove magic coeff

* add docstring

* add intergration test

* add document to controlnet.mdx

* made the comments a bit more explanatory

* fix table
2023-05-05 07:22:13 -07:00
Steven Liu
d6ae0aeeb9 [docs] Update community pipeline docs (#2989)
* update community pipeline docs

* fix formatting

* explain sharing workflows
2023-05-05 07:22:13 -07:00
Joseph Coffland
0be9f8bc68 Allow SD attend and excite pipeline to work with any size output images (#2835)
Allow stable diffusion attend and excite pipeline to work with any size output image. Re: #2476, #2603
2023-05-05 07:22:13 -07:00
Patrick von Platen
74907ee49a Throw deprecation warning for return_cached_folder (#3092)
Throw deprecation warning
2023-05-05 07:22:13 -07:00
Patrick von Platen
9dd6058d62 [Tests] parallelize (#3078)
* [Tests] parallelize

* finish folder structuring

* Parallelize tests more

* Correct saving of pipelines

* make sure logging level is correct

* try again

* Apply suggestions from code review

Co-authored-by: Pedro Cuenca <pedro@huggingface.co>

---------

Co-authored-by: Pedro Cuenca <pedro@huggingface.co>
2023-05-05 07:22:13 -07:00
YiYi Xu
068d6b421a doc string example remove from_pt (#3083) 2023-05-05 07:22:13 -07:00
Patrick von Platen
bbabf3ffe7 [Pipelines] Make sure that None functions are correctly not saved (#3080) 2023-05-05 07:22:13 -07:00
Andreas Steiner
7a1d10009c Adds profiling flags, computes train metrics average. (#3053)
* WIP controlnet training

- bugfix --streaming
- bugfix running report_to!='wandb'
- adds memory profile before validation

* Adds final logging statement.

* Sets train epochs to 11.

Looking at a longer ~16ep run, we see only good validation images
after ~11ep:

https://wandb.ai/andsteing/controlnet_fill50k/runs/3j2hx6n8

* Removes --logging_dir (it's not used).

* Adds --profile flags.

* Updates --output_dir=runs/fill-circle-{timestamp}.

* Compute mean of `train_metrics`.

Previously `train_metrics[-1]` was logged, resulting in very bumpy train
metrics.

* Improves logging a bit.

- adds l2_grads gradient norm logging
- adds steps_per_sec
- sets walltime as x coordinate of train/step
- logs controlnet_params config

* Adds --ccache (doesn't really help though).

* minor fix in controlnet flax example (#2986)

* fix the error when push_to_hub but not log validation

* contronet_from_pt & controlnet_revision

* add intermediate checkpointing to the guide

* Bugfix --profile_steps

* Sets `RACKER_PROJECT_NAME='controlnet_fill50k'`.

* Logs fractional epoch.

* Adds relative `walltime` metric.

* Adds `StepTraceAnnotation` and uses `global_step` insetad of `step`.

* Applied `black`.

* Streamlines commands in README a bit.

* Removes `--ccache`.

This makes only a very small difference (~1 min) with this model size, so removing
the option introduced in cdb3cc.

* Re-ran `black`.

* Update examples/controlnet/README.md

Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>

* Converts spaces to tab.

* Removes repeated args.

* Skips first step (compilation) in profiling

* Updates README with profiling instructions.

* Unifies tabs/spaces in README.

* Re-ran style & quality.

---------
Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
2023-05-05 07:22:13 -07:00
Patrick von Platen
af0c3a7d5e [Post release] v0.16.0dev (#3072) 2023-05-05 07:22:13 -07:00
Sayak Paul
322b5cb2af [Tests] Speed up panorama tests (#3067)
* fix: norm group test for UNet3D.

* chore: speed up the panorama tests (fast).

* set default value of _test_inference_batch_single_identical.

* fix: batch_sizes default value.
2023-05-05 07:22:13 -07:00
Patrick von Platen
945f3001b1 Release: v0.15.0 2023-05-05 07:22:13 -07:00
Andranik Movsisyan
10c54cbf8f Text2video zero refinements (#3070)
* fix progress bar issue in pipeline_text_to_video_zero.py. Copy scheduler after first backward

* fix tensor loading in test_text_to_video_zero.py

* make style && make quality
2023-05-05 07:22:13 -07:00
Ernie Chu
115e382d3b Fix a bug of pano when not doing CFG (#3030)
* Fix a bug of pano when not doing CFG

* enhance code quality

* apply formatting.

---------

Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
2023-05-05 07:22:13 -07:00
Pedro Cuenca
cbb18d8ba9 Update Flax TPU tests (#3069)
Update Flax TPU tests.

Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>
2023-05-05 07:22:13 -07:00
Sayak Paul
870169e08f [Docs] refactor text-to-video zero (#3049)
* fix: norm group test for UNet3D.

* refactor text-to-video zero docs.
2023-05-05 07:22:13 -07:00
Patrick von Platen
40ee0d4eec Finish docs textual inversion (#3068)
* Finish docs textual inversion

* Apply suggestions from code review

Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
Co-authored-by: Pedro Cuenca <pedro@huggingface.co>

---------

Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
Co-authored-by: Pedro Cuenca <pedro@huggingface.co>
2023-05-05 07:22:13 -07:00
Nipun Jindal
129483eaea [2064]: Add Karras to DPMSolverMultistepScheduler (#3001)
* [2737]: Add Karras DPMSolverMultistepScheduler

* [2737]: Add Karras DPMSolverMultistepScheduler

* Add test

* Apply suggestions from code review

Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>

* fix: repo consistency.

* remove Copied from statement from the set_timestep method.

* fix: test

* Empty commit.

Co-authored-by: njindal <njindal@adobe.com>

---------

Co-authored-by: njindal <njindal@adobe.com>
Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>
Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
2023-05-05 07:22:13 -07:00
Sean Sube
2c442553e2 add support for pre-calculated prompt embeds to Stable Diffusion ONNX pipelines (#2597)
* add support for prompt embeds to SD ONNX pipeline

* fix up the pipeline copies

* add prompt embeds param to other ONNX pipelines

* fix up prompt embeds param for SD upscaling ONNX pipeline

* add missing type annotations to ONNX pipes
2023-05-05 07:22:13 -07:00
Will Berman
9eb141a3cb fix pipeline __setattr__ value == None (#3063)
* fix pipeline __setattr__

* add test

---------

Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>
2023-05-05 07:22:13 -07:00
Andy
8344d99d6f [WIP] implement rest of the test cases (LoRA tests) (#2824)
* inital commit for lora test cases

* help a bit with lora for 3d

* fixed lora tests

* replaced redundant code

---------

Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>
Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
2023-05-05 07:22:13 -07:00
Pedro Cuenca
a16860e1eb Flax memory efficient attention (#2889)
* add use_memory_efficient params placeholder

* test

* add memory efficient attention jax

* add memory efficient attention jax

* newline

* forgot dot

* Rename use_memory_efficient

* Keep dtype last.

* Actually use key_chunk_size

* Rename symbol

* Apply style

* Rename use_memory_efficient

* Keep dtype last

* Pass `use_memory_efficient_attention` in `from_pretrained`

* Move JAX memory efficient attention to attention_flax.

* Simple test.

* style

---------

Co-authored-by: muhammad_hanif <muhammad_hanif@sofcograha.co.id>
Co-authored-by: MuhHanif <48muhhanif@gmail.com>
2023-05-05 07:22:13 -07:00
Susung Hong
184dab3b31 [Docs] update Self-Attention Guidance docs (#2952)
* Update index.mdx

* Edit docs & add HF space link

* Only change equation numbers in comments
2023-05-05 07:22:13 -07:00
Sayak Paul
3826f99791 Fix InstructPix2Pix training in multi-GPU mode (#2978)
* fix: norm group test for UNet3D.

* fix: unet rejig.

* fix: unwrapping when running validation inputs.

* unwrapping the unet too.

* fix: device.

* better unwrapping.

* unwrapping before ema.

* unwrapping.
2023-05-05 07:22:13 -07:00
Patrick von Platen
befae11bf9 fix slow tsets (#3066)
* fix slow tsets

* make style
2023-05-05 07:22:13 -07:00
Sayak Paul
2d6b410525 [LoRA] Enabling limited LoRA support for text encoder (#2918)
* add: first draft for a better LoRA enabler.

* make fix-copies.

* feat: backward compatibility.

* add: entry to the docs.

* add: tests.

* fix: docs.

* fix: norm group test for UNet3D.

* feat: add support for flat dicts.

* add depcrcation message instead of warning.
2023-05-05 07:22:13 -07:00
Sayak Paul
3f3ab51b39 [Examples] Fix type-casting issue in the ControlNet training script (#2994)
* fix: norm group test for UNet3D.

* fix: type-casting issue in controlnet training.
2023-05-05 07:22:13 -07:00
Will Berman
a6cf0f24bf Attn added kv processor torch 2.0 block (#3023)
add AttnAddedKVProcessor2_0 block
2023-05-05 07:22:12 -07:00
Will Berman
07b9368322 Attention processor cross attention norm group norm (#3021)
add group norm type to attention processor cross attention norm

This lets the cross attention norm use both a group norm block and a
layer norm block.

The group norm operates along the channels dimension
and requires input shape (batch size, channels, *) where as the layer norm with a single
`normalized_shape` dimension only operates over the least significant
dimension i.e. (*, channels).

The channels we want to normalize are the hidden dimension of the encoder hidden states.

By convention, the encoder hidden states are always passed as (batch size, sequence
length, hidden states).

This means the layer norm can operate on the tensor without modification, but the group
norm requires flipping the last two dimensions to operate on (batch size, hidden states, sequence length).

All existing attention processors will have the same logic and we can
consolidate it in a helper function `prepare_encoder_hidden_states`

prepare_encoder_hidden_states -> norm_encoder_hidden_states re: @patrickvonplaten

move norm_cross defined check to outside norm_encoder_hidden_states

add missing attn.norm_cross check
2023-05-05 07:22:12 -07:00
Will Berman
e38bc51dfa unet time embedding activation function (#3048)
* unet time embedding activation function

* typo act_fn -> time_embedding_act_fn

* flatten conditional
2023-05-05 07:22:12 -07:00
Chanchana Sornsoontorn
b80790f95a Fix typo and format BasicTransformerBlock attributes (#2953)
* ⚙️chore(train_controlnet) fix typo in logger message

* ⚙️chore(models) refactor modules order; make them the same as calling order

When printing the BasicTransformerBlock to stdout, I think it's crucial that the attributes order are shown in proper order. And also previously the "3. Feed Forward" comment was not making sense. It should have been close to self.ff but it's instead next to self.norm3

* correct many tests

* remove bogus file

* make style

* correct more tests

* finish tests

* fix one more

* make style

* make unclip deterministic

* ⚙️chore(models/attention) reorganize comments in BasicTransformerBlock class

---------

Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>
2023-05-05 07:22:12 -07:00
Will Berman
0c8fd45894 add only cross attention to simple attention blocks (#3011)
* add only cross attention to simple attention blocks

* add test for only_cross_attention re: @patrickvonplaten

* mid_block_only_cross_attention better default

allow mid_block_only_cross_attention to default to
`only_cross_attention` when `only_cross_attention` is given
as a single boolean
2023-05-05 07:22:12 -07:00
Pedro Cuenca
d8eedb4787 Fix invocation of some slow Flax tests (#3058)
* Fix invocation of some slow tests.

We use __call__ rather than pmapping the generation function ourselves
because the number of static arguments is different now.

* style
2023-05-05 07:22:12 -07:00
Pedro Cuenca
7e6ab07707 Fix scheduler type mismatch (#3041)
When doing generation manually and using guidance_scale as a static
argument.
2023-05-05 07:22:12 -07:00
George Ogden
8d362f2cf5 Update documentation (#2996)
* Update documentation

Based on sampling, the width and height must be powers of 2 as the samples halve in size each time

* make style
2023-05-05 07:22:12 -07:00
Will Berman
049d6f4219 AttentionProcessor.group_norm num_channels should be query_dim (#3046)
* `AttentionProcessor.group_norm` num_channels should be `query_dim`

The group_norm on the attention processor should really norm the number
of channels in the query _not_ the inner dim. This wasn't caught before
because the group_norm is only used by the added kv attention processors
and the added kv attention processors are only used by the karlo models
which are configured such that the inner dim is the same as the query
dim.

* add_{k,v}_proj should be projecting to inner_dim
2023-05-05 07:22:12 -07:00
Will Berman
53c0c6d372 accelerate min version for ProjectConfiguration import (#3042) 2023-05-05 07:22:12 -07:00
Will Berman
2bc0a15818 config fixes (#3060) 2023-05-05 07:22:12 -07:00
Patrick von Platen
1336668f0e make style 2023-05-05 07:22:12 -07:00
J N Hearns
1ee04a5e60 Fix imports for composable_stable_diffusion pipeline (#3002)
* Update composable_stable_diffusion.py

Fix imports

* Formatting

* Formatting

* Formatting
2023-05-05 07:22:12 -07:00
Steven Liu
531192367f [docs] Reusing components (#3000)
* reuse-components

* format
2023-05-05 07:22:12 -07:00
Patrick von Platen
473d4d3961 Fix config prints and save, load of pipelines (#2849)
* [Config] Fix config prints and save, load

* Only use potential nn.Modules for dtype and device

* Correct vae image processor

* make sure in_channels is not accessed directly

* make sure in channels is only accessed via config

* Make sure schedulers only access config attributes

* Make sure to access config in SAG

* Fix vae processor and make style

* add tests

* uP

* make style

* Fix more naming issues

* Final fix with vae config

* change more
2023-05-05 07:22:12 -07:00
Patrick von Platen
9605755ef5 fix report tool (#3047) 2023-05-05 07:22:12 -07:00