Coder Social home page Coder Social logo

aifarms / nor-behavior-recognition Goto Github PK

View Code? Open in Web Editor NEW
18.0 3.0 3.0 15.7 MB

Official Implementation of "Vision-based Behavioral Recognition of Novelty Preference in Pigs"

Home Page: https://arxiv.org/abs/2106.12181

Jupyter Notebook 47.40% Python 52.57% Shell 0.03%
action-recognition deep-learning dataset nor computer-vision pig-tracking c3d tsm lrcn behavioral-scoring

nor-behavior-recognition's Introduction

NOR-behavior-recognition

Official Implementation of Vision-based Behavioral Recognition of Novelty Preference in Pigs

Arxiv Paper: https://arxiv.org/abs/2106.12181 (CVPR2021 CV4Animals Workshop Poster)

Dataset

Download the dataset and the annotations from this drive link and place under the data folder. Use the script extract_frames.py to extract and downsample the annotated frames from the dataset. Use statistic.ipynb to truncate clips into a fixed length of either 30 or 60 frames.

Demo

Create a directory checkpoints and place this TSM checkpoint in the checkpoints folder. Run annotate.py using the following sample command:

python3 annotate.py -v data/videos/1815_C2_624_4wk.mp4 -c checkpoints/tsm.best.pth.tar -m data/pncl-maskfilter.png -j data/

LRCN

Run python3 train.py to train the model.

To use pretrained model, download the cnn-pig.pth and rnn-pig.pth from this drive and place in the models/LRCN/checkpoints folder

Run python3 annotate-folder.py to annotate the video dataset

C3D

Download the C3D sports-1m weights using

cd models/C3D
wget https://github.com/adamcasson/c3d/releases/download/v0.1/sports1M_weights_tf.h5 -o c3d_sports1m.h5

Precompute C3D features for the dataset using the script extract.py.

Run python3 train.py to train the model.

Run python3 annotate-folder.py to annotate the video dataset.

TSM

Follow the procedure specified here to generate the dataset. Run the following command to train the model:

python3 main.py pig RGB \
      -p 2 --arch resnet18 --num_segments 8  --gd 20 --lr 0.02 \
      --wd 1e-4 --lr_steps 12 25 --epochs 35 --batch-size 64 -j 16 --dropout 0.5 \
      --consensus_type=avg --eval-freq=1 --shift --shift_div=8 --shift_place=blockres --npb

Run python3 annotate.py to annotate the video dataset.

nor-behavior-recognition's People

Contributors

ani8897 avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

nor-behavior-recognition's Issues

AssertionError

When i run extract_frames.py ,I met a problem, as follows:
D:\anaconda\envs\nor\python.exe E:/NOR/data/extract_frames.py
1815_C1_548_4wk
Traceback (most recent call last):
File "E:/NOR/data/extract_frames.py", line 45, in
assert actions_df.iloc[0]['Behaviour'] == 'Begin Trial'
AssertionError

Can you help me solve the problem? Thanh you so much.

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.