Added Ptn Pre Add Channel Axis node and Ptn Pre Flatten node. Also added example workflows to build a model from scratch using Ptn Chained Model node.

This commit is contained in:
HowToSD
2025-03-15 23:51:42 -07:00
parent f36a829fc6
commit b7d2ea5346
15 changed files with 312 additions and 6 deletions
+12
View File
@@ -0,0 +1,12 @@
# Building a Model from Scratch
ComfyUI Pt Wrapper provides composite models that can be easily customized by adjusting parameters. However, you can also build a model from scratch by sequentially combining basic models such as `Conv2D` and `Linear`.
To chain two models, use the **Pt Chained Model** node. This node also supports specifying post-processing after the forward pass of the second model (e.g., activation functions). To define the post-processing step, connect a **Ptf** node (e.g., `Ptf ReLU`).
In some cases, preprocessing may be required before feeding data into the model. For instance, you can use the **Pt Pre Add Channel Axis** node to add a channel dimension to the input tensor or the **Pt Pre Flatten** node to flatten convolutional output before passing it to a linear layer.
The following example workflows demonstrate this approach:
- `./examples/workflows/fashion_mnist_eval_conv_chained_model.json`: Constructs a multi-layer convolutional network from scratch.
- `./examples/workflows/fashion_mnist_train_chained_model.json`: Uses the trained model for evaluation.
+2 -3
View File
@@ -7,13 +7,12 @@ Currently, following archituctures are supported (node names are in parentheses)
* Convolutional Network (Ptn Conv Model)
* ResNet (Ptn Resnet Model)
In addition, a single layer Linear model is supported as an example to illustrate the use (see the bottom of this page on how to use it):
* Linear (Ptn Linear)
You can adjust the model configuration including output dimension on the UI.
The system is designed to be modular. For example, to switch from a linear model to a convolutional model, you only need to replace the model node (see screenshot below).
You can also build a model from scratch by sequentially combining basic models such as `Conv2D` and `Linear` by using the **Pt Chained Model** node. See [Building a Model from Scratch](building_a_model_from_scratch.md) for details.
You can choose to:
* Use your own images
* Use a public dataset
+2
View File
@@ -120,6 +120,8 @@
| [Ptn Linear](ptn_linear.md) | A linear model consisting of a single dense layer. |
| [Ptn Linear Model](ptn_linear_model.md) | A linear model consisting of dense layers. |
| [Ptn Max Pool](ptn_max_pool2d.md) | A maxpool layer. |
| [Ptn Pre Add Channel Axis](ptn_pre_add_channel_axis.md) | Adds a channel axis after the batch axis if the input is rank 3 (bs, h, w) |
| [Ptn Pre Flatten](ptn_pre_flatten.md) | Flattens the input tensor before processing the tensor in the specified model. |
| [Ptn Resnet Model](ptn_resnet_model.md) | A Resnet model consisting of multiple Resnet layers. |
## PyTorch wrapper - Optimizer
| Node | Description |
+1 -1
View File
@@ -25,7 +25,7 @@ t.
| dilation | String |
| groups | Int |
| bias | Boolean |
| padding_mode | Zeros |
| padding_mode | |
## Output
| Data type |
@@ -0,0 +1,18 @@
# Ptn Pre Add Channel Axis
Adds a channel axis after the batch axis if the input is rank 3 (bs, h, w)
before the forward pass by the specified model.
## Input
| Name | Data type |
|---|---|
| model | Ptmodel |
## Output
| Data type |
|---|
| Ptmodel |
<HR>
Category: PyTorch wrapper - Model
ComfyUI Pt Wrapper Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved.
+17
View File
@@ -0,0 +1,17 @@
# Ptn Pre Flatten
Flattens the input tensor before processing the tensor in the specified model.
## Input
| Name | Data type |
|---|---|
| model | Ptmodel |
## Output
| Data type |
|---|
| Ptmodel |
<HR>
Category: PyTorch wrapper - Model
ComfyUI Pt Wrapper Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved.