summaryrefslogtreecommitdiffstats
path: root/r_facelib/detection/yolov5face/utils/autoanchor.py
diff options
context:
space:
mode:
authorGrafting Rayman <156515434+GraftingRayman@users.noreply.github.com>2025-01-17 11:06:44 +0000
committerGitHub <noreply@github.com>2025-01-17 11:06:44 +0000
commite6bd5af6a8e306a1cdef63402a77a980a04ad6e1 (patch)
treed0732226bbc22feedad9e834b2218d7d0b0eff54 /r_facelib/detection/yolov5face/utils/autoanchor.py
parent495ffc4777522e40941753e3b1b79c02f84b25b4 (diff)
downloadComfyui-reactor-node-e6bd5af6a8e306a1cdef63402a77a980a04ad6e1.tar.gz
Add files via uploadHEADmain
Diffstat (limited to 'r_facelib/detection/yolov5face/utils/autoanchor.py')
-rw-r--r--r_facelib/detection/yolov5face/utils/autoanchor.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/r_facelib/detection/yolov5face/utils/autoanchor.py b/r_facelib/detection/yolov5face/utils/autoanchor.py
new file mode 100644
index 0000000..cb0de89
--- /dev/null
+++ b/r_facelib/detection/yolov5face/utils/autoanchor.py
@@ -0,0 +1,12 @@
+# Auto-anchor utils
+
+
+def check_anchor_order(m):
+ # Check anchor order against stride order for YOLOv5 Detect() module m, and correct if necessary
+ a = m.anchor_grid.prod(-1).view(-1) # anchor area
+ da = a[-1] - a[0] # delta a
+ ds = m.stride[-1] - m.stride[0] # delta s
+ if da.sign() != ds.sign(): # same order
+ print("Reversing anchor order")
+ m.anchors[:] = m.anchors.flip(0)
+ m.anchor_grid[:] = m.anchor_grid.flip(0)