Metadata-Version: 2.1
Name: asone
Version: 0.1.2.dev9
Summary: UNKNOWN
Home-page: https://github.com/axcelerateai/asone
Author: AxcelerateAI
Author-email: 
License: BSD 2-clause
Keywords: asone bytetrack deepsort norfair yolo yolox yolor yolov5 yolov7 installation inferencing
Platform: UNKNOWN
Classifier: Development Status :: 1 - Planning
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: Microsoft :: Windows :: Windows 10
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Description-Content-Type: text/markdown
License-File: LICENCE
Requires-Dist: Cython
Requires-Dist: easydict
Requires-Dist: gdown
Requires-Dist: lap
Requires-Dist: loguru
Requires-Dist: norfair
Requires-Dist: numpy
Requires-Dist: onnxruntime-gpu (==1.12.1)
Requires-Dist: opencv-python
Requires-Dist: pandas
Requires-Dist: pyyaml
Requires-Dist: scipy
Requires-Dist: tabulate
Requires-Dist: torch
Requires-Dist: torchvision
Requires-Dist: typing-extensions (==3.10.0.2)
Requires-Dist: wheel

# ASOne

![croped](https://user-images.githubusercontent.com/107035454/195083948-4873d60a-3ac7-4279-8770-535488f4a097.png)

#### Table of Contents
- [Introduction](#introduction)
- [Prerequisite](#prerequisite)
- [Installation](#installation)
- [Usage](#usage)
- [Benchmarks](asone/linux/Instructions/Benchmarking.md)

### Introduction

Asone is a python wrapper for multiple detection and tracking algorithms all at one place. Different trackers such as `ByteTrack`, `DeepSort` or `NorFair` can be integrated with different versions of `YOLO` with minimum lines of code.
This python wrapper provides yolo models in both `ONNX` and `PyTorch` versions.

### Prerequisite

- Make sure to install `GPU` drivers in your system if you want to use `GPU` . Follow [driver installation](asone/linux/Instructions/Driver-Installations.md) for further instructions.
- Make sure you have [MS Build tools](https://aka.ms/vs/17/release/vs_BuildTools.exe) installed in system if using windows. 
- [Download git for windows](https://git-scm.com/download/win) if not installed.

### Installation

For linux

```
python3 -m venv .env
source .env/bin/activate

pip install numpy Cython
pip install cython-bbox

pip install asone


# for cpu
pip install torch torchvision

# for gpu
pip install torch torchvision --extra-index-url https://download.pytorch.org/whl/cu113

```

For windows

```
python -m venv .env
.env\Scripts\activate
pip install numpy Cython
pip install -e git+https://github.com/samson-wang/cython_bbox.git#egg=cython-bbox

pip install asone

# for cpu
pip install torch torchvision

# for gpu
pip install torch torchvision --extra-index-url https://download.pytorch.org/whl/cu113
```


### Usage
#### Detector
Use detector on a img using gpu

```
import asone
from asone import utils
from asone.detectors import Detector
import cv2

img = cv2.imread('data/sample_imgs/test2.jpg')
detector = Detector(asone.YOLOV7_E6_ONNX, use_cuda=True).get_detector() # Set use_cuda to False for cpu

dets, img_info = detector.detect(img)

bbox_xyxy = dets[:, :4]
scores = dets[:, 4]
class_ids = dets[:, 5]

img = utils.draw_boxes(img, bbox_xyxy, class_ids=class_ids)
cv2.imwrite('result.png', img)
```

Change detector by simply changing detector flag. flags are provided in [benchmark](asone/linux/Instructions/Benchmarking.md) tables.

```
# Change detector
detector = Detector(asone.YOLOX_S_PYTORCH, use_cuda=True).get_detector()
```

Run the `asone/demo_detector.py` to test detector.

```
# run on gpu
python -m asone.demo_detector data/sample_imgs/test2.jpg

# run on cpu
python -m asone.demo_detector data/sample_imgs/test2.jpg --cpu
```


#### Tracker
Use tracker on sample video using gpu. 


```
import asone
from asone import ASOne

dt_obj = ASOne(tracker=asone.BYTETRACK, detector=asone.YOLOX_DARKNET_PYTORCH, use_cuda=True) # Set use_cuda to False for cpu

for bbox_details, frame_details in dt_obj.track_video(
                                                        args.video_path,
                                                        output_dir=args.output_dir,
                                                        save_result=args.save_result,
                                                        display=args.display
                                                        ):
        # bbox_details = bbox_xyxy, ids, scores, class_ids
        # frame_details = frame, frame_no, fps
        
        # Do anything with bboxes here
        pass

# To track using webcam
# for bbox_details, frame_details in dt_obj.track_video(
#                                                        args.video_path,
#                                                        output_dir=args.output_dir,
#                                                        save_result=args.save_result,
#                                                        display=args.display
#                                                        ):
#        # bbox_details = bbox_xyxy, ids, scores, class_ids
#        # frame_details = frame, frame_no, fps
        
#        # Do anything with bboxes here
#        pass
```

Change Tracker by simply changing the tracker flag.

flags are provided in [benchmark](asone/linux/Instructions/Benchmarking.md) tables.

```
dt_obj = ASOne(tracker=asone.BYTETRACK, detector=asone.YOLOX_DARKNET_PYTORCH, use_cuda=True)
// Change tracker
dt_obj = ASOne(tracker=asone.DEEPSORT, detector=asone.YOLOX_DARKNET_PYTORCH, use_cuda=True)
```



```
dt_obj = ASOne(tracker=asone.DEEPSORT, detector=asone.YOLOX_S_PYTORCH, use_cuda=True)
```

Run `main.py` to test tracker on `data/sample_videos/test.mp4` video

```
# run on gpu
python main.py data/sample_videos/test.mp4

# run on cpu
python main.py data/sample_videos/test.mp4 --cpu
```


Results on provided sample video

https://user-images.githubusercontent.com/107035454/195079926-aee47eac-0430-4ada-8cc7-cc9d1d13c889.mp4

To setup ASOne using Docker follow instructions given in [docker setup](asone/linux/Instructions/Docker-Setup.md) 


|Offered By: |Maintained By:|
|-------------|-------------|
|[![AugmentedStarups](https://user-images.githubusercontent.com/107035454/195115263-d3271ef3-973b-40a4-83c8-0ade8727dd40.png)](https://augmentedstartups.com)|[![AxcelerateAI](https://user-images.githubusercontent.com/107035454/195114870-691c8a52-fcf0-462e-9e02-a720fc83b93f.png)](https://axcelerate.ai/)|



