Giter VIP home page Giter VIP logo

anomaly_prediction's Introduction

Anomaly_Prediction

Pytorch implementation of anomaly prediction for CVPR2018:Future Frame Prediction for Anomaly Detection – A New Baseline.
This implementation used lite-flownet instead of Flownet2SD and the generator network is slightly different.
I only trained the ped2 and avenue datasets, the results:

AUC USCD Ped2 CUHK Avenue
original implementation 95.4% 84.9%
this implementation 95.6% 84.6%

The network pipeline.

Example 0

Environments

PyTorch >= 1.1.
Python >= 3.6.
tensorboardX
cupy
sklearn
Other common packages.

Prepare

  • Download the ped2 and avenue datasets.
USCD Ped2 CUHK Avenue
Google Drive Google Drive
Baidu Cloud: e0qj Baidu Cloud: ufq6
  • Modify 'data_root' in config.py, and then unzip the datasets under your data root.
  • Download the lite-flownet model and put it under the 'models/liteFlownet' folder, or the Flownet2SD model under the 'models/flownet2' folder.
network-default.pytorch FlowNet2-SD.pth
Google Drive Google Drive
Baidu Cloud: auqh Baidu Cloud: v7qr
  • Download the trained model and put them under the 'weights' folder.
ped2_26000.pth avenue_15000.pth
Google Drive Google Drive
Baidu Cloud: 5hu9 Baidu Cloud: 92d8

Train

# Train by default with specified dataset.
python train.py --dataset=avenue
# Train with different batch_size, you might need to tune the learning rate by yourself.
python train.py --dataset=avenue --batch_size=16
# Set the max training iterations.
python train.py --dataset=avenue --iters=80000
# Set the save interval and the validation interval.
python train.py --dataset=avenue --save_interval=2000 --val_interval=2000
# Resume training with the latest trained model or a specified model.
python train.py --dataset=avenue --resume latest [or avenue_10000.pth]
# Train with Flownet2SD instead of lite-flownet.
python train.py --dataset=avenue --flownet=2sd
# Visualize the optic flow during training.
python train.py --dataset=avenue --show_flow

Use tensorboard

tensorboard --logdir=tensorboard_log/ped2_bs4

Example 1

Evalution

# Validate with a trained model.
python evaluate.py --dataset=ped2 --trained_model=ped2_26000.pth
# Show and save the psnr curve and the difference heatmap between the gt frame and the 
# generated frame during evaluating. This drops fps.
python evaluate.py --dataset=ped2 --trained_model=ped2_26000.pth --show_curve --show_heatmap

Example 2

anomaly_prediction's People

Contributors

feiyuhuahuo 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

Watchers

 avatar  avatar  avatar  avatar

anomaly_prediction's Issues

About running time.

Hello, thank you so much for sharing such great code. I have a question. Your code is running at about 50 FPS, while the speed given in the original paper is 25 FPS. What do you think caused this? Is PyTorch faster? The original paper used TITAN, and I used 1080Ti.

About FlowNet and optimizer

Hello, I have seen that you have provided two kinds of flownet options. I would like to ask which performance is better. I tested it. It seems that Lite flownet and flownet2sd have similar performance. Is that right?

Another question, I read your commits history. You tried SGD optimizer, and then you changed back to Adam. Is Adam better in your experiment?

Other dataset

Hi! Thanks for your work! And I have to questions.
First, what I want to ask is that if I want to test in other dataset, such as Mall, what should I do?
And second, if I want to taste to make a new dataset, how should I label it?
Looking forward to your reply, thank you again.

pretrained model

hello, could you give a link of pretrained model of litenet and flownet?

Evaluation incorrect?

Isn't the evaluation calculation wrong?
Considering Ped2, why are the scores normalized between 0 and 1 for each of the 12 video clips individually? This isn't correct as the camera view is the same in all of the clips.

about 'weights' folder

hi,before training,you said"Download the trained model and put them under the 'weights' folder"
but i didn't find the 'weights' folder,could you tell me where the 'weights'? folder is?
thanks!

About the lite-flownet

Hi!Do you use the pre-training weights of the lite-flownet author ? Also, which version of lite-flownet are you using?thank you very
much!

tensorboard --logdir=tensorboard_log/ped2_bs4

你好,请问如何自定义自己想要可视化某一张图片?(把自己想要的某张图片的target_frame),另外在可视化界面中,怎么调整target_frame上面的黄色横线的尺度单位?
很感谢你的工作!期待回复!

train.py

I run train.py a night. But nothing was showed on the terminal.how long do you train?
image

About AUC

I want to know how to get AUC value? Thanks.

train.py

When I run python train.py --dataset=avenue,The following problems arise
image

Regarding Channel information when loading video

Shouldn't the channel information be part of frames when you are reading frames with 3 channels?

That is (n, 12, 256, 256) should be (n, 12, 3, 256, 256). Or is it that your code will only work with inputs of 1 channel?

EDIT: Or do we just multiply the channel information with clip length?
EDIT2: Got it!! :)

Other datasets

hello,have you run experiments on other datasets (like ped1 and shanghaitech)? Is there a weights file for these two datasets?

About Unet

Hello,
After I read your code,I found that the unet.py does not implement the Concatenate operation,as the picture shows.
Am I right?
Thanks for your reply!
image

segmentation fault (core dumped) error?

The work is very niubility, and I appreciate it. But when i exec the "train.py" for about 100 epoch, the terminal display "segmentation fault (core dumped)". I try to solve this problem, but i failed. Anyone can help me? thank you very very very very muchhhhh!

train.py

我在训练时卡在dataloader循环之前。我注意到你在另一个工作 pre_ano_detection那边也有相同的问题,程序卡住下不去,你的这份代码我也遇到了同样的问题,请问你知道原因吗
image

About learning rate

Hello, how can I adjust the learning rate if I change the network structure? I am a beginner in deep learning. If you could give me some experience, I would be very grateful.

About EER

Hello,Could you tell me how to compute Equal Error Rate?
By the way,do you have any idea to improve your prediction model?
Have you tried to add a reconstruction model after the prediction model?

Test

Another question:For example,after I trained the Avenue/training datasets,how to do test the Avenue/testing datasets?

Train

Hello,Thanks for your work!
I have a question,when I running the "train.py" in pycharm,it no problem.
However,when I used Linux terminal run "python train.py --datasets=avenue",it said "ModuleNotFoundError: No module named 'cupy' ".But my packages including the 'cupy'.Thus,I don't know where is the problem.
I'm looking forward for your response.Thanks!

Question for "Dataset.py" file

First of all, thank you for such a clean implementation and comments at different places to understand what's going on. Kudos and so much to learn. Also, cheers for still addressing issues! :)

So, in your Dataset.py file are you sampling multiple sequences or just in order the frames appear?
For example, if video frames are [01, 02, 03, 04, 05, 06, 07, 08, 09, 10] then are you doing (assuming input video length 5):

  1. [01, 02, 03, 04, 05] and then[06, 07, 08, 09, 10]?
  2. (or) Randomly sampling a sequence of 5 consecutive frames from the video (random start point).

If you doing the latter (point 2), are you sampling multiple times (in order to get more possible sequences from the same video)?

about shanghaitech dataset

hi,when i used shanghaitech dataset for training, there has been no response since the program started
but this code works well on avenue and ped2

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.