Browse Source
Improvements: - Create YOLOConfig data class with all inference settings consolidated - Add CoordinateMode and PreprocessingTechnique enums for type safety - Update YOLOInferenceEngine constructor to accept configurable settings - Replace scattered constants with config usage in key methods - Enable runtime configuration of model file, thresholds, and processing options Maintainability Benefits: - All YOLO settings in one place for easy adjustment - Type-safe enums prevent configuration errors - Default values maintain backward compatibility - Cleaner separation between configuration and implementation Performance Impact: - Thread pool size now configurable via config.threadPoolSize - Confidence and processing thresholds easily adjustable - Foundation for A/B testing different configurations 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>arch-002-ml-inference-engine
2 changed files with 78 additions and 8 deletions
@ -0,0 +1,67 @@ |
|||||
|
package com.quillstudios.pokegoalshelper.ml |
||||
|
|
||||
|
/** |
||||
|
* Configuration class for YOLO inference engine |
||||
|
* Consolidates all settings in one place for better maintainability |
||||
|
*/ |
||||
|
data class YOLOConfig( |
||||
|
// Model settings |
||||
|
val modelFile: String = "best.onnx", |
||||
|
val inputSize: Int = 640, |
||||
|
val numChannels: Int = 3, |
||||
|
val numDetections: Int = 300, |
||||
|
val numClasses: Int = 95, |
||||
|
|
||||
|
// Confidence and NMS thresholds |
||||
|
val confidenceThreshold: Float = 0.55f, |
||||
|
val nmsThreshold: Float = 0.3f, |
||||
|
val iouThreshold: Float = 0.4f, |
||||
|
|
||||
|
// Preprocessing settings |
||||
|
val enableMultiPreprocessing: Boolean = false, // Disabled for mobile performance |
||||
|
val enableTTA: Boolean = true, // Test-time augmentation |
||||
|
val enableUltralyticsPreprocessing: Boolean = true, |
||||
|
val enableContrastEnhancement: Boolean = true, |
||||
|
val enableSharpening: Boolean = true, |
||||
|
val enableNoiseReduction: Boolean = true, |
||||
|
|
||||
|
// Performance settings |
||||
|
val maxInferenceTimeMs: Long = 4500L, // Leave 500ms for other processing |
||||
|
val threadPoolSize: Int = 3, |
||||
|
|
||||
|
// Coordinate transformation mode |
||||
|
val coordinateMode: CoordinateMode = CoordinateMode.HYBRID, |
||||
|
|
||||
|
// Debug settings |
||||
|
val showAllConfidences: Boolean = false, |
||||
|
val classFilter: String? = null |
||||
|
) |
||||
|
|
||||
|
/** |
||||
|
* Coordinate transformation modes |
||||
|
*/ |
||||
|
enum class CoordinateMode(val modeName: String) |
||||
|
{ |
||||
|
HYBRID("HYBRID"), |
||||
|
LETTERBOX("LETTERBOX"), |
||||
|
DIRECT("DIRECT"); |
||||
|
|
||||
|
companion object |
||||
|
{ |
||||
|
fun fromString(mode: String): CoordinateMode |
||||
|
{ |
||||
|
return values().find { it.modeName == mode } ?: HYBRID |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Preprocessing technique enum |
||||
|
*/ |
||||
|
enum class PreprocessingTechnique |
||||
|
{ |
||||
|
ULTRALYTICS, |
||||
|
ENHANCED, |
||||
|
SHARPENED, |
||||
|
ORIGINAL |
||||
|
} |
||||
Loading…
Reference in new issue