Git Product home page Git Product logo

mpn's People

Contributors

ktr-hubrt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

mpn's Issues

error inside dataloader for Shanghai-Tech dataset

Hi,

I am getting the following error when using the Shanghai-Tech dataset:

IndexError: list index out of range
1%|          | 405/67748 [03:18<7:00:28,  2.67it/s, Epoch=1 log, Lr=0.000100, PRe=0.006008(0.0218), FRe=0.000619(0.0013), Dist=0.999953(0.0001)] 

The error is in this line of file model/utils.py (inside the __getitem__ block of Dataloader):

image = np_load_frame(self.videos[video_name]['frame'][frame_name+i], self._resize_height, self._resize_width)

It always occurs at 405/67748. Can you check it on your end? I am using the default training set of Shanghai-Tech with frames extracted at 24 fps. Thanks in advance.

The AUC on Ped2 is only 80+%

I obtained results on the Ped2 dataset that differ by 10 percentage points from the results in the paper, with an epoch of 1000. Is there any configuration setting that I might have overlooked?

Training details

Hi,

First, congratulations for the great paper and thank you for publishing the code.

Unfortunately, I'm not able to reproduce the results in the unsupervised setting described in the paper on the ShanghaiTech dataset. As already described in #20, in the paper you mentioned that you first pre-train using only the frame prediction loss.

So, I did the following steps:

  • I downloaded the ShanghaiTech dataset, whose training is composed of videos.
  • For each of these videos, I created a folder named as the base name of the file, where I extracted the frames using ffmpeg. For example, for the video 01_001.avi I created a folder named 01_001 and I extracted the frames using the command ffmpeg -r 1 -i 01_001.avi -r 1 "01_001/%04d.jpg". As a result, the training folder is organized in the same way as the testing folder.
  • Instead of using the VideoDataLoader, which is used in your Train.py, I used your DataLoader class because this data loader iterates through all frames.
  • I trained from scratch your model (the convAE class) for 10 epochs using only the frame prediction loss.

Is this pre-training step correct or you did something different? After this pre-training step and before the meta-training, do you train again your model using the code in Train.py?

Many thanks in advance.

Could you please upload the trained model on Avenue?

My re-implemented results in unsupervised anomaly detection (1000 epochs for all the three datasets):
Ped2: 95.0%
Avenue: 82.2%
ShanghaiTech: 72.9%

The result on Avenue is much lower than that reported in the paper (89.5%), which is similar to those mentioned in #14 by BenedictGreen and yangyangtiaoguo.

Could you please upload the trained model on Avenue? It is import because MPN achieves the best result on Avenue. Thanks a lot!

the problem of test.py

File "Test.py", line 173, in
outputs, feas, _, _, _, fea_loss = model.forward(imgs[:,:3*4], update_weights, False)
ValueError: not enough values to unpack (expected 6, got 2)

how can I solve it?

Where is the definition of self.memory_size?

File "/home/XXX/MPN/model/base_model.py", line 157, in forward
updated_fea, keys, fea_loss, cst_loss, dis_loss = self.prototype(new_fea, new_fea, weights, train)
File "/home/XXX/anaconda3/envs/pt3.6/lib/python3.6/site-packages/torch/nn/modules/module.py", line 547, in call
result = self.forward(input, **kwargs)
File "/home/XXX/MPN/model/meta_prototype.py", line 84, in forward
multi_heads_weights = multi_heads_weights.view((batch_size, h
w, self.memory_size, 1))
File "/home/XXX/anaconda3/envs/pt3.6/lib/python3.6/site-packages/torch/nn/modules/module.py", line 591, in getattr
type(self).name, name))
AttributeError: 'Meta_Prototype' object has no attribute 'memory_size'

ones needs to be contiguous

The problem I encountered when running train.py was not solved. I also use torch.autograd.detect_anomaly() to find some reasons.Here's the hint is 'No forward pass information available. Enable detect anomaly during forward pass for more information
error

calc and filter function???

What do the calc function and filter function in utils.py mean?

def filter(data, template, radius=5):
arr=np.array(data)
length=arr.shape[0]
newData=np.zeros(length)

