natanielruiz
2017-10-30 b730bbd6ea565d7689964661c53a6074654b5d3b
next
45个文件已删除
2个文件已修改
8815 ■■■■■ 已修改文件
.ipynb_checkpoints/headpose_video.py-checkpoint.ipynb 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.ipynb_checkpoints/load_300W_LP-checkpoint.ipynb 180 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
code/batch_testing.py 152 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
code/batch_testing_preangles.py 158 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
code/datasets.py 97 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
code/hopenet.py 125 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
code/pretrain_SRNet.py 补丁 | 查看 | 原始文档 | blame | 历史
code/test.py 142 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
code/test_new.py 136 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
code/test_preangles_extreme.py 149 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
code/test_resnet50_regression_extreme.py 129 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
code/train.py 293 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
code/train_hopenet_new.py 221 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
code/train_hopenet_sr.py 207 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
code/train_preangles_focalloss.py 224 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
practice/.ipynb_checkpoints/AFLW2000-checkpoint.ipynb 286 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
practice/.ipynb_checkpoints/BIWI-checkpoint.ipynb 299 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
practice/.ipynb_checkpoints/create_filtered_datasets-checkpoint.ipynb 179 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
practice/.ipynb_checkpoints/load_300W-LP-checkpoint.ipynb 197 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
practice/.ipynb_checkpoints/load_AFLW-Copy1-checkpoint.ipynb 196 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
practice/.ipynb_checkpoints/load_AFLW-KEPLER_split-checkpoint.ipynb 225 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
practice/.ipynb_checkpoints/load_AFLW-checkpoint.ipynb 178 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
practice/.ipynb_checkpoints/output_viz-checkpoint.ipynb 208 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
practice/.ipynb_checkpoints/remove_AFLW2000-checkpoint.ipynb 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
practice/.ipynb_checkpoints/remove_KEPLER_test_split-checkpoint.ipynb 128 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
practice/.ipynb_checkpoints/shape_space-checkpoint.ipynb 251 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
practice/.ipynb_checkpoints/smoothing_ypr-checkpoint.ipynb 269 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
practice/.ipynb_checkpoints/vis_AFLW-checkpoint.ipynb 125 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
practice/.ipynb_checkpoints/vis_AFW-checkpoint.ipynb 197 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
practice/.ipynb_checkpoints/vis_LS3D-checkpoint.ipynb 123 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
practice/AFLW2000.ipynb 314 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
practice/BIWI.ipynb 293 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
practice/create_filtered_datasets.ipynb 187 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
practice/headpose_video.py.ipynb 677 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
practice/load_300W-LP.ipynb 245 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
practice/load_AFLW-Copy1.ipynb 196 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
practice/load_AFLW-KEPLER_split.ipynb 190 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
practice/load_AFLW.ipynb 167 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
practice/output_viz.ipynb 208 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
practice/remove_AFLW2000.ipynb 128 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
practice/remove_KEPLER_test_split.ipynb 128 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
practice/shape_space.ipynb 263 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
practice/smoothing_ypr.ipynb 269 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
practice/untitled.txt 补丁 | 查看 | 原始文档 | blame | 历史
practice/vis_AFLW.ipynb 158 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
practice/vis_AFW.ipynb 179 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
practice/vis_LS3D.ipynb 127 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.ipynb_checkpoints/headpose_video.py-checkpoint.ipynb
File was deleted
.ipynb_checkpoints/load_300W_LP-checkpoint.ipynb
File was deleted
code/batch_testing.py
File was deleted
code/batch_testing_preangles.py
File was deleted
code/datasets.py
@@ -164,88 +164,6 @@
        # 122,450
        return self.length
