Coder Social home page Coder Social logo

trustaiot / yoga Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 545 KB

Code for Pattern Recognition (Elsevier) 2023 paper: YOGA: Deep Object Detection in the Wild with Lightweight Feature Learning and Multiscale Attention

Home Page: https://tluocs.github.io

License: GNU General Public License v3.0

Dockerfile 0.64% Shell 0.88% Python 87.69% Jupyter Notebook 10.78%
object-detection edge-computing

yoga's Introduction

Source code and evaluation scripts for the following paper (Pattern Recognition 2023):

Link to paper
arXiv

YOGA: Deep Object Detection in the Wild with Lightweight Feature Learning and Multiscale Attention

Abstract

We introduce YOGA, a deep learning based yet lightweight object detection model that can operate on low-end edge devices while still achieving competitive accuracy. The YOGA architecture consists of a two-phase feature learning pipeline with a cheap linear transformation, which learns feature maps using only half of the convolution filters required by conventional convolutional neural networks. In addition, it performs multi-scale feature fusion in its neck using an attention mechanism instead of the naive concatenation used by conventional detectors. YOGA is a flexible model that can be easily scaled up or down by several orders of magnitude to fit a broad range of hardware constraints. We evaluate YOGA on COCO-val and COCO-testdev datasets with over 10 state-of-the-art object detectors. The results show that YOGA strikes the best trade-off between model size and accuracy (up to 22% increase of AP and 23โ€“34% reduction of parameters and FLOPs), making it an ideal choice for deployment in the wild on low-end edge devices. This is further affirmed by our hardware implementation and evaluation on NVIDIA Jetson Nano.

BibTex provided below for your citation:

@article{pattern2023yoga,
  title={YOGA: Deep Object Detection in the Wild with Lightweight Feature Learning and Multiscale Attention},
  author={Sunkara, Raja and Luo, Tie},
  journal={Pattern Recognition},
  volume={139},
  pages={109451},
  year={2023},
  publisher={Elsevier},
  doi= {10.1016/j.patcog.2023.109451},
}

YOGA Building Block:

losses

Installation

# Download the code 
git clone https://github.com/LabSAINT/YOGA

# Create an environment
cd SPD-Conv
conda create -n YOGA python==3.7.4
conda activate YOGA
conda install pytorch==1.13.1 torchvision==0.14.1 torchaudio==0.13.1 pytorch-cuda=11.7 -c pytorch -c nvidia
pip3 install -r requirements.txt

YOGA

YOGA has been trained and evaluated using the COCO-2017 dataset. Below are the pretrained models, evaluation, and training scripts

Pre-trained models

The table below gives an overview of the results of our models

$$\textbf{Model}$$ $$\textbf{AP}$$ $$\textbf{AP}_\textbf{S}$$ $$\textbf{Params (M)}$$ $$\textbf{FLOPs (B)}$$
YOGA-n 32.3 15.2 1.9 4.9
YOGA-s 40.7 23.0 7.6 16.6
YOGA-m 45.2 28.0 16.3 34.6
YOGA-l 48.9 31.8 33.6 71.8
Evaluation

The script val.py can be used to evaluate the pre-trained models

  $ python val.py --weights 'pth_models/YOGA-n.pt' --img 640 --iou 0.65 --half --batch-size 1 --data data/coco.yaml
  $ python val.py --weights 'pth_models/YOGA-s.pt' --img 640 --iou 0.65 --half --batch-size 1 --data data/coco.yaml
  $ python val.py --weights 'pth_models/YOGA-m.pt' --img 640 --iou 0.65 --half --batch-size 1 --data data/coco.yaml   
Training

The script train.py is used to train YOGA models

# nano model
python3 train.py --data coco.yaml --cfg ./models/YOGA-n.yaml --hyp ./data/hyps/YOGA-n.yaml --weights '' --batch-size 128 --epochs 300 --sync-bn --project YOGA --name YOGA-n --label-smoothing 0.01

# small model
python3 train.py --data coco.yaml --cfg ./models/YOGA-s.yaml --hyp ./data/hyps/YOGA-s.yaml --weights '' --batch-size 128 --epochs 300 --sync-bn --project YOGA --name YOGA-s --linear-lr

# medium model
python3 train.py --data coco.yaml --cfg ./models/YOGA-m.yaml --hyp ./data/hyps/YOGA-m.yaml --weights '' --batch-size 64 --epochs 300 --sync-bn --project YOGA --name YOGA-m

# large model

python3 train.py --data coco.yaml --cfg ./models/YOGA-l.yaml --hyp ./data/hyps/YOGA-m.yaml --weights '' --batch-size 20 --epochs 250 --sync-bn --project YOGA --name YOGA-l

AttributeError Issue Resolution

If you encounter the error: AttributeError: 'Upsample' object has no attribute 'recompute_scale_factor' A solution has been provided in the YOLOv5 GitHub repository.

Details of the Issue:

  • Error: AttributeError: 'Upsample' object has no attribute 'recompute_scale_factor'
  • Resolution: Amend the line containing recompute_scale_factor=self.recompute_scale_factor in E:\condaaa\lib\site-packages\torch\nn\modules\upsampling.py file.

For a detailed discussion and context, please refer to this GitHub issue comment.

yoga's People

Contributors

raja-sunkara avatar tluocs avatar rajasunkara avatar

Stargazers

 avatar  avatar

Watchers

Kostas Georgiou avatar

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.