Skip to content

[Refactor] Better align from_single_file logic with from_pretrained #7496

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 113 commits into from
May 9, 2024
Merged
Changes from 1 commit
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
f03ea10
refactor unet single file loading a bit.
sayakpaul Mar 14, 2024
bfaa0d8
retrieve the unet from create_diffusers_unet_model_from_ldm
sayakpaul Mar 14, 2024
bc32a9d
update
DN6 Mar 18, 2024
5bb7d56
update
DN6 Mar 18, 2024
56863a2
updae
DN6 Mar 21, 2024
2cd8175
update
DN6 Mar 21, 2024
92cf552
update
DN6 Mar 21, 2024
57aa8be
update
DN6 Mar 25, 2024
8c9a890
update
DN6 Mar 25, 2024
5cb4f12
update
DN6 Mar 26, 2024
0dd26eb
update
DN6 Mar 26, 2024
8e0cdd2
update
DN6 Mar 26, 2024
5203eb6
update
DN6 Mar 26, 2024
17f3cbd
update
DN6 Mar 26, 2024
3d0bc40
update
DN6 Mar 27, 2024
88389a2
update
DN6 Mar 27, 2024
3850ef8
update
DN6 Mar 27, 2024
7997372
update
DN6 Mar 27, 2024
64bdee0
update
DN6 Mar 27, 2024
f12217a
update
DN6 Mar 29, 2024
8bf783a
update
DN6 Mar 29, 2024
2838e8a
update
DN6 Mar 29, 2024
c8665f1
update
DN6 Mar 29, 2024
76b838a
update
DN6 Mar 29, 2024
2e0dd15
update
DN6 Mar 29, 2024
b2fe190
update
DN6 Mar 29, 2024
9d692b9
update
DN6 Mar 29, 2024
ebebc43
update
DN6 Mar 29, 2024
3aa537b
update
DN6 Mar 29, 2024
3f3582d
update
DN6 Mar 29, 2024
adaf292
update
DN6 Mar 29, 2024
d8cd73d
update
DN6 Mar 29, 2024
06b2a77
update
DN6 Mar 29, 2024
4b16059
update
DN6 Apr 2, 2024
7421a32
update
DN6 Apr 2, 2024
b5497a9
update
DN6 Apr 2, 2024
17fa96f
update
DN6 Apr 2, 2024
e85570c
update
DN6 Apr 2, 2024
2c3b5e7
update
DN6 Apr 2, 2024
243bbf8
update
DN6 Apr 3, 2024
a48381d
Merge branch 'main' into single-file-updates
DN6 Apr 3, 2024
c60eb53
update
DN6 Apr 3, 2024
2f88a9a
update
DN6 Apr 3, 2024
3dcc07f
update
DN6 Apr 3, 2024
4504fdf
update
DN6 Apr 4, 2024
38c6f8e
update
DN6 Apr 4, 2024
bbdfe9d
update
DN6 Apr 4, 2024
88a7a94
update
DN6 Apr 4, 2024
7c9fffa
tests
DN6 Apr 5, 2024
0ae2137
update
DN6 Apr 8, 2024
de97fbc
update
DN6 Apr 8, 2024
66df5f7
update
DN6 Apr 9, 2024
8d4a1d2
Update docs/source/en/api/single_file.md
DN6 Apr 9, 2024
93da824
Update docs/source/en/api/single_file.md
DN6 Apr 9, 2024
ab09847
update
DN6 Apr 9, 2024
18e1dec
update
DN6 Apr 9, 2024
4c7a060
update
DN6 Apr 9, 2024
aea47f3
update
DN6 Apr 9, 2024
7ccd797
update
DN6 Apr 9, 2024
e1c7607
update
DN6 Apr 9, 2024
5f05f91
update
DN6 Apr 10, 2024
2ea357d
update
DN6 Apr 10, 2024
912b49b
update
DN6 Apr 10, 2024
be1e70b
merge upstream
DN6 Apr 10, 2024
695cedd
update
DN6 Apr 10, 2024
759afb2
update
DN6 Apr 10, 2024
25c7ed7
update
DN6 Apr 10, 2024
5dca42f
update
DN6 Apr 11, 2024
ba74a33
Merge branch 'main' into single-file-updates
sayakpaul Apr 11, 2024
083c494
Update docs/source/en/api/loaders/single_file.md
DN6 Apr 17, 2024
3f39e48
Update src/diffusers/loaders/single_file.py
DN6 Apr 17, 2024
bbe4b78
Update docs/source/en/api/loaders/single_file.md
DN6 Apr 17, 2024
d8d2bdc
Update docs/source/en/api/loaders/single_file.md
DN6 Apr 17, 2024
8e72865
Update docs/source/en/api/loaders/single_file.md
DN6 Apr 17, 2024
492161e
Merge branch 'single-file-updates' of https://github.com/huggingface/…
DN6 Apr 17, 2024
ccb130f
Update docs/source/en/api/loaders/single_file.md
DN6 Apr 17, 2024
39e8697
update
DN6 Apr 19, 2024
4a78284
Merge branch 'single-file-updates' of https://github.com/huggingface/…
DN6 Apr 19, 2024
e47b4a1
Merge branch 'single-file-updates-changes' into single-file-updates
DN6 Apr 19, 2024
109b997
update
DN6 Apr 19, 2024
351a520
update
DN6 Apr 19, 2024
0253e61
update
DN6 Apr 19, 2024
e3d4f08
update
DN6 Apr 22, 2024
e778b7a
update
DN6 Apr 22, 2024
53b16fc
update
DN6 Apr 22, 2024
7127f9f
update
DN6 Apr 24, 2024
2bd6c28
update
DN6 Apr 25, 2024
0e4630d
Merge branch 'main' into single-file-updates
DN6 Apr 25, 2024
9cecfb9
update
DN6 Apr 25, 2024
a775ad0
update
DN6 Apr 25, 2024
2dd9a0b
update
DN6 Apr 26, 2024
a2a0030
update
DN6 Apr 26, 2024
7e7cbd6
update
DN6 Apr 26, 2024
03a2ed8
update
DN6 Apr 26, 2024
0051843
update
DN6 Apr 29, 2024
a5c78c2
update
DN6 Apr 29, 2024
96f1b2e
Merge branch 'main' into single-file-updates
DN6 Apr 30, 2024
47f825d
update
DN6 May 1, 2024
8e41325
Merge branch 'main' into single-file-updates
DN6 May 7, 2024
bd2e73f
update
DN6 May 7, 2024
f5e4017
update
DN6 May 7, 2024
954c20a
update
DN6 May 7, 2024
a04562f
update
DN6 May 7, 2024
4a8f072
update
DN6 May 7, 2024
cc16cc8
update
DN6 May 8, 2024
28bf5ad
update
DN6 May 8, 2024
8387950
update
DN6 May 8, 2024
fff5297
update
DN6 May 8, 2024
696b258
update
DN6 May 8, 2024
d364604
update
DN6 May 9, 2024
6a22444
update
DN6 May 9, 2024
c61779d
update
DN6 May 9, 2024
f211c04
Merge branch 'main' into single-file-updates
DN6 May 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update
  • Loading branch information
