From 5fec952b8cb11cd99a748f57cd5b62f1eae88c24 Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Sat, 15 Nov 2025 19:48:42 +0200 Subject: [PATCH] adjust detections --- .rubocop.yml | 3 +++ lib/templates/image_to_fields.rb | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index aad5509e..294fc484 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -45,6 +45,9 @@ Metrics/PerceivedComplexity: Style/MultipleComparison: Enabled: false +Style/NumericPredicate: + Enabled: false + Naming/PredicateMethod: Enabled: false diff --git a/lib/templates/image_to_fields.rb b/lib/templates/image_to_fields.rb index fa342f4e..50837c1c 100755 --- a/lib/templates/image_to_fields.rb +++ b/lib/templates/image_to_fields.rb @@ -77,7 +77,7 @@ module Templates end def build_fields_from_detections(detections, image) - Array.new(detections[:xyxy].shape[0]) do |i| + detections[:xyxy].shape[0].times.filter_map do |i| x1 = detections[:xyxy][i, 0] y1 = detections[:xyxy][i, 1] x2 = detections[:xyxy][i, 2] @@ -92,6 +92,12 @@ module Templates x1_norm = x2 / image.width.to_f y1_norm = y2 / image.height.to_f + x1_norm = 1 if x1_norm > 1 + y1_norm = 1 if y1_norm > 1 + + next if x0_norm < 0 || x0_norm > 1 + next if y0_norm < 0 || y0_norm > 1 + type_name = ID_TO_CLASS[class_id] Field.new(