Example #1
0
    def __init__(self, cfg):
        super(VoxMeshHead, self).__init__()

        self.setup(cfg)
        # backbone
        self.backbone, feat_dims = build_backbone(
            cfg.MODEL.VOXEL_HEAD.RGB_BACKBONE)
        # voxel head
        cfg.MODEL.VOXEL_HEAD.COMPUTED_INPUT_CHANNELS = feat_dims[-1]
        self.voxel_head = VoxelHead(cfg)
        # mesh head
        cfg.MODEL.MESH_HEAD.COMPUTED_INPUT_CHANNELS = sum(feat_dims)
        self.mesh_head = MeshRefinementHead(cfg)
Example #2
0
    def __init__(self, cfg):
        super(Pixel2MeshHead, self).__init__()

        # fmt: off
        backbone = cfg.MODEL.MESH_HEAD.RGB_BACKBONE
        self.ico_sphere_level = cfg.MODEL.MESH_HEAD.ICO_SPHERE_LEVEL
        # fmt: on

        self.register_buffer("K", get_blender_intrinsic_matrix())
        # backbone
        self.backbone, feat_dims = build_backbone(backbone)
        # mesh head
        cfg.MODEL.MESH_HEAD.COMPUTED_INPUT_CHANNELS = sum(feat_dims)
        self.mesh_head = MeshRefinementHead(cfg)
Example #3
0
    def __init__(self, cfg):
        super(VoxMeshHead, self).__init__()

        # fmt: off
        backbone = cfg.MODEL.BACKBONE
        self.cubify_threshold = cfg.MODEL.VOXEL_HEAD.CUBIFY_THRESH
        self.voxel_size = cfg.MODEL.VOXEL_HEAD.VOXEL_SIZE
        # fmt: on

        self.register_buffer("K", get_blender_intrinsic_matrix())
        # backbone
        self.backbone, feat_dims = build_backbone(backbone)
        # voxel head
        cfg.MODEL.VOXEL_HEAD.COMPUTED_INPUT_CHANNELS = feat_dims[-1]
        self.voxel_head = VoxelHead(cfg)
        # mesh head
        cfg.MODEL.MESH_HEAD.COMPUTED_INPUT_CHANNELS = sum(feat_dims)
        self.mesh_head = MeshRefinementHead(cfg)
Example #4
0
    def __init__(self, cfg):
        nn.Module.__init__(self)

        self.setup(cfg)
        self.single_view_voxel_prediction = cfg.MODEL.VOXEL_HEAD.SINGLE_VIEW

        # backbone
        self.backbone, feat_dims = build_backbone(
            cfg.MODEL.VOXEL_HEAD.RGB_BACKBONE)
        # voxel head
        cfg.MODEL.VOXEL_HEAD.COMPUTED_INPUT_CHANNELS = feat_dims[-1]
        self.voxel_head = VoxelHead(cfg)

        # multi-view feature fusion
        prefusion_feat_dims = sum(feat_dims)
        postfusion_feat_dims = self.init_feature_fusion(
            cfg, prefusion_feat_dims)

        # mesh head
        # times 3 cuz multi-view (mean, avg, std) features will be used
        cfg.MODEL.MESH_HEAD.COMPUTED_INPUT_CHANNELS = postfusion_feat_dims
        self.mesh_head = MeshRefinementHead(cfg, self.fuse_multiview_features)
Example #5
0
    def init_mesh_head(self, cfg):
        self.contrastive_depth_type = cfg.MODEL.CONTRASTIVE_DEPTH_TYPE
        if cfg.MODEL.MESH_HEAD.RGB_FEATURES_INPUT:
            if getattr(self, "pre_voxel_rgb_cnn", None) is not None:
                # reuse RGB CNN is already exists
                self.post_voxel_rgb_cnn = self.pre_voxel_rgb_cnn
                self.post_voxel_rgb_feat_dims = self.pre_voxel_rgb_feat_dims
            else:
                self.post_voxel_rgb_cnn, self.post_voxel_rgb_feat_dims \
                        = build_backbone(cfg.MODEL.MESH_HEAD.RGB_BACKBONE)
        else:
            self.post_voxel_rgb_cnn = None
            self.post_voxel_rgb_feat_dims = [0]

        if cfg.MODEL.MESH_HEAD.DEPTH_FEATURES_INPUT:
            self.post_voxel_depth_feat_dims = self.init_post_voxel_depth_cnn(
                cfg)
        else:
            self.post_voxel_depth_cnn = None
            self.post_voxel_depth_feat_dims = [0]

        # multi-view feature fusion
        self.prefusion_feat_dims = sum(self.post_voxel_rgb_feat_dims) \
                            + sum(self.post_voxel_depth_feat_dims)
        self.postfusion_feat_dims = self.init_feature_fusion(
            cfg, self.prefusion_feat_dims)

        # mesh head
        cfg.MODEL.MESH_HEAD.COMPUTED_INPUT_CHANNELS = self.postfusion_feat_dims
        self.mesh_head = MeshRefinementHead(cfg, self.fuse_multiview_features)
        # depth renderer
        self.depth_renderer = DepthRenderer(cfg)

        print({
            "post_voxel_rgb_feat_dims": self.post_voxel_rgb_feat_dims,
            "post_voxel_depth_feat_dims": self.post_voxel_depth_feat_dims,
            "prefusion_feat_dims": self.prefusion_feat_dims,
            "postfusion_feat_dims": self.postfusion_feat_dims
        })