You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/source/en/modular_diffusers/custom_blocks.md
+23-16Lines changed: 23 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,11 +13,19 @@ specific language governing permissions and limitations under the License.
13
13
14
14
# Building Custom Blocks
15
15
16
-
Modular Diffusers allows you to create custom blocks that can be used in a pipeline. This guide will show you how to create a custom block, define its inputs and outputs, and implement the computation logic.
16
+
Modular Diffusers allows you to create custom blocks that can be plugged into Modular Pipelines. This guide will show you how to create and use a custom block.
17
17
18
-
Let's create a custom block that uses the Florence2 model to process an input image and generate a mask for inpainting
18
+
First let's take a look at the structure of our custom block project:
19
19
20
-
First let's define a custom block in a file called `block.py`:
20
+
```shell
21
+
.
22
+
├── block.py
23
+
└── modular_config.json
24
+
```
25
+
26
+
The code to define the custom block lives in a file called `block.py`. The `modular_config.json` file contains metadata for loading the block with Modular Diffusers.
27
+
28
+
In this example, we will create a custom block that uses the Florence 2 model to process an input image and generate a mask for inpainting
21
29
22
30
```py
23
31
from typing import List, Union
@@ -32,7 +40,7 @@ from diffusers.modular_pipelines import (
32
40
ComponentSpec,
33
41
OutputParam,
34
42
)
35
-
from transformers import AutoProcessor, AutoModelForCausalLM
43
+
from transformers import AutoProcessor, Florence2ForConditionalGeneration
0 commit comments