UNet1DModel¶
The UNet model was originally introduced by Ronneberger et al. for biomedical image segmentation, but it is also commonly used in 🤗 Diffusers because it outputs images that are the same size as the input. It is one of the most important components of a diffusion system because it facilitates the actual diffusion process. There are several variants of the UNet model in 🤗 Diffusers, depending on it's number of dimensions and whether it is a conditional model or not. This is a 1D UNet model.
The abstract from the paper is:
There is large consent that successful training of deep networks requires many thousand annotated training samples. In this paper, we present a network and training strategy that relies on the strong use of data augmentation to use the available annotated samples more efficiently. The architecture consists of a contracting path to capture context and a symmetric expanding path that enables precise localization. We show that such a network can be trained end-to-end from very few images and outperforms the prior best method (a sliding-window convolutional network) on the ISBI challenge for segmentation of neuronal structures in electron microscopic stacks. Using the same network trained on transmitted light microscopy images (phase contrast and DIC) we won the ISBI cell tracking challenge 2015 in these categories by a large margin. Moreover, the network is fast. Segmentation of a 512x512 image takes less than a second on a recent GPU. The full implementation (based on Caffe) and the trained networks are available at http://lmb.informatik.uni-freiburg.de/people/ronneber/u-net.
mindone.diffusers.UNet1DModel
¶
Bases: ModelMixin
, ConfigMixin
A 1D UNet model that takes a noisy sample and a timestep and returns a sample shaped output.
This model inherits from [ModelMixin
]. Check the superclass documentation for it's generic methods implemented
for all models (such as downloading or saving).
PARAMETER | DESCRIPTION |
---|---|
sample_size |
Default length of sample. Should be adaptable at runtime.
TYPE:
|
in_channels |
Number of channels in the input sample.
TYPE:
|
out_channels |
Number of channels in the output.
TYPE:
|
extra_in_channels |
Number of additional channels to be added to the input of the first down block. Useful for cases where the input data has more channels than what the model was initially designed for.
TYPE:
|
time_embedding_type |
Type of time embedding to use.
TYPE:
|
freq_shift |
Frequency shift for Fourier time embedding.
TYPE:
|
flip_sin_to_cos |
Whether to flip sin to cos for Fourier time embedding.
TYPE:
|
down_block_types |
Tuple of downsample block types.
TYPE:
|
up_block_types |
Tuple of upsample block types.
TYPE:
|
block_out_channels |
Tuple of block output channels.
TYPE:
|
mid_block_type |
Block type for middle of UNet.
TYPE:
|
out_block_type |
Optional output processing block of UNet.
TYPE:
|
act_fn |
Optional activation function in UNet blocks.
TYPE:
|
norm_num_groups |
The number of groups for normalization.
TYPE:
|
layers_per_block |
The number of layers per block.
TYPE:
|
downsample_each_block |
Experimental feature for using a UNet without upsampling.
TYPE:
|
Source code in mindone/diffusers/models/unets/unet_1d.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 |
|
mindone.diffusers.UNet1DModel.construct(sample, timestep, return_dict=False)
¶
The [UNet1DModel
] forward method.
PARAMETER | DESCRIPTION |
---|---|
sample |
The noisy input tensor with the following shape
TYPE:
|
timestep |
The number of timesteps to denoise an input.
TYPE:
|
return_dict |
Whether or not to return a [
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Union[UNet1DOutput, Tuple]
|
[ |
Source code in mindone/diffusers/models/unets/unet_1d.py
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 |
|
mindone.diffusers.models.unets.unet_1d.UNet1DOutput
dataclass
¶
Bases: BaseOutput
The output of [UNet1DModel
].
PARAMETER | DESCRIPTION |
---|---|
sample |
The hidden states output from the last layer of the model.
TYPE:
|
Source code in mindone/diffusers/models/unets/unet_1d.py
28 29 30 31 32 33 34 35 36 37 38 |
|