191 lines
4.6 KiB
Rust
191 lines
4.6 KiB
Rust
//! # RTX Vision - Vision Transformers and Computer Vision Models
|
|
//!
|
|
//! Revolutionary vision models with world-class performance for RustyTorch++.
|
|
//!
|
|
//! ## Features
|
|
//! - Vision Transformer (ViT) with Flash Attention integration
|
|
//! - ConvNeXt modern ConvNet architecture
|
|
//! - EfficientNet V2 with Fused-MBConv blocks and progressive learning
|
|
//! - MobileViT hybrid CNN-Transformer for mobile deployment
|
|
//! - EdgeViT edge-optimized Vision Transformer for efficient deployment
|
|
//! - Mobile-optimized components (depthwise separable convolutions, efficient attention)
|
|
//! - CLIP vision encoders for multimodal learning
|
|
//! - Patch embedding with learnable positional encodings
|
|
//! - Advanced image preprocessing and augmentation
|
|
//! - Quantization-aware training utilities
|
|
//! - PyTorch-compatible APIs where applicable
|
|
//!
|
|
//! ## Architecture
|
|
//! - `preprocessing`: Image loading, normalization, and augmentation
|
|
//! - `layers`: Patch embedding, positional encoding, specialized layers
|
|
//! - `models`: Complete vision model implementations
|
|
//! - `utils`: Vision-specific utilities and metrics
|
|
//!
|
|
//! ## Example
|
|
//! ```rust,ignore
|
|
//! use rtx_vision::{models::ViT, preprocessing::ImageTensor};
|
|
//!
|
|
//! let model = ViT::new(ViTConfig::base_16()).unwrap();
|
|
//! let image = ImageTensor::from_path("image.jpg").unwrap();
|
|
//! let output = model.forward(&image).unwrap();
|
|
//! ```
|
|
|
|
pub mod architectures;
|
|
pub mod error;
|
|
pub mod layers;
|
|
pub mod models;
|
|
pub mod preprocessing;
|
|
pub mod utils;
|
|
|
|
// Vision tensor implementation (using real rtx-tensor)
|
|
pub mod vision_tensor;
|
|
|
|
#[cfg(test)]
|
|
pub mod vision_tensor_tests;
|
|
|
|
// Re-export main types
|
|
pub use error::{Result, VisionError};
|
|
|
|
// Re-export tensor types
|
|
pub use rtx_tensor::{DType, Device, Result as TensorResult, Shape, Tensor, TensorError};
|
|
|
|
// Re-export preprocessing types
|
|
pub use preprocessing::{Augmentation, ImageProcessor, ImageTensor};
|
|
|
|
// Re-export layer types
|
|
pub use layers::{PatchEmbedding, PositionalEncoding};
|
|
|
|
// Re-export model types
|
|
pub use models::{ConvNeXt, ConvNeXtConfig, ViT, ViTConfig};
|
|
|
|
// Re-export architecture types
|
|
pub use architectures::{
|
|
AGCConfig,
|
|
AdaptiveGradientClipping,
|
|
BasicBlock,
|
|
BlockAttention,
|
|
BlockAttentionConfig,
|
|
Bottleneck,
|
|
// CoAtNet
|
|
CoAtNet,
|
|
CoAtNetConfig,
|
|
CoAtNetMBConvBlock,
|
|
CoAtNetMBConvConfig,
|
|
CoAtNetStage,
|
|
CoAtNetTransformerBlock,
|
|
CoAtNetTransformerConfig,
|
|
CoAtNetVariant,
|
|
// ConvNeXt V2
|
|
ConvNeXtV2,
|
|
ConvNeXtV2Block,
|
|
ConvNeXtV2Config,
|
|
DecomposedAttention,
|
|
DecomposedAttentionConfig,
|
|
DenseBlock,
|
|
DenseLayer,
|
|
// DenseNet
|
|
DenseNet,
|
|
DenseNetConfig,
|
|
DenseNetVariant,
|
|
DepthwiseSepConv,
|
|
DepthwiseSepConvConfig,
|
|
// Mobile Components
|
|
DepthwiseSeparableConv,
|
|
DepthwiseSeparableConvConfig,
|
|
// EdgeViT
|
|
EdgeViT,
|
|
EdgeViTClassificationHead,
|
|
EdgeViTConfig,
|
|
EdgeViTVariant,
|
|
EfficientAttention,
|
|
EfficientAttentionConfig,
|
|
EfficientChannelAttention,
|
|
EfficientChannelAttentionConfig,
|
|
// EfficientNet V2
|
|
EfficientNetV2,
|
|
EfficientNetV2Config,
|
|
EfficientNetV2Variant,
|
|
EfficientPositionalEncoding,
|
|
FusedMBConvBlock,
|
|
FusedMBConvConfig,
|
|
GlobalResponseNormalization,
|
|
GridAttention,
|
|
GridAttentionConfig,
|
|
InvertedResidualBlock,
|
|
InvertedResidualConfig,
|
|
LGLBlock,
|
|
LGLBlockConfig,
|
|
MAEDecoder,
|
|
MAEEncoder,
|
|
// MaxViT
|
|
MaxViT,
|
|
MaxViTConfig,
|
|
MaxViTMBConvBlock,
|
|
MaxViTMBConvConfig,
|
|
MaxViTStage,
|
|
MaxViTVariant,
|
|
MobileActivations,
|
|
// MobileNet
|
|
MobileNet,
|
|
MobileNetConfig,
|
|
MobileNetVariant,
|
|
// MobileViT
|
|
MobileViT,
|
|
MobileViTBlock,
|
|
MobileViTBlockConfig,
|
|
MobileViTConfig,
|
|
MobileViTTransformerBlock,
|
|
MobileViTVariant,
|
|
MultiAxisAttention,
|
|
MultiAxisAttentionConfig,
|
|
MultiScaleAggregation,
|
|
MultiScaleAggregationConfig,
|
|
NFBlock,
|
|
NFBlockConfig,
|
|
// NFNet
|
|
NFNet,
|
|
NFNetConfig,
|
|
NFNetHead,
|
|
NFNetStem,
|
|
NFNetTransition,
|
|
NFNetVariant,
|
|
QuantizationAwareUtils,
|
|
// RegNet
|
|
RegNet,
|
|
RegNetBlock,
|
|
RegNetBlockConfig,
|
|
RegNetConfig,
|
|
RegNetHead,
|
|
RegNetStage,
|
|
RegNetStageConfig,
|
|
RegNetStem,
|
|
RelativeAttention,
|
|
RelativeAttentionConfig,
|
|
// ResNet
|
|
ResNet,
|
|
ResNetConfig,
|
|
ResNetVariant,
|
|
SEModule,
|
|
SEModule as RegNetSEModule,
|
|
SEModuleConfig,
|
|
SEModuleConfig as RegNetSEModuleConfig,
|
|
ScaledWSConfig,
|
|
ScaledWeightStandardization,
|
|
TransformerBlockConfig,
|
|
// VGG
|
|
VGG,
|
|
VGGConfig,
|
|
VGGVariant,
|
|
};
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn test_module_structure() {
|
|
// Basic smoke test to ensure module structure is valid
|
|
assert!(true);
|
|
}
|
|
}
|