class Pose_300W_LP_SR(Dataset):
    def __init__(self, data_dir, filename_path, transform, img_ext='.jpg', annot_ext='.mat', image_mode='RGB'):
        self.data_dir = data_dir
        self.transform = transform
        self.img_ext = img_ext
        self.annot_ext = annot_ext
        filename_list = get_list_from_filenames(filename_path)
        self.X_train = filename_list
        self.y_train = filename_list
        self.image_mode = image_mode
        self.length = len(filename_list)
    def __getitem__(self, index):
        img = Image.open(os.path.join(self.data_dir, self.X_train[index] + self.img_ext))
        img = img.convert(self.image_mode)
        mat_path = os.path.join(self.data_dir, self.y_train[index] + self.annot_ext)
        # Crop the face
        pt2d = utils.get_pt2d_from_mat(mat_path)
        x_min = min(pt2d[0,:])
        y_min = min(pt2d[1,:])
        x_max = max(pt2d[0,:])
        y_max = max(pt2d[1,:])
        # k = 0.2 to 0.40
        k = np.random.random_sample() * 0.2 + 0.2
        x_min -= 0.6 * k * abs(x_max - x_min)
        y_min -= 2 * k * abs(y_max - y_min)
        x_max += 0.6 * k * abs(x_max - x_min)
        y_max += 0.6 * k * abs(y_max - y_min)
        img = img.crop((int(x_min), int(y_min), int(x_max), int(y_max)))
        # We get the pose in radians
        pose = utils.get_ypr_from_mat(mat_path)
        # And convert to degrees.
        pitch = pose[0] * 180 / np.pi
        yaw = pose[1] * 180 / np.pi
        roll = pose[2] * 180 / np.pi
        rnd = np.random.random_sample()
        if rnd < 0.5:
            ds = 10
            original_size = img.size
            img = img.resize((img.size[0] / ds, img.size[1] / ds), resample=Image.NEAREST)
            img = img.resize((original_size[0], original_size[1]), resample=Image.NEAREST)
        # Flip?
        rnd = np.random.random_sample()
        if rnd < 0.5:
            yaw = -yaw
            roll = -roll
            img = img.transpose(Image.FLIP_LEFT_RIGHT)
        # Blur?
        rnd = np.random.random_sample()
        if rnd < 0.05:
            img = img.filter(ImageFilter.BLUR)
        img_ycc = img.convert('YCbCr')
        # Bin values
        bins = np.array(range(-99, 102, 3))
        binned_pose = np.digitize([yaw, pitch, roll], bins) - 1
        labels = torch.LongTensor(np.concatenate((binned_pose, shape), axis = 0))
        cont_labels = torch.FloatTensor([yaw, pitch, roll])
        # Transforms
        img = transforms.Scale(240)(img)
        img = transforms.RandomCrop(224)(img)
        img_ycc = img.convert('YCbCr')
        img = transforms.ToTensor()
        img_ycc = transforms.ToTensor()
        return img, img_ycc, labels, cont_labels, self.X_train[index]
    def __len__(self):
        # 122,450
        return self.length
class AFLW2000(Dataset):
    def __init__(self, data_dir, filename_path, transform, img_ext='.jpg', annot_ext='.mat', image_mode='RGB'):
        self.data_dir = data_dir
@@ -395,21 +313,6 @@
            yaw = -yaw
            roll = -roll
            img = img.transpose(Image.FLIP_LEFT_RIGHT)
        # Blur?
        # rnd = np.random.random_sample()
        # if rnd < 0.05:
        #     img = img.filter(ImageFilter.BLUR)
        #     if rnd < 0.025:
        #         img = img.filter(ImageFilter.BLUR)
        #
        # rnd = np.random.random_sample()
        # if rnd < 0.05:
        #     nb = np.random.randint(1,5)
        #     img = img.rotate(-nb)
        # elif rnd > 0.95:
        #     nb = np.random.randint(1,5)
        #     img = img.rotate(nb)
        # Bin values
        bins = np.array(range(-99, 102, 3))
