Skip to main content

Bluesignal Vision AI project

Project description

logo

bluevision

PyPI - Version PyPI - Python Version


Table of Contents

Installation

pip install bluevision

Usage

Simple video demo

from bluevision.demo import video_demo

video_demo(
    weights="yolov8s-coco.safetensors",
    video_path="sample.mp4",
    model_size="s",
    track=True,
    show=True,
    save_path="output.mp4",
)

Video Inference Process

import cv2
import supervision as sv
import bluevision as bv
from bluevision.utils import to_supervision_detections, make_labels

# Initialize
detector = bv.solutions.Detector(model=bv.solutions.detector.models.Yolov8(size='s'),
                                 nms=bv.utils.nms.soft_nms,
                                 weights="yolov8s.safetensors")
tracker = bv.utils.tracker.BYTETracker(track_thresh=0.15, match_thresh=0.9,
                                       track_buffer=60, frame_rate=30)
box_annotator = sv.BoundingBoxAnnotator(thickness=2)
label_annotator = sv.LabelAnnotator(text_scale=0.5, text_padding=2)

# Load sample video
vid = cv2.VideoCapture('sample.mp4')

# Start
while True:
    ret, original_image = vid.read()
    if not ret:
        break

    detections = detector(original_image)
    detections = tracker.update(detections)

    # Draw bboxes using supervision
    sv_detections = to_supervision_detections(detections)
    annotated_frame = box_annotator.annotate(
        scene=original_image,
        detections=sv_detections,
    )
    annotated_frame = label_annotator.annotate(
        scene=annotated_frame,
        detections=sv_detections,
        labels=make_labels(sv_detections)
    )

    cv2.imshow('annotated image', annotated_frame)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break
cv2.destroyAllWindows()

BlueVision

Solution

Object Detector

Utils

NMS Object Tracker

Test

$ python test_with_time.py
Using device: mps
preprocess: 0.00225s, infer: 0.015508s, postprocess: 0.01313s, track: 0.00108s, draw: 0.000670s, total: 0.03462s, t-avg: 0.03576s
total frame : 1050
total elapsed time: 56.25610s
total inference time: 37.55273s

License

bluevision is distributed under the terms of the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

bluevision-0.0.6-py3-none-any.whl (23.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page