ktr-hubrt / mpn Goto Github PK
View Code? Open in Web Editor NEWOfficial codes of CVPR21 paper: Learning Normal Dynamics in Videos with Meta Prototype Network
Official codes of CVPR21 paper: Learning Normal Dynamics in Videos with Meta Prototype Network
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.
what version of python in your paper?
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?
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:
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.VideoDataLoader
, which is used in your Train.py
, I used your DataLoader
class because this data loader iterates through all frames.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.
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.
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?
If the calc and filters functions are not used, why does the result decrease by about 2%?
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, hw, 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'
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
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?
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
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)
Thx a lot!
I retrained the model on two datasets, but did not get the same results as in the paper. Could you pls upload the model trained on ShanghaiTech and Avenue? Or provide more detailed parameters for the training settings.
How to train DPU? Is AE+DPU trained together? Or do you train AE first and then AE+DPU?
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')
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)
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
Regarding the ShanghaiTech dataset, how to adapt it to your work after downloading
Hi,
Can you please make the pretrained models on Google Drive/OneDrive/DropBox? We can't access baidu from my current location,
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.
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()
232行outputs = torch.cat(pred,1)中pred未定义
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~
Does the UCSD data set need to be preprocessed?
DPU model 该怎么进行测试呢,git中只提供了训练代码。
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.
Hi,
Your google Drive folder named 'few-shot' seem empty. I can definitely see a model under 'unsupervised' folder.
Can you please check?
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 ?
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?
Hi @ktr-hubrt ,
Can you please provide the pre-trained model for your model meta-trained at k=0 for UCF-Crime given in Table 2?
Could you give some advise of the similarity ?
in the project , the author do not use the similarity , why?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.