DN6 committed May 8, 2024
commit 8387950a8a765d556ad8dd6836634d24d98a038b
14 changes: 8 additions & 6 deletions tests/single_file/test_model_vae_single_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
from diffusers.utils.testing_utils import (
enable_full_determinism,
load_hf_numpy,
numpy_cosine_similarity_distance,
require_torch_gpu,
slow,
torch_all_close,
torch_device,
)

Expand Down Expand Up @@ -69,16 +69,18 @@ def test_single_file_inference_same_as_pretrained(self):

image = self.get_sd_image(33)

generator = torch.Generator(torch_device)

with torch.no_grad():
sample_1 = model_1(image).sample
sample_2 = model_2(image).sample
sample_1 = model_1(image, generator=generator.manual_seed(0)).sample
sample_2 = model_2(image, generator=generator.manual_seed(0)).sample

assert sample_1.shape == sample_2.shape

output_slice_1 = sample_1[-1, -2:, -2:, :2].flatten().float().cpu()
output_slice_2 = sample_2[-1, -2:, -2:, :2].flatten().float().cpu()
output_slice_1 = sample_1.flatten().float().cpu()
output_slice_2 = sample_2.flatten().float().cpu()

assert torch_all_close(output_slice_1, output_slice_2, atol=3e-3)
assert numpy_cosine_similarity_distance(output_slice_1, output_slice_2) < 1e-4

def test_single_file_components(self):
model_single_file = self.model_class.from_single_file(self.ckpt_path)
Expand Down