From f1b1b3439e35ff4a52bee9d14f87085518e74b48 Mon Sep 17 00:00:00 2001 From: Quildra Date: Tue, 29 Jul 2025 21:26:22 +0100 Subject: [PATCH] Add raw model output debugging for shiny icon investigation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Log raw output statistics including max values and non-zero counts - Specifically check shiny icon class region (class 50) in raw model output - Will reveal if model produces shiny predictions before post-processing - Helps identify if issue is in model weights vs post-processing 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .../pokegoalshelper/YOLOOnnxDetector.kt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/src/main/java/com/quillstudios/pokegoalshelper/YOLOOnnxDetector.kt b/app/src/main/java/com/quillstudios/pokegoalshelper/YOLOOnnxDetector.kt index be01899..e6c2de1 100644 --- a/app/src/main/java/com/quillstudios/pokegoalshelper/YOLOOnnxDetector.kt +++ b/app/src/main/java/com/quillstudios/pokegoalshelper/YOLOOnnxDetector.kt @@ -405,6 +405,22 @@ class YOLOOnnxDetector(private val context: Context) { val outputTensor = result.get(0).value as Array> val flatOutput = outputTensor[0].flatMap { it.asIterable() }.toFloatArray() + // Debug: Log raw output statistics when looking for shiny icons + if (DEBUG_SHINY_DETECTION) { + val maxVal = flatOutput.maxOrNull() ?: 0f + val nonZeroCount = flatOutput.count { it > 0.01f } + Log.w(TAG, "🔬 [RAW OUTPUT] Method: $method, FlatOutput size: ${flatOutput.size}, Max value: %.4f, Non-zero (>0.01): $nonZeroCount".format(maxVal)) + + // Check for any values in the shiny icon class region (class 50 * 8400 detections) + val shinyClassStart = 50 * NUM_DETECTIONS + 4 * NUM_DETECTIONS // After x,y,w,h for all detections + if (shinyClassStart < flatOutput.size) { + val shinyClassValues = flatOutput.sliceArray(shinyClassStart until kotlin.math.min(shinyClassStart + NUM_DETECTIONS, flatOutput.size)) + val maxShinyConf = shinyClassValues.maxOrNull() ?: 0f + val shinyAboveThreshold = shinyClassValues.count { it > 0.1f } + Log.w(TAG, "🔬 [SHINY RAW] Max shiny confidence: %.4f, Count >0.1: $shinyAboveThreshold".format(maxShinyConf)) + } + } + // Post-process results with method-specific coordinate transformation val detections = postprocessWithMethod(flatOutput, inputMat.cols(), inputMat.rows(), INPUT_SIZE, method)