Skip to main content

CVMD

A Computer Vision Model Development toolkit. cvmd uses NumPy arrays as both input and output, aiming to provide a unified and concise model inference interface.

Installation

pip install cvmd

Quick Start

import imageio.v3 as iio
from cvmd import build

# Build and load model
model = build("yolov11det", weights="yolo11l.torchscript", device="cuda")
model.load_model()

# Read image (HWC, RGB)
image = iio.imread("image.jpg")

# Perform inference
results = model(image)
# results: [x1, y1, x2, y2, confidence, class]

Core API

Model Building and Management

cvmd provides a registration mechanism to manage different models.

  • list_models(): List all registered model names.
  • build(model_name_or_cls, **kwargs): Build a model instance by name or class.
  • register_model(*names): Decorator to register custom model classes into cvmd.

Supported Models

Currently supported model series (primarily loaded via TorchScript):

Model Series Task Registered Names
YOLOv12 Detection / Segmentation yolov12det, yolov12seg
YOLOv11 Detection / Segmentation yolov11det, yolov11seg
YOLOv8 Detection / Segmentation yolov8det, yolov8seg
YOLOv5 Detection / Segmentation yolov5det, yolov5seg
DETR Detection detr (To be implemented)
Deformable DETR Detection deformabledetr (To be implemented)

Inference Interface

All model classes follow a unified calling convention:

Detection Models (*Detect)

  • Input: image (np.ndarray, HWC, RGB)
  • Output: results (np.ndarray, shape=(N, 6))
    • Format per row: [x1, y1, x2, y2, confidence, class]

Segmentation Models (*Segment)

  • Input: image (np.ndarray, HWC, RGB)
  • Output: (detections, masks)
    • detections: (np.ndarray, shape=(N, 6)), same format as above.
    • masks: (np.ndarray, shape=(N, H, W)), boolean masks.

Utility Functions

Sliding Window Inference

For large image inference, you can use detect_with_windows:

from cvmd.utils.windows import detect_with_windows

# Define windows [x1, y1, x2, y2]
windows = [[0, 0, 640, 640], [320, 320, 960, 960]]

results = detect_with_windows(
    image, 
    windows, 
    model, 
    merge=True, 
    merge_iou=0.2
)

Distributed Inference with Ray

cvmd includes a utility for distributed inference using Ray. This is useful for processing large batches of images across multiple GPUs.

from cvmd.utils.ray_infer import ray_infer_iter, InferActor

# Define your custom handler
def my_handler(task, model_config, runs_config):
    model = model_config["model"]
    image = task["image"]
    return model(image)

# Run distributed inference
tasks = [{"image": img} for img in my_images]
results = ray_infer_iter(
    InferActor,
    tasks,
    num_actors=4,
    actor_kwargs={
        "model_config": {"model_name": "yolov11det", "weights": "yolo11l.torchscript"},
        "handler": my_handler
    }
)

for r in results:
    print(r)

Examples & Tests

You can find more usage examples in the test/ directory:

Development

uv sync --dev

Metadata

Release files for cvmd 0.1.0.post202601010007

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cvmd 0.1.0.post202601010007
File Size Uploaded Provenance Actions
cvmd-0.1.0.post202601010007.tar.gz 27.6 kB Without provenance Details for cvmd-0.1.0.post202601010007.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cvmd 0.1.0.post202601010007
File Interpreter ABI Platform Actions
cvmd-0.1.0.post202601010007-py3-none-any.whl Python 3 none any Details for cvmd-0.1.0.post202601010007-py3-none-any.whl

Total release size: 55.5 kB

Release files / cvmd-0.1.0.post202601010007.tar.gz

Download URL cvmd-0.1.0.post202601010007.tar.gz
Size 27.6 kB
Tags Source
SHA-256 checksum
How to use checksums
3d64f496f97ae650874c4bb7b089f89c0d6deebc5ecc74694d1844f65b838af5
BLAKE2b-256 checksum
How to use checksums
773751afbae25e461788159e07ebe32c6640244673222f0ce52b57053b1598a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / cvmd-0.1.0.post202601010007-py3-none-any.whl

Download URL cvmd-0.1.0.post202601010007-py3-none-any.whl
Size 27.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0f615777062a780e2ba95c3ca1553009a8fca944b90766b20c950ab5e572baec
BLAKE2b-256 checksum
How to use checksums
273bc4d4d03fec12ecdec26a967da9ec6f4e79072df4faa0c9d4af9295538001
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for cvmd 0.1.0.post202601010007

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page