Example #1
0
    def __init__(self,n_classes=6,n_channel=3):
        '''v1 3D Instance Segmentation PointNet
        :param n_classes:3
        :param one_hot_vec:[bs,n_classes]
        '''
        super(FusionInstanceSeg, self).__init__()
        self.psp = PSPNet(bins=(1, 2, 3, 6), backend='resnet18')
        self.conv0 = nn.Conv1d(32, 64, 1)
        self.conv1 = nn.Conv1d(n_channel, 64, 1)
        self.conv2 = nn.Conv1d(64, 64, 1)
        self.conv3 = nn.Conv1d(128, 128, 1)
        self.conv4 = nn.Conv1d(128, 128, 1)
        self.conv5 = nn.Conv1d(128, 1024, 1)
        self.bn1 = nn.BatchNorm1d(64)
        self.bn2 = nn.BatchNorm1d(64)
        self.bn3 = nn.BatchNorm1d(128)
        self.bn4 = nn.BatchNorm1d(128)
        self.bn5 = nn.BatchNorm1d(1024)

        self.n_classes = n_classes
        self.dconv1 = nn.Conv1d(1152+n_classes, 512, 1)
        self.dconv2 = nn.Conv1d(512, 256, 1)
        self.dconv3 = nn.Conv1d(256, 128, 1)
        self.dconv4 = nn.Conv1d(128, 128, 1)
        self.dropout = nn.Dropout(p=0.5)
        self.dconv5 = nn.Conv1d(128, 2, 1)
        self.dbn1 = nn.BatchNorm1d(512)
        self.dbn2 = nn.BatchNorm1d(256)
        self.dbn3 = nn.BatchNorm1d(128)
        self.dbn4 = nn.BatchNorm1d(128)
Example #2
0
 def __init__(self, n_cat=6, nv_prior=1024):
     super(DeformNet, self).__init__()
     self.n_cat = n_cat
     self.psp = PSPNet(bins=(1, 2, 3, 6), backend='resnet18')
     self.instance_color = nn.Sequential(
         nn.Conv1d(32, 64, 1),
         nn.ReLU(),
     )
     self.instance_geometry = nn.Sequential(
         nn.Conv1d(3, 64, 1),
         nn.ReLU(),
         nn.Conv1d(64, 64, 1),
         nn.ReLU(),
         nn.Conv1d(64, 64, 1),
         nn.ReLU(),
     )
     self.instance_global = nn.Sequential(
         nn.Conv1d(128, 128, 1),
         nn.ReLU(),
         nn.Conv1d(128, 1024, 1),
         nn.ReLU(),
         nn.AdaptiveAvgPool1d(1),
     )
     self.category_local = nn.Sequential(
         nn.Conv1d(3, 64, 1),
         nn.ReLU(),
         nn.Conv1d(64, 64, 1),
         nn.ReLU(),
         nn.Conv1d(64, 64, 1),
         nn.ReLU(),
     )
     self.category_global = nn.Sequential(
         nn.Conv1d(64, 128, 1),
         nn.ReLU(),
         nn.Conv1d(128, 1024, 1),
         nn.ReLU(),
         nn.AdaptiveAvgPool1d(1),
     )
     self.assignment = nn.Sequential(
         nn.Conv1d(2176, 512, 1),
         nn.ReLU(),
         nn.Conv1d(512, 256, 1),
         nn.ReLU(),
         nn.Conv1d(256, n_cat * nv_prior, 1),
     )
     self.deformation = nn.Sequential(
         nn.Conv1d(2112, 512, 1),
         nn.ReLU(),
         nn.Conv1d(512, 256, 1),
         nn.ReLU(),
         nn.Conv1d(256, n_cat * 3, 1),
     )
     # Initialize weights to be small so initial deformations aren't so big
     self.deformation[4].weight.data.normal_(0, 0.0001)
