Coder Social home page Coder Social logo

asbar's Introduction

ASBAR: an Animal Skeleton-Based Action Recognition framework

Examples - walking, sitting, standing, running

Installation

Clone source code:

git clone https://github.com/MitchFuchs/asbar.git

Move into directory:

cd asbar

Create conda environment:

conda env create -f requirements.yaml

Activate conda environment:

conda activate asbar

Launch GUI:

./gui.sh

If the installation was successful, you should see this: 0_start

Prepare Datasets

Follow the same structure as below:

Pose dataset

├── ...
├── data                              # data folder
│   ├── <pose_dataset>                # create a new folder and name it with the name of the pose dataset 
|   │   ├── train                     # create a new folder named 'train' containing training images
|   │   |   ├── train_0000.jpg        # training image (name irrelevant) 
|   │   |   ├── train_0001.jpg        # training image (name irrelevant) 
|   │   |   ├── train_0002.jpg        # training image (name irrelevant)
│   |   |   └── ...                   # etc.
|   │   ├── val                       # create a new folder named 'val' containing validation images
|   │   |   ├── val_0000.jpg          # validation image (name irrelevant) 
|   │   |   ├── val_0001.jpg          # validation image (name irrelevant) 
|   │   |   ├── val_0002.jpg          # validation image (name irrelevant)
│   |   |   └── ...                   # etc.
|   │   ├── train_annotations.json    # add a json file with training annotations structured as below
|   │   └── val_annotations.json      # add a json file with validation annotations structured as below
│   └── ...                   
└── ...

structure of train_annotations.json and val_annotations.json

{
    "data": [
        {
            "file": "train_0000.jpg",
            "species": "Rhesus_macaque",
            "bbox": [x, y, w, h],
            "landmarks": [x_1, y_1, x_2, y_2, ..., x_n, y_n],
            "visibility": [1, 1, ..., 1]
        },
        {
            "file": "train_0001.jpg",
            "species": "Gorilla",
            "bbox": [x, y, w, h],
            "landmarks": [x_1, y_1, x_2, y_2, ..., x_n, y_n],
            "visibility": [1, 0, ..., 0]
        }
    ]
}

Behavior dataset

├── ...
├── data                              # data folder
│   ├── <behavior_dataset>            # create a new folder and name it with the name of the behavior dataset 
|   │   ├── splits                    # create a new folder named 'splits' containing data split files
|   │   |   ├── trainingdata.txt      # text file listing all video names (without file extension) of the training dataset 
|   │   |   ├── validationdata.txt    # text file listing all video names (without file extension) of the validation dataset 
|   │   |   └── testdata.txt          # text file listing all video names (without file extension) of the test dataset 
|   │   ├── videos                    # create a new folder named 'videos' containing all videos
|   │   |   ├── 0000.mp4              # video file (name irrelevant) 
|   │   |   ├── 0001.mp4              # video file (name irrelevant) 
|   │   |   ├── 0002.mp4              # video file (name irrelevant)
│   |   |   └── ...                   # etc.
|   │   └── activities                # add a pickle file with behavior annotations structured as below
│   └── ...                   
└── ...

structure of activities

{
    "sitting": [                                                     # behavior
        [
            0000,                                                    # video name (without file extension) 
            0,                                                       # animal_id (can be left as 0 or for tracking id)
            126,                                                     # number of the first frame displaying the behavior
            166,                                                     # number of the last frame displaying the behavior 
            [(x_1, y_1, x_2, y_2), ..., (x_1, y_1, x_2, y_2)]        # list of bounding box coordinates for each frame, (x_top_left, y_top_left, x_bottom_right, y_bottom_right) 
        ],
        [
            0000,
            0,
            180,
            190,
            [(x_1, y_1, x_2, y_2), ..., (x_1, y_1, x_2, y_2)]
        ],
    ],
    "standing": [                  
        [
            0000,
            0,
            167,
            179,
            [(x_1, y_1, x_2, y_2), ..., (x_1, y_1, x_2, y_2)]
        ],
        [
            0001,
            0,
            23,
            58,
            [(x_1, y_1, x_2, y_2), ..., (x_1, y_1, x_2, y_2)]
        ]
    ]
}