for j in range(radius//2,arr.shape[0]-radius//2):
    t=arr[ j-radius//2:j+radius//2+1]
    a=np.multiply(t,template)
    newData[j]=a.sum()
# expand
for i in range(radius//2):
    newData[i]=newData[radius//2]
for i in range(-radius//2,0):
    newData[i]=newData[-radius//2]    
# import pdb;pdb.set_trace()
return newData

def calc(r=5, sigma=2):
k = np.zeros(r)
for i in range(r):
k[i] = 1/((2math.pi)**0.5sigma)*math.exp(-((i-r//2)2/2/(sigma2)))
return k

Training detail

According to the meaning in the original text, the batch size of each GPU is 1, and the total batch size is 4. Is this the understanding?
So,according to the parameters you provided, can you get the original result using 4 blocks of 2080ti?

A question about Train_meta.py

when i run Train_meta.py,a problem happened,
RuntimeError: cannot reshape tensor of 0 elements into shape [0, -1, 128] because the unspecified dimension size -1 can be any value and is ambiguous
could you help me solve this problem?
run train.py is OK

model文件夹中的utils.py文件 __getitem__(self, index)函数中的 return np.concatenate(batch, axis=0)是什么意思??

def __getitem__(self, index):
    
    video_name = self.video_names[index]
    length = self.videos[video_name]['length']-4
    seg_ind = random.sample(range(0, self.num_segs), 1)
    frame_ind = random.sample(range(0, length//self.num_segs), self.task_size)

    batch = []
    for j in range(self.task_size):
        couple = []
        frame_name = seg_ind[0]*(length//self.num_segs)+frame_ind[j]
        for i in range(self._time_step+self._num_pred):
            image = np_load_frame(self.videos[video_name]['frame'][frame_name+i], self._resize_height, self._resize_width)
            # print(self.videos[video_name]['frame'][frame_name+i])
            if self.transform is not None:
                couple.append(self.transform(image))
        batch.append(np.expand_dims(np.concatenate(couple, axis=0), axis=0))
    # import pdb;pdb.set_trace()
    return np.concatenate(batch, axis=0)  

DPU train

How to train DPU? Is AE+DPU trained together? Or do you train AE first and then AE+DPU?

About Test_mate.py file

Test_mate.py 代码报错,原因指向
self.weight = Parameter(torch.Tensor(out_features, in_features))
请问作者这两句的变化是什么意思呢,其他文件都是 128
parser.add_argument('--fdim', type=list, default=[512,256,128,64], help='channel dimension of the features')
parser.add_argument('--pdim', type=list, default=[512,256,128,64], help='channel dimension of the prototypes')

calculate the prototype after decoding process?

Thx for the great work!
I read the code 'base_model.py', in function forward() at line146, I noticed that the code calculated the prototype after decoding process instead of after the encoding process. I read the ori paper with figure 2,which seems that the calculation of the prototype is after encoding process.I am confused. Could you tell me which situation is correct?

    def forward(self, x, weights=None, train=True):
        ...
        fea, skip1, skip2, skip3 = self.encoder(x) 
        new_fea = self.decoder(fea, skip1, skip2, skip3) 
        ....
        new_fea = F.normalize(new_fea, dim=1)
        updated_fea, keys, fea_loss, cst_loss, dis_loss = self.prototype(new_fea, new_fea, weights, train)
        output = self.ohead(updated_fea)

Train_meta details

Excuse me, I want to ask about, to training shanghai data set, if need to use the training model of the shanghai data set on the MPU as pre-trained model to load the encoder.Or can do not need any pre-trained model, and if so, the weight of the encoder is random

How can I solve this problem? thank you.

0%| | 0/120 [00:00<?, ?it/s]Traceback (most recent call last):
File "D:/Project/MPN/Train.py", line 134, in
for j, (imgs) in enumerate(train_batch):
File "C:\ProgramData\Anaconda3\envs\MPN\lib\site-packages\torch\utils\data\dataloader.py", line 521, in next
data = self._next_data()
File "C:\ProgramData\Anaconda3\envs\MPN\lib\site-packages\torch\utils\data\dataloader.py", line 561, in _next_data
data = self._dataset_fetcher.fetch(index) # may raise StopIteration
File "C:\ProgramData\Anaconda3\envs\MPN\lib\site-packages\torch\utils\data_utils\fetch.py", line 49, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "C:\ProgramData\Anaconda3\envs\MPN\lib\site-packages\torch\utils\data_utils\fetch.py", line 49, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File "D:\Project\MPN\model\utils.py", line 144, in getitem
frame_ind = random.sample(range(0, length//self.num_segs), 1)
File "C:\ProgramData\Anaconda3\envs\MPN\lib\random.py", line 320, in sample
raise ValueError("Sample larger than population or is negative")
ValueError: Sample larger than population or is negative
0%| | 0/120 [00:00<?, ?it/s]

Many thanks in advance.

NO panda=1.1.2

I meet an error about install panda==1.1.2
panda version have(0.1, 0.2b0, 0.2b1, 0.2, 0.3.0b0, 0.3.0b2, 0.3.0, 0.4.0, 0.4.1, 0.4.2, 0.4.3, 0.5.0, 0.6.0, 0.6.1, 0.7.0, 0.7.1, 0.7.2, 0.7.3, 0.8.0rc1, 0.8.0, 0.8.1, 0.9.0, 0.9.1, 0.10.0, 0.10.1, 0.11.0, 0.12.0, 0.13.0, 0.13.1, 0.14.0, 0.14.1, 0.15.0, 0.15.1, 0.15.2, 0.16.0, 0.16.1, 0.16.2, 0.17.0, 0.17.1, 0.18.0, 0.18.1, 0.19.0, 0.19.1, 0.19.2, 0.20.0, 0.20.1, 0.20.2, 0.20.3, 0.21.0, 0.21.1, 0.22.0, 0.23.0, 0.23.1, 0.23.2, 0.23.3, 0.23.4, 0.24.0, 0.24.1, 0.24.2, 0.25.0, 0.25.1, 0.25.2, 0.25.3()

What is meaning about labels(0 1)?

Do you know data/frame_ labels_ ped1.npy, what do 0 and 1 stand for here?
I suspect some picture with 1 and some picture with 0, and I can't find the different...

look forward to your reply~

DPU model test

DPU model 该怎么进行测试呢,git中只提供了训练代码。

Details about the datasets

I really appreciate your work. Could you please provide me more details about the datasets to reproduce your results? Such as how to handle them to fit your code.

Location of MPN

According to you paper, MPN seems to be at bottleneck of encoder and decoder but according to your code it seems to be after decoder. Can you please clarify ?

Using the pretrained model get AUC=80.1310% on ped2

I used the provided pretrained model, but got AUC=80.1310% on ped2, which is much lower than the AUC reported in the paper(Ours w DPU: 96.9)
I moved the pretrained model (i.e., ped2_model_1000.pth) to folder exp/ped2/log/, and run the command as

python Test.py --model_dir /home/zyq/code/MPN/exp/ped2/log/ped2_model_1000.pth

Is there anything wrong with my procedure? How can I reproduce the result reported in the paper?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.