资源简介

本源码是MDNet视频目标跟踪算法在Github上共享的、适用于Python 2.7版本的Python源码。一种可行的运行环境为:CUDA 8.0.61 for Ubuntu 16.04、cuDNN 5.1 for CUDA 8.0、Python 2.7、PyTorch 0.2.0。

资源截图

代码片段和文件信息

import os
import scipy.io
import numpy as np
from collections import OrderedDict

import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
import torch

def append_params(params module prefix):
    for child in module.children():
        for kp in child._parameters.iteritems():
            if p is None: continue
            
            if isinstance(child nn.BatchNorm2d):
                name = prefix + ‘_bn_‘ + k
            else:
                name = prefix + ‘_‘ + k
            
            if name not in params:
                params[name] = p
            else:
                raise RuntimeError(“Duplicated param name: %s“ % (name))


class LRN(nn.Module):
    def __init__(self):
        super(LRN self).__init__()

    def forward(self x):
        #
        # x: N x C x H x W
        pad = Variable(x.data.new(x.size(0) 1 1 x.size(2) x.size(3)).zero_())
        x_sq = (x**2).unsqueeze(dim=1)
        x_tile = torch.cat((torch.cat((x_sqpadpadpadpad)2)
                            torch.cat((padx_sqpadpadpad)2)
                            torch.cat((padpadx_sqpadpad)2)
                            torch.cat((padpadpadx_sqpad)2)
                            torch.cat((padpadpadpadx_sq)2))1)
        x_sumsq = x_tile.sum(dim=1).squeeze(dim=1)[:2:-2::]
        x = x / ((2.+0.0001*x_sumsq)**0.75)
        return x


