Repository navigation
fix: PPE detection order and exclusion zone counting in safety_app - #22
Merged
Merged
Conversation
detect_ppe overwrote its result for every person, so only the last person in the frame decided whether a violation was reported. Keep the result if any person matches. detect_zone compared max_allowed with the number of objects in the whole frame; count only objects whose box intersects the zone. A missing polygon, or one with fewer than three points, now means no zone to check instead of raising an error. The same zone fixes are applied to SingleInference_YOLOV7.detect_zone, which returns the unannotated image when there is no polygon. Drop the xfail markers from the tests that covered these.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the three behaviours marked xfail in #21, and the duplicate
detect_zoneinsingleinference_yolov7.py.detect_ppedepends on detection order.flagwas reassigned for every person, so only the last person inbox_listdecided the result. It now reports a violation if any person matches.detect_zoneand an empty polygon. A policy saved without a drawn zone reacheddetect_zoneas[]and raisedIndexError. A missing polygon, or one with fewer than three points (which shapely also rejects), now means there is no zone to check:safety_app.detect_zonereturnsFalse, andSingleInference_YOLOV7.detect_zonereturns the unannotated image instead ofNone, which the Exclusion Zones page passed tost.image.max_allowedcounts the whole frame. It is now compared with the number of objects of that class whose box intersects the zone, in both copies.The xfail markers are removed. The PPE test now checks both detection orders, and the empty-polygon test covers
None,[]and a two-point polygon. All 83 unit tests pass; the updated tests fail against the previoussafety_app.py.The
singleinference_yolov7.pychange isn't covered by the unit job since that module needs torch. I checked itsdetect_zonewith fixed detections: withmax_allowed=1, one person inside and one outside is no longer drawn red, and an empty polygon returns the image instead of failing incv2.fillPoly.