Skip to content

cachengo/cachengo-ai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cachengo-ai

Tools for running AI workloads on Cachengo symbiotes

Package

Basic structure of package is

├── README.md
├── cachengoai
│   ├── __init__.py
│   ├── rknn.py
│   └── rknn_utils.py
│   └── bbox_utils.py
│   └── yolov5_utils.py
│   └── image_utils.py
├── requirements.txt
├── setup.py
└── tests
    ├── __init__.py

Prerequisites

Ensure that RKNPU userspace dependencies are installed.

git clone https://github.com/airockchip/rknn-toolkit2.git
sudo cp ./rknn-toolkit2/rknpu2/runtime/Linux/librknn_api/aarch64/* /usr/lib
sudo cp ./rknn-toolkit2/rknpu2/runtime/Linux/rknn_server/aarch64/usr/bin/* /usr/bin/

Ensure that opencv dependencies are installed

apt-get update && apt-get install ffmpeg libsm6 libxext6  -y

Installation

Package can be installed by running

pip install git+https://github.com/cachengo/cachengo-ai.git

Package can also be installed by running the following command inside the repo directory

pip install .

Requirements

Package requirements are handled using pip. To install them do

pip install -r requirements.txt

Tests

Coming soon...

Examples

Run inference on video file

from cachengoai import rknn

# Initialize default yolov5 model with COCO classes
model = rknn.model()
# Run inference on video file and return list of detected classes
_,_,objs = rknn.detect(model,"./TestVideo.mp4",conf_thresh=0.6)

Run inference on raw frames

from cachengoai import rknn
import cv2

# Convert video to raw frames
def video_to_frames(video_path):
    """Converts a video to a list of raw frames using OpenCV."""

    cap = cv2.VideoCapture(video_path)
    frames = []

    while cap.isOpened():
        ret, frame = cap.read()
        if not ret:
            break
        frames.append(frame)

    cap.release()
    return frames

# Initialize local model
model = rknn.model("./yolov5s-640-640.rknn")
# Run inference on video file and return list of detected classes
raw_frames = video_to_frames('./TestVideo.mp4')

_,_,objs = rknn.detect(model,conf_thresh=0.6,frames=raw_frames)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages