Files
rustytorch/demos/segmentation-shared/src/lib.rs
T
2026-03-04 00:08:42 +00:00

48 lines
1.5 KiB
Rust

// Segmentation Shared Types Library
// Provides common types, configuration, and IPC types for semantic segmentation
mod class_sets;
mod ipc;
mod types;
pub use class_sets::{ADE20K_CLASSES, CITYSCAPES_CLASSES, PASCAL_VOC_CLASSES};
pub use ipc::{SegmentRequest, SegmentResponse};
pub use types::{
ClassInfo, SegmentationConfig, SegmentationMask, SegmentationModel, SegmentationResult,
};
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_library_exports_all_types() {
// Verify all types are accessible
let _model: SegmentationModel = SegmentationModel::DeepLabV3;
let _config =
SegmentationConfig::new(SegmentationModel::DeepLabV3, "cpu".to_string(), 21, 512);
let _mask = SegmentationMask::new(10, 10, vec![0; 100]);
let _result = SegmentationResult::new(SegmentationMask::new(10, 10, vec![0; 100]), 100.0);
let _class = ClassInfo::new(0, "background", "#000000");
// Verify class sets are accessible
assert!(!PASCAL_VOC_CLASSES.is_empty());
assert!(!ADE20K_CLASSES.is_empty());
assert!(!CITYSCAPES_CLASSES.is_empty());
}
#[test]
fn test_ipc_types_accessible() {
let _request = SegmentRequest::Segment {
image_data: vec![0; 100],
width: 10,
height: 10,
model: SegmentationModel::DeepLabV3,
};
let _response = SegmentResponse::Success {
result: SegmentationResult::new(SegmentationMask::new(10, 10, vec![0; 100]), 100.0),
};
}
}