UperNet3D#

pydantic model vision_architectures.nets.upernet_3d.UPerNet3DFusionConfig[source]#

Bases: CNNBlockConfig

Show JSON schema
{
   "title": "UPerNet3DFusionConfig",
   "type": "object",
   "properties": {
      "in_channels": {
         "default": null,
         "description": "Calculated based on other parameters",
         "title": "In Channels",
         "type": "null"
      },
      "out_channels": {
         "default": null,
         "description": "Calculated based on other parameters",
         "title": "Out Channels",
         "type": "null"
      },
      "kernel_size": {
         "default": 3,
         "title": "Kernel Size",
         "type": "integer"
      },
      "padding": {
         "anyOf": [
            {
               "type": "integer"
            },
            {
               "items": {
                  "type": "integer"
               },
               "type": "array"
            },
            {
               "type": "string"
            }
         ],
         "default": "same",
         "title": "Padding"
      },
      "stride": {
         "default": 1,
         "title": "Stride",
         "type": "integer"
      },
      "conv_kwargs": {
         "additionalProperties": true,
         "default": {},
         "title": "Conv Kwargs",
         "type": "object"
      },
      "transposed": {
         "default": false,
         "description": "Whether to perform ConvTranspose instead of Conv",
         "title": "Transposed",
         "type": "boolean"
      },
      "normalization": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": "batchnorm3d",
         "title": "Normalization"
      },
      "normalization_pre_args": {
         "default": [],
         "items": {},
         "title": "Normalization Pre Args",
         "type": "array"
      },
      "normalization_post_args": {
         "default": [],
         "items": {},
         "title": "Normalization Post Args",
         "type": "array"
      },
      "normalization_kwargs": {
         "additionalProperties": true,
         "default": {},
         "title": "Normalization Kwargs",
         "type": "object"
      },
      "activation": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": "relu",
         "title": "Activation"
      },
      "activation_kwargs": {
         "additionalProperties": true,
         "default": {},
         "title": "Activation Kwargs",
         "type": "object"
      },
      "sequence": {
         "default": "CNA",
         "enum": [
            "C",
            "AC",
            "CA",
            "CD",
            "CN",
            "DC",
            "NC",
            "ACD",
            "ACN",
            "ADC",
            "ANC",
            "CAD",
            "CAN",
            "CDA",
            "CDN",
            "CNA",
            "CND",
            "DAC",
            "DCA",
            "DCN",
            "DNC",
            "NAC",
            "NCA",
            "NCD",
            "NDC",
            "ACDN",
            "ACND",
            "ADCN",
            "ADNC",
            "ANCD",
            "ANDC",
            "CADN",
            "CAND",
            "CDAN",
            "CDNA",
            "CNAD",
            "CNDA",
            "DACN",
            "DANC",
            "DCAN",
            "DCNA",
            "DNAC",
            "DNCA",
            "NACD",
            "NADC",
            "NCAD",
            "NCDA",
            "NDAC",
            "NDCA"
         ],
         "title": "Sequence",
         "type": "string"
      },
      "drop_prob": {
         "default": 0.0,
         "title": "Drop Prob",
         "type": "number"
      },
      "dim": {
         "title": "Dim",
         "type": "integer"
      },
      "num_features": {
         "title": "Num Features",
         "type": "integer"
      },
      "fused_shape": {
         "anyOf": [
            {
               "maxItems": 3,
               "minItems": 3,
               "prefixItems": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "integer"
                  },
                  {
                     "type": "integer"
                  }
               ],
               "type": "array"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "Shape of the fused feature map. It can also be provided during runtime. If None, highest input resolution is used.",
         "title": "Fused Shape"
      },
      "interpolation_mode": {
         "default": "trilinear",
         "title": "Interpolation Mode",
         "type": "string"
      }
   },
   "required": [
      "dim",
      "num_features"
   ]
}

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_features: int [Required]#
Validated by:
field kernel_size: int = 3#
Validated by:
field fused_shape: tuple[int, int, int] | None = None#

Shape of the fused feature map. It can also be provided during runtime. If None, highest input resolution is used.

Validated by:
field interpolation_mode: str = 'trilinear'#
Validated by:
field in_channels: None = None#

Calculated based on other parameters

Validated by:
field out_channels: None = None#

Calculated based on other parameters

Validated by:
pydantic model vision_architectures.nets.upernet_3d.UPerNet3DConfig[source]#

Bases: FPN3DConfig