class MDNet(nn.Module):
    def __init__(self model_path=None K=1):
        super(MDNet self).__init__()
        self.K = K
        self.layers = nn.Sequential(OrderedDict([
                (‘conv1‘ nn.Sequential(nn.Conv2d(3 96 kernel_size=7 stride=2)
                                        nn.ReLU()
                                        LRN()
                                        nn.MaxPool2d(kernel_size=3 stride=2)))
                (‘conv2‘ nn.Sequential(nn.Conv2d(96 256 kernel_size=5 stride=2)
                                        nn.ReLU()
                                        LRN()
                                        nn.MaxPool2d(kernel_size=3 stride=2)))
                (‘conv3‘ nn.Sequential(nn.Conv2d(256 512 kernel_size=3 stride=1)
                                        nn.ReLU()))
                (‘fc4‘   nn.Sequential(nn.Dropout(0.5)
                                        nn.Linear(512 * 3 * 3 512)
                                        nn.ReLU()))
                (‘fc5‘   nn.Sequential(nn.Dropout(0.5)
                                        nn.Linear(512 512)
                                        nn.ReLU()))]))
        
        self.branches = nn.ModuleList([nn.Sequential(nn.Dropout(0.5) 
                                                     nn.Linear(512 2)) for _ in range(K)])
        
        if model_path is not None:
            if os.path.splitext(model_path)[1] == ‘.pth‘:
                self.load_model(model_path)
            elif os.path.splitext(model_path)[1] == ‘.mat‘:
                sel

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

    .......       112  2017-06-06 11:52  py-MDNet-master-for-Python2.7\py-MDNet-master\.gitignore

    .......         0  2017-06-06 11:52  py-MDNet-master-for-Python2.7\py-MDNet-master\dataset\OTB\DragonBaby\.gitkeep

    .......        30  2017-06-06 11:52  py-MDNet-master-for-Python2.7\py-MDNet-master\dataset\OTB\DragonBaby\attrs.txt

    .......      6798  2017-06-06 11:52  py-MDNet-master-for-Python2.7\py-MDNet-master\dataset\OTB\DragonBaby\cfg.json

    .......       869  2017-06-06 11:52  py-MDNet-master-for-Python2.7\py-MDNet-master\dataset\OTB\DragonBaby\cfg.mat

    .......      1490  2017-06-06 11:52  py-MDNet-master-for-Python2.7\py-MDNet-master\dataset\OTB\DragonBaby\groundtruth_rect.txt

    .......     80538  2017-06-06 11:52  py-MDNet-master-for-Python2.7\py-MDNet-master\dataset\OTB\DragonBaby\img\0001.jpg

    .......     86649  2017-06-06 11:52  py-MDNet-master-for-Python2.7\py-MDNet-master\dataset\OTB\DragonBaby\img\0002.jpg

    .......     87579  2017-06-06 11:52  py-MDNet-master-for-Python2.7\py-MDNet-master\dataset\OTB\DragonBaby\img\0003.jpg

    .......     87743  2017-06-06 11:52  py-MDNet-master-for-Python2.7\py-MDNet-master\dataset\OTB\DragonBaby\img\0004.jpg

    .......     85623  2017-06-06 11:52  py-MDNet-master-for-Python2.7\py-MDNet-master\dataset\OTB\DragonBaby\img\0005.jpg

    .......     82421  2017-06-06 11:52  py-MDNet-master-for-Python2.7\py-MDNet-master\dataset\OTB\DragonBaby\img\0006.jpg

    .......     82730  2017-06-06 11:52  py-MDNet-master-for-Python2.7\py-MDNet-master\dataset\OTB\DragonBaby\img\0007.jpg

    .......     81100  2017-06-06 11:52  py-MDNet-master-for-Python2.7\py-MDNet-master\dataset\OTB\DragonBaby\img\0008.jpg

    .......     81830  2017-06-06 11:52  py-MDNet-master-for-Python2.7\py-MDNet-master\dataset\OTB\DragonBaby\img\0009.jpg

    .......     78536  2017-06-06 11:52  py-MDNet-master-for-Python2.7\py-MDNet-master\dataset\OTB\DragonBaby\img\0010.jpg

    .......     77630  2017-06-06 11:52  py-MDNet-master-for-Python2.7\py-MDNet-master\dataset\OTB\DragonBaby\img\0011.jpg

    .......     77141  2017-06-06 11:52  py-MDNet-master-for-Python2.7\py-MDNet-master\dataset\OTB\DragonBaby\img\0012.jpg

    .......     75724  2017-06-06 11:52  py-MDNet-master-for-Python2.7\py-MDNet-master\dataset\OTB\DragonBaby\img\0013.jpg

    .......     75934  2017-06-06 11:52  py-MDNet-master-for-Python2.7\py-MDNet-master\dataset\OTB\DragonBaby\img\0014.jpg

    .......     75277  2017-06-06 11:52  py-MDNet-master-for-Python2.7\py-MDNet-master\dataset\OTB\DragonBaby\img\0015.jpg

    .......     76822  2017-06-06 11:52  py-MDNet-master-for-Python2.7\py-MDNet-master\dataset\OTB\DragonBaby\img\0016.jpg

    .......     76316  2017-06-06 11:52  py-MDNet-master-for-Python2.7\py-MDNet-master\dataset\OTB\DragonBaby\img\0017.jpg

    .......     73082  2017-06-06 11:52  py-MDNet-master-for-Python2.7\py-MDNet-master\dataset\OTB\DragonBaby\img\0018.jpg

    .......     71938  2017-06-06 11:52  py-MDNet-master-for-Python2.7\py-MDNet-master\dataset\OTB\DragonBaby\img\0019.jpg

    .......     68982  2017-06-06 11:52  py-MDNet-master-for-Python2.7\py-MDNet-master\dataset\OTB\DragonBaby\img\0020.jpg

    .......     69480  2017-06-06 11:52  py-MDNet-master-for-Python2.7\py-MDNet-master\dataset\OTB\DragonBaby\img\0021.jpg

    .......     70347  2017-06-06 11:52  py-MDNet-master-for-Python2.7\py-MDNet-master\dataset\OTB\DragonBaby\img\0022.jpg

    .......     68931  2017-06-06 11:52  py-MDNet-master-for-Python2.7\py-MDNet-master\dataset\OTB\DragonBaby\img\0023.jpg

    .......     70270  2017-06-06 11:52  py-MDNet-master-for-Python2.7\py-MDNet-master\dataset\OTB\DragonBaby\img\0024.jpg

............此处省略120个文件信息

评论

共有 条评论