Update pipeline.py
Browse files- pipeline.py +7 -7
pipeline.py
CHANGED
@@ -79,13 +79,14 @@ EXAMPLE_DOC_STRING = """
|
|
79 |
)
|
80 |
pipe.transformer = transformer
|
81 |
pipe.text_encoder_2 = text_encoder_2
|
|
|
82 |
pipe.to("cuda")
|
83 |
|
84 |
-
prompt = "
|
85 |
image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/robot.png")
|
86 |
|
87 |
-
head_mask = np.
|
88 |
-
head_mask[65:
|
89 |
mask_image = Image.fromarray(head_mask)
|
90 |
|
91 |
processor = DepthPreprocessor.from_pretrained("LiheYoung/depth-anything-large-hf")
|
@@ -96,14 +97,13 @@ EXAMPLE_DOC_STRING = """
|
|
96 |
image=image,
|
97 |
control_image=control_image,
|
98 |
mask_image=mask_image,
|
99 |
-
height=1024,
|
100 |
-
width=1024,
|
101 |
num_inference_steps=30,
|
102 |
strength=0.9,
|
103 |
-
guidance_scale=
|
104 |
generator=torch.Generator().manual_seed(42),
|
105 |
).images[0]
|
106 |
-
make_image_grid([image, control_image, mask_image, output], rows=1, cols=4).save("output.png")
|
|
|
107 |
|
108 |
```
|
109 |
"""
|
|
|
79 |
)
|
80 |
pipe.transformer = transformer
|
81 |
pipe.text_encoder_2 = text_encoder_2
|
82 |
+
pipe.enable_model_cpu_offload()
|
83 |
pipe.to("cuda")
|
84 |
|
85 |
+
prompt = "a blue robot singing opera with human-like expressions"
|
86 |
image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/robot.png")
|
87 |
|
88 |
+
head_mask = np.zeros_like(image)
|
89 |
+
head_mask[65:580,300:642] = 255
|
90 |
mask_image = Image.fromarray(head_mask)
|
91 |
|
92 |
processor = DepthPreprocessor.from_pretrained("LiheYoung/depth-anything-large-hf")
|
|
|
97 |
image=image,
|
98 |
control_image=control_image,
|
99 |
mask_image=mask_image,
|
|
|
|
|
100 |
num_inference_steps=30,
|
101 |
strength=0.9,
|
102 |
+
guidance_scale=50.0,
|
103 |
generator=torch.Generator().manual_seed(42),
|
104 |
).images[0]
|
105 |
+
make_image_grid([image, control_image, mask_image, output.resize(image.size)], rows=1, cols=4).save("output.png")
|
106 |
+
|
107 |
|
108 |
```
|
109 |
"""
|