Example #3
0
    def __init__(self,
                 model_file=None,
                 use_relu=True,
                 use_cuda=True,
                 truncated_blocks=2,
                 model_type=None,
                 edge_threshold=5,
                 dilation_blocks=1,
                 mode=1,
                 pspnetTest=0):
        super(D2Net, self).__init__()

        if pspnetTest:
            self.dense_feature_extraction = PSPNet(
                n_classes=19,
                pyramids=[6, 3, 2, 1],
                input_size=[713, 713],
                use_bn=True,
                output_features=False,
                output_all=False,
                model_type=model_type,
                truncated_blocks=truncated_blocks,
                dilation_blocks=dilation_blocks,
                d2netTest=True)
        else:
            self.dense_feature_extraction = DenseFeatureExtractionModule(
                use_relu=use_relu,
                use_cuda=use_cuda,
                truncated_blocks=truncated_blocks,
                model_type=model_type,
                dilation_blocks=dilation_blocks)

        self.detection = HardDetectionModule(edge_threshold=edge_threshold)

        self.localization = HandcraftedLocalizationModule()

        if model_file is not None:
            if pspnetTest:
                if use_cuda:
                    self.load_state_dict(torch.load(model_file)['state_dict'],
                                         strict=False)
                else:
                    self.load_state_dict(torch.load(
                        model_file, map_location='cpu')['state_dict'],
                                         strict=False)
            else:
                if use_cuda:
                    self.load_state_dict(torch.load(model_file)['model'])
                else:
                    self.load_state_dict(
                        torch.load(model_file, map_location='cpu')['model'])
Example #4
0
from collections import deque

import torch
import torch.nn as nn
import torch.nn.parallel
import torch.utils.data
import numpy as np
import torch.nn.functional as F
from lib.pspnet import PSPNet
from lib.transformations import quaternion_matrix, quaternion_from_matrix

psp_models = {
    'resnet18':
    lambda: PSPNet(sizes=(1, 2, 3, 6),
                   psp_size=512,
                   deep_features_size=256,
                   backend='resnet18'),
    'resnet34':
    lambda: PSPNet(sizes=(1, 2, 3, 6),
                   psp_size=512,
                   deep_features_size=256,
                   backend='resnet34'),
    'resnet50':
    lambda: PSPNet(sizes=(1, 2, 3, 6),
                   psp_size=2048,
                   deep_features_size=1024,
                   backend='resnet50'),
    'resnet101':
    lambda: PSPNet(sizes=(1, 2, 3, 6),
                   psp_size=2048,
                   deep_features_size=1024,
Example #5
0
    print_function,
    unicode_literals,
)
import torch
import torch.nn as nn

# import lib.utils.etw_pytorch_utils as pt_utils
from collections import namedtuple
from lib.pspnet import PSPNet, Modified_PSPNet
from lib.pointnet2_utils.pointnet2_modules import PointnetFPModule, PointnetSAModuleMSG
import torch.nn.functional as F

psp_models = {
    "resnet18":
    lambda: PSPNet(sizes=(1, 2, 3, 6),
                   psp_size=512,
                   deep_features_size=256,
                   backend="resnet18"),
    "resnet34":
    lambda: PSPNet(sizes=(1, 2, 3, 6),
                   psp_size=512,
                   deep_features_size=256,
                   backend="resnet34"),
    "resnet50":
    lambda: PSPNet(sizes=(1, 2, 3, 6),
                   psp_size=2048,
                   deep_features_size=1024,
                   backend="resnet50"),
    "resnet101":
    lambda: PSPNet(sizes=(1, 2, 3, 6),
                   psp_size=2048,
                   deep_features_size=1024,
from lib.pspnet import PSPNet
from torch import nn

psp_models = {
    'resnet18': lambda: PSPNet(sizes=(1, 2, 3, 6), psp_size=512, backend='resnet18'),
    'resnet34': lambda: PSPNet(sizes=(1, 2, 3, 6), psp_size=512, backend='resnet34'),
    'resnet50': lambda: PSPNet(sizes=(1, 2, 3, 6), psp_size=2048, backend='resnet50'),
    'resnet101': lambda: PSPNet(sizes=(1, 2, 3, 6), psp_size=2048, backend='resnet101'),
    'resnet152': lambda: PSPNet(sizes=(1, 2, 3, 6), psp_size=2048, backend='resnet152')
}


class ModifiedResnet(nn.Module):
    def __init__(self):
        super(ModifiedResnet, self).__init__()
        self.model = psp_models['resnet18']()
        self.model = nn.DataParallel(self.model)

    def forward(self, x):
        x = self.model(x)
        return x

class PoseNetFeat(nn.Module):
    def __init__(self, num_points):
        super(PoseNetFeat, self).__init__()
        self.conv1 = nn.Conv1d(3, 64, 1)
        self.conv2 = nn.Conv1d()

    def forward(self, x, emb):