ViT3D#

pydantic model vision_architectures.nets.vit_3d.ViT3DEncoderConfig[source]#

Bases: CustomBaseModel

Show JSON schema
{
   "title": "ViT3DEncoderConfig",
   "type": "object",
   "properties": {
      "dim": {
         "title": "Dim",
         "type": "integer"
      },
      "num_heads": {
         "title": "Num Heads",
         "type": "integer"
      },
      "mlp_ratio": {
         "title": "Mlp Ratio",
         "type": "integer"
      },
      "layer_norm_eps": {
         "title": "Layer Norm Eps",
         "type": "number"
      },
      "attn_drop_prob": {
         "default": 0.0,
         "title": "Attn Drop Prob",
         "type": "number"
      },
      "proj_drop_prob": {
         "default": 0.0,
         "title": "Proj Drop Prob",
         "type": "number"
      },
      "mlp_drop_prob": {
         "default": 0.0,
         "title": "Mlp Drop Prob",
         "type": "number"
      },
      "norm_location": {
         "default": "pre",
         "enum": [
            "pre",
            "post"
         ],
         "title": "Norm Location",
         "type": "string"
      },
      "encoder_depth": {
         "title": "Encoder Depth",
         "type": "integer"
      }
   },
   "required": [
      "dim",
      "num_heads",
      "mlp_ratio",
      "layer_norm_eps",
      "encoder_depth"
   ]
}

Config:
  • arbitrary_types_allowed: bool = True

  • extra: str = ignore

  • validate_default: bool = True

  • validate_assignment: bool = True

  • validate_return: bool = True

Fields:
Validators:

field dim: int [Required]#
Validated by:
field num_heads: int [Required]#
Validated by:
field mlp_ratio: int [Required]#
Validated by:
field layer_norm_eps: float [Required]#
Validated by:
field attn_drop_prob: float = 0.0#
Validated by:
field mlp_drop_prob: float = 0.0#
Validated by:
field proj_drop_prob: float = 0.0#
Validated by:
field norm_location: Literal['pre', 'post'] = 'pre'#
Validated by:
field encoder_depth: int [Required]#
Validated by:
pydantic model vision_architectures.nets.vit_3d.ViT3DConfig[source]#

Bases: ViT3DEncoderConfig

Show JSON schema
{
   "title": "ViT3DConfig",
   "type": "object",
   "properties": {
      "dim": {
         "title": "Dim",
         "type": "integer"
      },
      "num_heads": {
         "title": "Num Heads",
         "type": "integer"
      },
      "mlp_ratio": {
         "title": "Mlp Ratio",
         "type": "integer"
      },
      "layer_norm_eps": {
         "title": "Layer Norm Eps",
         "type": "number"
      },
      "attn_drop_prob": {
         "default": 0.0,
         "title": "Attn Drop Prob",
         "type": "number"
      },
      "proj_drop_prob": {
         "default": 0.0,
         "title": "Proj Drop Prob",
         "type": "number"
      },
      "mlp_drop_prob": {
         "default": 0.0,
         "title": "Mlp Drop Prob",
         "type": "number"
      },
      "norm_location": {
         "default": "pre",
         "enum": [
            "pre",
            "post"
         ],
         "title": "Norm Location",
         "type": "string"
      },
      "encoder_depth": {
         "title": "Encoder Depth",
         "type": "integer"
      },
      "patch_size": {
         "maxItems": 3,
         "minItems": 3,
         "prefixItems": [
            {
               "type": "integer"
            },
            {
               "type": "integer"
            },
            {
               "type": "integer"
            }
         ],
         "title": "Patch Size",
         "type": "array"
      },
      "in_channels": {
         "title": "In Channels",
         "type": "integer"
      },
      "num_class_tokens": {
         "title": "Num Class Tokens",
         "type": "integer"
      },
      "drop_prob": {
         "default": 0.0,
         "title": "Drop Prob",
         "type": "number"
      },
      "image_size": {
         "anyOf": [
            {
               "maxItems": 3,
               "minItems": 3,
               "prefixItems": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "integer"
                  },
                  {
                     "type": "integer"
                  }
               ],
               "type": "array"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Image Size"
      },
      "mask_ratio": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Mask Ratio"
      }
   },
   "required": [
      "dim",
      "num_heads",
      "mlp_ratio",
      "layer_norm_eps",
      "encoder_depth",
      "patch_size",
      "in_channels",
      "num_class_tokens"
   ]
}

