Skip to main content

Bluesignal Vision AI project

Project description

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="weights/yolov8s.safetensors",
    video_path="samples/mot17.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="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('samples/mot17.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

Object Detector

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.4-py3-none-any.whl (22.3 kB view details)

Uploaded Python 3

File details

Details for the file bluevision-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: bluevision-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 22.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.8

File hashes

Hashes for bluevision-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d07e9d1543bd8e244eb0ee1d91878279af149f94f2e3d65ce32a6f25b4f7077a
MD5 7f1212b0408672eeb20c2bce22fa8a1c
BLAKE2b-256 ff8624c06b36ec5b56e3d166cb23ddf66b0a991b79d1d0f99d0bfc9ced0c824f

See more details on using hashes here.

Provenance

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