Show JSON schema
{
   "title": "UPerNet3DConfig",
   "type": "object",
   "properties": {
      "blocks": {
         "items": {
            "$ref": "#/$defs/FPN3DBlockConfig"
         },
         "title": "Blocks",
         "type": "array"
      },
      "fusion": {
         "$ref": "#/$defs/UPerNet3DFusionConfig"
      },
      "enabled_outputs": {
         "default": [
            "object"
         ],
         "items": {
            "enum": [
               "object",
               "part",
               "scene",
               "material",
               "texture"
            ],
            "type": "string"
         },
         "title": "Enabled Outputs",
         "type": "array",
         "uniqueItems": true
      },
      "num_objects": {
         "anyOf": [
            {
               "type": "integer"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Num Objects"
      }
   },
   "$defs": {
      "FPN3DBlockConfig": {
         "properties": {
            "in_channels": {
               "default": null,
               "description": "Calculated based on other parameters",
               "title": "In Channels",
               "type": "null"
            },
            "out_channels": {
               "default": null,
               "description": "Calculated based on other parameters",
               "title": "Out Channels",
               "type": "null"
            },
            "kernel_size": {
               "default": 3,
               "title": "Kernel Size",
               "type": "integer"
            },
            "padding": {
               "anyOf": [
                  {
                     "type": "integer"
                  },
                  {
                     "items": {
                        "type": "integer"
                     },
                     "type": "array"
                  },
                  {
                     "type": "string"
                  }
               ],
               "default": "same",
               "title": "Padding"
            },
            "stride": {
               "default": 1,
               "title": "Stride",
               "type": "integer"
            },
            "conv_kwargs": {
               "additionalProperties": true,
               "default": {},
               "title": "Conv Kwargs",
               "type": "object"
            },
            "transposed": {
               "default": false,
               "description": "Whether to perform ConvTranspose instead of Conv",
               "title": "Transposed",
               "type": "boolean"
            },
            "normalization": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": "batchnorm3d",
               "title": "Normalization"
            },
            "normalization_pre_args": {
               "default": [],
               "items": {},
               "title": "Normalization Pre Args",
               "type": "array"
            },
            "normalization_post_args": {
               "default": [],
               "items": {},
               "title": "Normalization Post Args",
               "type": "array"
            },
            "normalization_kwargs": {
               "additionalProperties": true,
               "default": {},
               "title": "Normalization Kwargs",
               "type": "object"
            },
            "activation": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": "relu",
               "title": "Activation"
            },
            "activation_kwargs": {
               "additionalProperties": true,
               "default": {},
               "title": "Activation Kwargs",
               "type": "object"
            },
            "sequence": {
               "default": "CNA",
               "enum": [
                  "C",
                  "AC",
                  "CA",
                  "CD",
                  "CN",
                  "DC",
                  "NC",
                  "ACD",
                  "ACN",
                  "ADC",
                  "ANC",
                  "CAD",
                  "CAN",
                  "CDA",
                  "CDN",
                  "CNA",
                  "CND",
                  "DAC",
                  "DCA",
                  "DCN",
                  "DNC",
                  "NAC",
                  "NCA",
                  "NCD",
                  "NDC",
                  "ACDN",
                  "ACND",
                  "ADCN",
                  "ADNC",
                  "ANCD",
                  "ANDC",
                  "CADN",
                  "CAND",
                  "CDAN",
                  "CDNA",
                  "CNAD",
                  "CNDA",
                  "DACN",
                  "DANC",
                  "DCAN",
                  "DCNA",
                  "DNAC",
                  "DNCA",
                  "NACD",
                  "NADC",
                  "NCAD",
                  "NCDA",
                  "NDAC",
                  "NDCA"
               ],
               "title": "Sequence",
               "type": "string"
            },
            "drop_prob": {
               "default": 0.0,
               "title": "Drop Prob",
               "type": "number"
            },
            "dim": {
               "title": "Dim",
               "type": "integer"
            },
            "skip_conn_dim": {
               "title": "Skip Conn Dim",
               "type": "integer"
            },
            "is_deepest": {
               "default": false,
               "description": "True if this is the deepest block in the FPN, else False",
               "title": "Is Deepest",
               "type": "boolean"
            },
            "interpolation_mode": {
               "default": "trilinear",
               "title": "Interpolation Mode",
               "type": "string"
            },
            "merge_method": {
               "default": "add",
               "enum": [
                  "add",
                  "concat"
               ],
               "title": "Merge Method",
               "type": "string"
            }
         },
         "required": [
            "dim",
            "skip_conn_dim"
         ],
         "title": "FPN3DBlockConfig",
         "type": "object"
      },
      "UPerNet3DFusionConfig": {
         "properties": {
            "in_channels": {
               "default": null,
               "description": "Calculated based on other parameters",
               "title": "In Channels",
               "type": "null"
            },
            "out_channels": {
               "default": null,
               "description": "Calculated based on other parameters",
               "title": "Out Channels",
               "type": "null"
            },
            "kernel_size": {
               "default": 3,
               "title": "Kernel Size",
               "type": "integer"
            },
            "padding": {
               "anyOf": [
                  {
                     "type": "integer"
                  },
                  {
                     "items": {
                        "type": "integer"
                     },
                     "type": "array"
                  },
                  {
                     "type": "string"
                  }
               ],
               "default": "same",
               "title": "Padding"
            },
            "stride": {
               "default": 1,
               "title": "Stride",
               "type": "integer"
            },
            "conv_kwargs": {
               "additionalProperties": true,
               "default": {},
               "title": "Conv Kwargs",
               "type": "object"
            },
            "transposed": {
               "default": false,
               "description": "Whether to perform ConvTranspose instead of Conv",
               "title": "Transposed",
               "type": "boolean"
            },
            "normalization": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": "batchnorm3d",
               "title": "Normalization"
            },
            "normalization_pre_args": {
               "default": [],
               "items": {},
               "title": "Normalization Pre Args",
               "type": "array"
            },
            "normalization_post_args": {
               "default": [],
               "items": {},
               "title": "Normalization Post Args",
               "type": "array"
            },
            "normalization_kwargs": {
               "additionalProperties": true,
               "default": {},
               "title": "Normalization Kwargs",
               "type": "object"
            },
            "activation": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": "relu",
               "title": "Activation"
            },
            "activation_kwargs": {
               "additionalProperties": true,
               "default": {},
               "title": "Activation Kwargs",
               "type": "object"
            },
            "sequence": {
               "default": "CNA",
               "enum": [
                  "C",
                  "AC",
                  "CA",
                  "CD",
                  "CN",
                  "DC",
                  "NC",
                  "ACD",
                  "ACN",
                  "ADC",
                  "ANC",
                  "CAD",
                  "CAN",
                  "CDA",
                  "CDN",
                  "CNA",
                  "CND",
                  "DAC",
                  "DCA",
                  "DCN",
                  "DNC",
                  "NAC",
                  "NCA",
                  "NCD",
                  "NDC",
                  "ACDN",
                  "ACND",
                  "ADCN",
                  "ADNC",
                  "ANCD",
                  "ANDC",
                  "CADN",
                  "CAND",
                  "CDAN",
                  "CDNA",
                  "CNAD",
                  "CNDA",
                  "DACN",
                  "DANC",
                  "DCAN",
                  "DCNA",
                  "DNAC",
                  "DNCA",
                  "NACD",
                  "NADC",
                  "NCAD",
                  "NCDA",
                  "NDAC",
                  "NDCA"
               ],
               "title": "Sequence",
               "type": "string"
            },
            "drop_prob": {
               "default": 0.0,
               "title": "Drop Prob",
               "type": "number"
            },
            "dim": {
               "title": "Dim",
               "type": "integer"
            },
            "num_features": {
               "title": "Num Features",
               "type": "integer"
            },
            "fused_shape": {
               "anyOf": [
                  {
                     "maxItems": 3,
                     "minItems": 3,
                     "prefixItems": [
                        {
                           "type": "integer"
                        },
                        {
                           "type": "integer"
                        },
                        {
                           "type": "integer"
                        }
                     ],
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "Shape of the fused feature map. It can also be provided during runtime. If None, highest input resolution is used.",
               "title": "Fused Shape"
            },
            "interpolation_mode": {
               "default": "trilinear",
               "title": "Interpolation Mode",
               "type": "string"
            }
         },
         "required": [
            "dim",
            "num_features"
         ],
         "title": "UPerNet3DFusionConfig",
         "type": "object"
      }
   },
   "required": [
      "blocks",
      "fusion"
   ]
}