Config:
  • arbitrary_types_allowed: bool = True

  • extra: str = ignore

  • validate_default: bool = True

  • validate_assignment: bool = True

  • validate_return: bool = True

Fields:
Validators:

field patch_size: tuple[int, int, int] [Required]#
Validated by:
field in_channels: int [Required]#
Validated by:
field num_class_tokens: int [Required]#
Validated by:
field drop_prob: float = 0.0#
Validated by:
field image_size: tuple[int, int, int] | None = None#
Validated by:
field mask_ratio: float | None = None#
Validated by:
pydantic model vision_architectures.nets.vit_3d.ViT3DDecoderConfig[source]#

Bases: CustomBaseModel

Show JSON schema
{
   "title": "ViT3DDecoderConfig",
   "type": "object",
   "properties": {
      "dim": {
         "title": "Dim",
         "type": "integer"
      },
      "num_heads": {
         "title": "Num Heads",
         "type": "integer"
      },
      "mlp_ratio": {
         "title": "Mlp Ratio",
         "type": "integer"
      },
      "layer_norm_eps": {
         "title": "Layer Norm Eps",
         "type": "number"
      },
      "attn_drop_prob": {
         "default": 0.0,
         "title": "Attn Drop Prob",
         "type": "number"
      },
      "proj_drop_prob": {
         "default": 0.0,
         "title": "Proj Drop Prob",
         "type": "number"
      },
      "mlp_drop_prob": {
         "default": 0.0,
         "title": "Mlp Drop Prob",
         "type": "number"
      },
      "norm_location": {
         "default": "pre",
         "enum": [
            "pre",
            "post"
         ],
         "title": "Norm Location",
         "type": "string"
      },
      "decoder_depth": {
         "title": "Decoder Depth",
         "type": "integer"
      }
   },
   "required": [
      "dim",
      "num_heads",
      "mlp_ratio",
      "layer_norm_eps",
      "decoder_depth"
   ]
}

Config:
  • arbitrary_types_allowed: bool = True

  • extra: str = ignore

  • validate_default: bool = True

  • validate_assignment: bool = True

  • validate_return: bool = True

Fields:
Validators:

field dim: int [Required]#
Validated by:
field num_heads: int [Required]#
Validated by:
field mlp_ratio: int [Required]#
Validated by:
field layer_norm_eps: float [Required]#
Validated by:
field attn_drop_prob: float = 0.0#
Validated by:
field mlp_drop_prob: float = 0.0#
Validated by:
field proj_drop_prob: float = 0.0#
Validated by:
field norm_location: Literal['pre', 'post'] = 'pre'#
Validated by:
field decoder_depth: int [Required]#
Validated by:
class vision_architectures.nets.vit_3d.ViT3DEncoder(config)[source]#

Bases: Module, PyTorchModelHubMixin

__init__(config)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(embeddings, return_intermediates=False)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class vision_architectures.nets.vit_3d.ViT3DDecoder(config)[source]#

Bases: Module, PyTorchModelHubMixin

__init__(config)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(q, kv, return_intermediates=False)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class vision_architectures.nets.vit_3d.ViT3DModel(config)[source]#

Bases: Module, PyTorchModelHubMixin

__init__(config)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(pixel_values, spacings, mask_patches=None, mask_token=None, return_intermediates=False)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class vision_architectures.nets.vit_3d.ViT3DMIMDecoder(dim, image_size, in_channels, patch_size)[source]#

Bases: Module

__init__(dim, image_size, in_channels, patch_size)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(encodings)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class vision_architectures.nets.vit_3d.ViT3DMIM(config)[source]#

Bases: Module

__init__(config)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

mask_image(pixel_values)[source]#
class vision_architectures.nets.vit_3d.ViT3DSimMIM(*args, **kwargs)[source]#

Bases: ViT3DMIM, PyTorchModelHubMixin

__init__(config)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

static loss_fn(pred, target, reduction='mean')[source]#
forward(pixel_values, spacings)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.