Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
library_name: diffusers
|
4 |
+
---
|
5 |
+
test under this PR https://github.com/huggingface/diffusers/pull/11235
|
6 |
+
|
7 |
+
```python
|
8 |
+
from diffusers.modular_pipelines import ModularPipelineMixin, ComponentsManager
|
9 |
+
import torch
|
10 |
+
from diffusers.utils import load_image
|
11 |
+
|
12 |
+
repo_id = "YiYiXu/modular-diffdiff"
|
13 |
+
|
14 |
+
diffdiff_blocks = ModularPipelineMixin.from_pretrained(repo_id, trust_remote_code=True)
|
15 |
+
components = ComponentsManager()
|
16 |
+
|
17 |
+
diffdiff_blocks.setup_loader(modular_repo=repo_id, component_manager=components, collection="diffdiff")
|
18 |
+
diffdiff_blocks.loader.load(torch_dtype=torch.float16)
|
19 |
+
|
20 |
+
components.enable_auto_cpu_offload()
|
21 |
+
|
22 |
+
|
23 |
+
|
24 |
+
image = load_image(
|
25 |
+
"https://huggingface.co/datasets/OzzyGT/testing-resources/resolve/main/differential/20240329211129_4024911930.png?download=true"
|
26 |
+
)
|
27 |
+
|
28 |
+
mask = load_image(
|
29 |
+
"https://huggingface.co/datasets/OzzyGT/testing-resources/resolve/main/differential/gradient_mask.png?download=true"
|
30 |
+
)
|
31 |
+
|
32 |
+
prompt = "a green pear"
|
33 |
+
negative_prompt = "blurry"
|
34 |
+
|
35 |
+
image = diffdiff_blocks.run(
|
36 |
+
prompt=prompt,
|
37 |
+
negative_prompt=negative_prompt,
|
38 |
+
num_inference_steps=25,
|
39 |
+
diffdiff_map=mask,
|
40 |
+
image=image,
|
41 |
+
output="images"
|
42 |
+
)[0]
|
43 |
+
|
44 |
+
image.save("yiyi_test_10_out.png")
|
45 |
+
```
|
46 |
+
|
47 |
+
|
48 |
+

|
49 |
+
|