Config:
  • arbitrary_types_allowed: bool = True

  • extra: str = ignore

  • validate_default: bool = True

  • validate_assignment: bool = True

  • validate_return: bool = True

Fields:
Validators:
field fusion: UPerNet3DFusionConfig [Required]#
Validated by:
field enabled_outputs: set[Literal['object', 'part', 'scene', 'material', 'texture']] = {'object'}#
Validated by:
field num_objects: int | None = None#
Validated by:
validator validate_before  »  all fields[source]#

Base class method for validating data before creating the model.

validator validate  »  all fields[source]#

Base method for validating the model after creation.

class vision_architectures.nets.upernet_3d.UPerNet3DFusion(config={}, checkpointing_level=0, **kwargs)[source]#

Bases: Module

__init__(config={}, checkpointing_level=0, **kwargs)[source]#

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

concat_features(features, fused_shape=None)[source]#

Concatenate features from different resolutions and interpolate them to the same size.

Parameters:
  • features (list[torch.Tensor]) – List of feature maps to be concatenated. Each feature map should have shape (b, dim, d, h, w).

  • fused_shape (tuple[int, int, int] | None) – Shape to which all feature maps will be interpolated. If None, value entered in the config is used. If that is None too, the shape of the largest feature map is used.

fuse_features(concatenated_features)[source]#
forward(*args, **kwargs)[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.upernet_3d.UPerNet3D(config={}, checkpointing_level=0, **kwargs)[source]#

Bases: Module, PyTorchModelHubMixin

__init__(config={}, checkpointing_level=0, **kwargs)[source]#

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

forward(features, output_shape=None)[source]#

Forward pass of the UPerNet3D model.

Parameters:
  • features (list[torch.Tensor]) – List of feature maps from the FPN. Each feature map should have shape (b, dim, d, h, w).

  • output_shape (tuple[int, int, int], optional) – Desired output shape for the object head. If None, the shape of the highest resolution feature map is used.