Reference

If you use this material, please cite it as below.

Michael Fuchs, Emilie Genty, Klaus Zuberbühler, Paul Cotofrei. “ASBAR: an Animal Skeleton-Based Action Recognition framework. Recognizing great ape behaviors in the wild using pose estimation with domain adaptation”. In: bioRxiv (2023). doi: 10.1101/2023.09.24.559236. eprint: https://www.biorxiv.org/content/early/2023/09/25/2023.09.24.559236.full.pdf.

@article {asbar_Fuchs2023,
	author = {Michael Fuchs and Emilie Genty and Klaus Zuberb{\"u}hler and Paul Cotofrei},
	title = {ASBAR: an Animal Skeleton-Based Action Recognition framework. Recognizing great ape behaviors in the wild using pose estimation with domain adaptation},
	elocation-id = {2023.09.24.559236},
	year = {2023},
	doi = {10.1101/2023.09.24.559236},
	publisher = {Cold Spring Harbor Laboratory},
	URL = {https://www.biorxiv.org/content/early/2023/09/25/2023.09.24.559236},
	eprint = {https://www.biorxiv.org/content/early/2023/09/25/2023.09.24.559236.full.pdf},
	journal = {bioRxiv}
}

asbar's People

Contributors

mitchfuchs avatar

Stargazers

 avatar  avatar  avatar  avatar Felipe Parodi avatar Chengjie Hu avatar  avatar

Watchers

 avatar

asbar's Issues

deeplabcut models not available/not running

After installation steps, running the GUI and selecting DeepLabCut model with all keypoints (or any) with all visibility (or only visible):

ls: cannot access './models/deeplabcut/': No such file or directory
importing dlc
2023-11-20 15:43:01.861789: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.11.0
Loading DLC 2.2.3...
DLC loaded in light mode; you cannot use any GUI (labeling, relabeling and standalone GUI)
Traceback (most recent call last):
  File "main.py", line 71, in <module>
    main()
  File "main.py", line 65, in main
    use_deeplabcut(args, cfg)
  File "main.py", line 35, in use_deeplabcut
    from tools.dlc_utils import DLC
  File "/data/ProcessedData/user/Github/asbar/tools/dlc_utils.py", line 13, in <module>
    import deeplabcut as dlc
  File "/home/user/.conda/envs/asbar/lib/python3.8/site-packages/deeplabcut/__init__.py", line 78, in <module>
    from deeplabcut.pose_tracking_pytorch import transformer_reID
  File "/home/user/.conda/envs/asbar/lib/python3.8/site-packages/deeplabcut/pose_tracking_pytorch/__init__.py", line 12, in <module>
    from .train_dlctransreid import train_tracking_transformer
  File "/home/user/.conda/envs/asbar/lib/python3.8/site-packages/deeplabcut/pose_tracking_pytorch/train_dlctransreid.py", line 12, in <module>
    import torch
  File "/home/user/.conda/envs/asbar/lib/python3.8/site-packages/torch/__init__.py", line 189, in <module>
    _load_global_deps()
  File "/home/user/.conda/envs/asbar/lib/python3.8/site-packages/torch/__init__.py", line 142, in _load_global_deps
    ctypes.CDLL(lib_path, mode=ctypes.RTLD_GLOBAL)
  File "/home/user/.conda/envs/asbar/lib/python3.8/ctypes/__init__.py", line 373, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: /home/user/.conda/envs/asbar/lib/python3.8/site-packages/torch/lib/../../../../libcublas.so.11: undefined symbol: free_gemm_select, version libcublasLt.so.11

Running on Ubuntu 20.04.6 LTS (GNU/Linux 5.15.0-88-generic x86_64)

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.