Skip to content

grid_embedder

allennlp.modules.vision.grid_embedder

[SOURCE]


GridEmbedder

class GridEmbedder(nn.Module,  Registrable)

A GridEmbedder takes a batch of images as a tensor with shape (batch_size, color_channels, height, width), and returns an ordered dictionary of tensors with shape (batch_size, *), each representing a specific feature.

forward

class GridEmbedder(nn.Module,  Registrable):
 | ...
 | def forward(
 |     self,
 |     images: FloatTensor,
 |     sizes: IntTensor
 | ) -> "OrderedDict[str, FloatTensor]"

get_feature_names

class GridEmbedder(nn.Module,  Registrable):
 | ...
 | def get_feature_names(self) -> Tuple[str, ...]

Returns the feature names, in order, i.e. the keys of the ordered output dictionary from .forward().

NullGridEmbedder

@GridEmbedder.register("null")
class NullGridEmbedder(GridEmbedder)

A GridEmbedder that returns the input image as given.

forward

class NullGridEmbedder(GridEmbedder):
 | ...
 | def forward(
 |     self,
 |     images: FloatTensor,
 |     sizes: IntTensor
 | ) -> "OrderedDict[str, FloatTensor]"

get_feature_names

class NullGridEmbedder(GridEmbedder):
 | ...
 | def get_feature_names(self) -> Tuple[str, ...]

ResnetBackbone

@GridEmbedder.register("resnet_backbone")
class ResnetBackbone(GridEmbedder):
 | def __init__(self) -> None

Runs an image through ResNet, as implemented by torchvision.

forward

class ResnetBackbone(GridEmbedder):
 | ...
 | def forward(
 |     self,
 |     images: FloatTensor,
 |     sizes: IntTensor
 | ) -> "OrderedDict[str, FloatTensor]"

get_feature_names

class ResnetBackbone(GridEmbedder):
 | ...
 | def get_feature_names(self) -> Tuple[str, ...]