code/hopenet.py
@@ -4,41 +4,6 @@
import math
import torch.nn.functional as F
# CNN Model (2 conv layer)
class Simple_CNN(nn.Module):
    def __init__(self):
        super(Simple_CNN, self).__init__()
        self.layer1 = nn.Sequential(
            nn.Conv2d(3, 64, kernel_size=3, padding=0),
            nn.BatchNorm2d(64),
            nn.ReLU(),
            nn.MaxPool2d(2))
        self.layer2 = nn.Sequential(
            nn.Conv2d(64, 128, kernel_size=3, padding=0),
            nn.BatchNorm2d(128),
            nn.ReLU(),
            nn.MaxPool2d(2))
        self.layer3 = nn.Sequential(
            nn.Conv2d(128, 256, kernel_size=3, padding=0),
            nn.BatchNorm2d(256),
            nn.ReLU(),
            nn.MaxPool2d(2))
        self.layer4 = nn.Sequential(
            nn.Conv2d(256, 512, kernel_size=3, padding=0),
            nn.BatchNorm2d(512),
            nn.ReLU(),
            nn.MaxPool2d(2))
        self.fc = nn.Linear(17*17*512, 3)
    def forward(self, x):
        out = self.layer1(x)
        out = self.layer2(out)
        out = self.layer3(out)
        out = self.layer4(out)
        out = out.view(out.size(0), -1)
        out = self.fc(out)
        return out
class Hopenet(nn.Module):
    # This is just Hopenet with 3 output layers for yaw, pitch and roll.
    def __init__(self, block, layers, num_bins, iter_ref):
@@ -224,93 +189,3 @@
        pitch = self.fc_pitch(x)
        roll = self.fc_roll(x)
        return yaw, pitch, roll
class Hopenet_new(nn.Module):
    # This is just Hopenet with 3 output layers for yaw, pitch and roll.
    def __init__(self, block, layers, num_bins):
        self.inplanes = 64
        super(Hopenet_new, self).__init__()
        self.conv1 = nn.Conv2d(3, 64, kernel_size=7, stride=2, padding=3,
                               bias=False)
        self.bn1 = nn.BatchNorm2d(64)
        self.relu = nn.ReLU(inplace=True)
        self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=1)
        self.layer1 = self._make_layer(block, 64, layers[0])
        self.layer2 = self._make_layer(block, 128, layers[1], stride=2)
        self.layer3 = self._make_layer(block, 256, layers[2], stride=2)
        self.layer4 = self._make_layer(block, 512, layers[3], stride=2)
        self.avgpool = nn.AvgPool2d(7)
        self.fc_yaw = nn.Linear(512 * block.expansion, num_bins)
        self.fc_pitch = nn.Linear(512 * block.expansion, num_bins)
        self.fc_roll = nn.Linear(512 * block.expansion, num_bins)
        self.softmax = nn.Softmax()
        self.fc_finetune_new = nn.Linear(512 * block.expansion + 256 * block.expansion + 3, 3)
        self.conv1x1 = nn.Conv2d(1024, 64, kernel_size = 1, stride = 1, bias=False)
        self.maxpool_interm = nn.MaxPool2d(kernel_size=5, stride=3, padding=1)
        self.idx_tensor = Variable(torch.FloatTensor(range(66))).cuda()
        for m in self.modules():
            if isinstance(m, nn.Conv2d):
                n = m.kernel_size[0] * m.kernel_size[1] * m.out_channels
                m.weight.data.normal_(0, math.sqrt(2. / n))
            elif isinstance(m, nn.BatchNorm2d):
                m.weight.data.fill_(1)
                m.bias.data.zero_()
    def _make_layer(self, block, planes, blocks, stride=1):
        downsample = None
        if stride != 1 or self.inplanes != planes * block.expansion:
            downsample = nn.Sequential(
                nn.Conv2d(self.inplanes, planes * block.expansion,
                          kernel_size=1, stride=stride, bias=False),
                nn.BatchNorm2d(planes * block.expansion),
            )
        layers = []
        layers.append(block(self.inplanes, planes, stride, downsample))
        self.inplanes = planes * block.expansion
        for i in range(1, blocks):
            layers.append(block(self.inplanes, planes))
        return nn.Sequential(*layers)
    def forward(self, x):
        x = self.conv1(x)
        x = self.bn1(x)
        x = self.relu(x)
        x = self.maxpool(x)
        x = self.layer1(x)
        x = self.layer2(x)
        x = self.layer3(x)
        x_interm = self.conv1x1(x)
        x_interm = self.relu(x_interm)
        x_interm = self.maxpool_interm(x_interm)
        x_interm = x_interm.view(x_interm.size(0), -1)
        x = self.layer4(x)
        x = self.avgpool(x)
        x = x.view(x.size(0), -1)
        pre_yaw = self.fc_yaw(x)
        pre_pitch = self.fc_pitch(x)
        pre_roll = self.fc_roll(x)
        yaw = self.softmax(pre_yaw)
        yaw = Variable(torch.sum(yaw.data * self.idx_tensor.data, 1), requires_grad=True) * 3 - 99
        pitch = self.softmax(pre_pitch)
        pitch = Variable(torch.sum(pitch.data * self.idx_tensor.data, 1), requires_grad=True) * 3 - 99
        roll = self.softmax(pre_roll)
        roll = Variable(torch.sum(roll.data * self.idx_tensor.data, 1), requires_grad=True) * 3 - 99
        yaw = yaw.view(yaw.size(0), 1)
        pitch = pitch.view(pitch.size(0), 1)
        roll = roll.view(roll.size(0), 1)
        preangles = torch.cat([yaw, pitch, roll], 1)
        # angles predicts the residual
        residuals = self.fc_finetune_new(torch.cat((preangles, x_interm, x), 1))
        final_angles = preangles + residuals
        return pre_yaw, pre_pitch, pre_roll, preangles, final_angles
