torsh-vision
Computer vision utilities and models for ToRSh, leveraging scirs2-vision for optimized image operations.
Overview
This crate provides comprehensive computer vision functionality:
- Image I/O: Loading, saving, and format conversion
- Transforms: Data augmentation and preprocessing
- Datasets: Common vision datasets (ImageNet, COCO, etc.)
- Models: Pre-trained vision models
- Operations: Image processing and computer vision algorithms
- Visualization: Image display and annotation utilities
Note: This crate integrates with scirs2-vision for optimized image processing operations.
Usage
Image I/O
use *;
// Load images
let image = read_image?;
let batch = read_image_batch?;
// Save images
write_image?;
write_video?;
// Format conversion
let rgb = bgr_to_rgb?;
let gray = rgb_to_grayscale?;
let hsv = rgb_to_hsv?;
Transforms
use *;
// Create transform pipeline
let transform = new;
let transformed = transform.apply?;
// Data augmentation
let augment = new;
// Advanced augmentations
let mixup = new;
let cutmix = new;
let augmix = new;
Datasets
use *;
// ImageNet dataset
let imagenet = new?;
// COCO dataset
let coco = new?;
// CIFAR datasets
let cifar10 = CIFAR10new?;
// Custom folder dataset
let dataset = new?;
// Video dataset
let video_dataset = new?;
Pre-trained Models
use *;
// Classification models
let resnet = resnet50?;
let efficientnet = efficientnet_b0?;
let vit = vit_base_patch16_224?;
// Object detection
let faster_rcnn = fasterrcnn_resnet50_fpn?;
// Segmentation
let deeplabv3 = deeplabv3_resnet101?;
// Feature extraction
let features = resnet.features?;
let backbone = create_feature_extractor?;
Image Operations
use *;
// Basic operations (leveraging scirs2-vision)
let resized = resize?;
let cropped = crop?;
let flipped = hflip?;
let rotated = rotate?;
// Filtering
let blurred = gaussian_blur?;
let sharpened = adjust_sharpness?;
let edge = sobel_edge_detection?;
// Color adjustments
let bright = adjust_brightness?;
let contrast = adjust_contrast?;
let saturated = adjust_saturation?;
// Advanced operations
let slic = slic_superpixels?;
let optical_flow = dense_optical_flow?;
Object Detection Utilities
use *;
// Bounding box operations
let iou = box_iou?;
let nms_keep = nms?;
let converted = box_convert?;
// Anchor generation
let anchors = new?;
// ROI operations
let roi_pool = roi_pool?;
let roi_align = roi_align?;
Visualization
use *;
// Draw bounding boxes
let annotated = draw_bounding_boxes?;
// Draw segmentation masks
let masked = draw_segmentation_masks?;
// Draw keypoints
let keypoint_image = draw_keypoints?;
// Create image grid
let grid = make_grid?;
// Save visualization
save_image?;
Video Processing
use *;
// Read video
let video = read_video?;
let frames = video.frames; // Tensor of shape [T, C, H, W]
let audio = video.audio; // Optional audio tensor
// Write video
write_video?;
// Video transforms
let video_transform = new;
Feature Extraction and Similarity
// Extract features
let feature_extractor = create_feature_extractor?;
let features = feature_extractor?;
// Image similarity
let similarity = cosine_similarity?;
// Image retrieval
let retrieval_system = new;
retrieval_system.add_images?;
let similar_images = retrieval_system.search?;
Integration with SciRS2
This crate leverages scirs2-vision for:
- Optimized image processing operations
- Efficient data augmentation
- Hardware-accelerated transforms
- Computer vision algorithms
License
Licensed under the Apache License, Version 2.0. See LICENSE for details.