Files
temp_SSA_SCAN/lib/ml/model-config.ts
2025-08-29 10:12:37 -06:00

57 lines
1.8 KiB
TypeScript

import type { DetectionConfig, ModelInfo } from './types';
/**
* Configuration for different model variants.
* I've used the models from the original repo and another one from TensorFlow Hub.
*/
export const MODEL_VARIANTS: Record<'quantized' | 'standard' | 'full', ModelInfo> = {
quantized: {
variant: 'quantized',
url: '/models/model.json',
size: 2 * 1024 * 1024, // ~2MB
name: 'SSD-MobileNetV2 Quantized',
description: 'Fastest, for continuous detection.'
},
standard: {
variant: 'standard',
url: '/models/model.json',
size: 2 * 1024 * 1024, // Same model, different configs
name: 'SSD-MobileNetV2 Standard',
description: 'Balanced speed and accuracy.'
},
full: {
variant: 'full',
url: '/models/model.json',
size: 2 * 1024 * 1024, // Same model, different configs
name: 'SSD-MobileNetV2 Full',
description: 'Most accurate, for on-demand scan.'
}
};
/**
* Default detection configuration.
*/
export const DEFAULT_CONFIG: DetectionConfig = {
frameSkip: 6,
confidenceThreshold: 0.8, // Default to 80% confidence
modelVariant: 'standard',
maxDetections: 5, // Match the working implementation (process up to 5 detections)
inputSize: [300, 300], // Match the working implementation
enableContinuous: true,
enableTrigger: true,
};
/**
* Class labels for the models.
* IMPORTANT: This must match the order of the model's output classes.
*/
export const CLASS_LABELS = ['shoe'];
/**
* Rules to validate detections and reduce false positives.
*/
export const VALIDATION_RULES = {
minBoundingBoxSize: 30, // Minimum pixel width/height of a bounding box
aspectRatioRange: [0.5, 2.0], // Plausible aspect ratio (width / height) for a shoe
temporalConsistencyFrames: 3, // Must be detected in N consecutive frames
};