From 6cb594216e3cfe081b0cc598d834cdf841409c29 Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Sat, 17 Oct 2020 21:52:41 +1100 Subject: [PATCH] Added fallback for ML grid detection to use raw prediction --- src/helpers/map.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/helpers/map.js b/src/helpers/map.js index e3b0f9b..943a2f4 100644 --- a/src/helpers/map.js +++ b/src/helpers/map.js @@ -113,8 +113,16 @@ async function gridSizeML(image, candidates) { } } - const x = Math.floor(width / bestScale); - const y = Math.floor(height / bestScale); + let x = Math.floor(width / bestScale); + let y = Math.floor(height / bestScale); + + if (gridSizeVaild(x, y)) { + return { x, y }; + } else { + // Fallback to raw prediction + x = Math.round(prediction); + y = Math.floor(x / ratio); + } if (gridSizeVaild(x, y)) { return { x, y };