code/pretrain_SRNet.py
code/test.py
File was deleted
code/test_new.py
File was deleted
code/test_preangles_extreme.py
File was deleted
code/test_resnet50_regression_extreme.py
File was deleted
code/train.py
File was deleted
code/train_hopenet_new.py
File was deleted
code/train_hopenet_sr.py
File was deleted
code/train_preangles_focalloss.py
File was deleted
practice/.ipynb_checkpoints/AFLW2000-checkpoint.ipynb
File was deleted
practice/.ipynb_checkpoints/BIWI-checkpoint.ipynb
File was deleted
practice/.ipynb_checkpoints/create_filtered_datasets-checkpoint.ipynb
File was deleted
practice/.ipynb_checkpoints/load_300W-LP-checkpoint.ipynb
File was deleted
practice/.ipynb_checkpoints/load_AFLW-Copy1-checkpoint.ipynb
File was deleted
practice/.ipynb_checkpoints/load_AFLW-KEPLER_split-checkpoint.ipynb
File was deleted
practice/.ipynb_checkpoints/load_AFLW-checkpoint.ipynb
File was deleted
practice/.ipynb_checkpoints/output_viz-checkpoint.ipynb
File was deleted
practice/.ipynb_checkpoints/remove_AFLW2000-checkpoint.ipynb
File was deleted
practice/.ipynb_checkpoints/remove_KEPLER_test_split-checkpoint.ipynb
File was deleted
practice/.ipynb_checkpoints/shape_space-checkpoint.ipynb
File was deleted
practice/.ipynb_checkpoints/smoothing_ypr-checkpoint.ipynb
File was deleted
practice/.ipynb_checkpoints/vis_AFLW-checkpoint.ipynb
File was deleted
practice/.ipynb_checkpoints/vis_AFW-checkpoint.ipynb
File was deleted
practice/.ipynb_checkpoints/vis_LS3D-checkpoint.ipynb
File was deleted
practice/AFLW2000.ipynb
File was deleted
practice/BIWI.ipynb
File was deleted
practice/create_filtered_datasets.ipynb
File was deleted
practice/headpose_video.py.ipynb
File was deleted
practice/load_300W-LP.ipynb
File was deleted
practice/load_AFLW-Copy1.ipynb
File was deleted
practice/load_AFLW-KEPLER_split.ipynb
File was deleted
practice/load_AFLW.ipynb
File was deleted
practice/output_viz.ipynb
File was deleted
practice/remove_AFLW2000.ipynb
File was deleted
practice/remove_KEPLER_test_split.ipynb
File was deleted
practice/shape_space.ipynb
File was deleted
practice/smoothing_ypr.ipynb
File was deleted
practice/untitled.txt
practice/vis_AFLW.ipynb
File was deleted
practice/vis_AFW.ipynb
File was deleted
practice/vis_LS3D.ipynb
File was deleted