mirror of
https://github.com/openmv/openmv.git
synced 2025-09-26 23:09:13 +08:00
lib/models: Add blazeface model.
This commit is contained in:
parent
65829023f0
commit
f6f39f924b
@ -38,6 +38,12 @@
|
|||||||
"alignment": 16,
|
"alignment": 16,
|
||||||
"optimize": "Performance"
|
"optimize": "Performance"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "tflite",
|
||||||
|
"path": "{TOP}/lib/models/blazeface_front_128.tflite",
|
||||||
|
"alignment": 16,
|
||||||
|
"optimize": "Performance"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "haar",
|
"type": "haar",
|
||||||
"path": "{TOP}/lib/haar/haarcascade_eye.xml",
|
"path": "{TOP}/lib/haar/haarcascade_eye.xml",
|
||||||
|
@ -32,6 +32,12 @@
|
|||||||
"alignment": 16,
|
"alignment": 16,
|
||||||
"optimize": "Performance"
|
"optimize": "Performance"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "tflite",
|
||||||
|
"path": "{TOP}/lib/models/blazeface_front_128.tflite",
|
||||||
|
"alignment": 16,
|
||||||
|
"optimize": "Performance"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "haar",
|
"type": "haar",
|
||||||
"path": "{TOP}/lib/haar/haarcascade_eye.xml",
|
"path": "{TOP}/lib/haar/haarcascade_eye.xml",
|
||||||
|
@ -38,6 +38,12 @@
|
|||||||
"alignment": 16,
|
"alignment": 16,
|
||||||
"optimize": "Performance"
|
"optimize": "Performance"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "tflite",
|
||||||
|
"path": "{TOP}/lib/models/blazeface_front_128.tflite",
|
||||||
|
"alignment": 16,
|
||||||
|
"optimize": "Performance"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "haar",
|
"type": "haar",
|
||||||
"path": "{TOP}/lib/haar/haarcascade_eye.xml",
|
"path": "{TOP}/lib/haar/haarcascade_eye.xml",
|
||||||
|
@ -38,6 +38,12 @@
|
|||||||
"alignment": 16,
|
"alignment": 16,
|
||||||
"optimize": "Performance"
|
"optimize": "Performance"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "tflite",
|
||||||
|
"path": "{TOP}/lib/models/blazeface_front_128.tflite",
|
||||||
|
"alignment": 16,
|
||||||
|
"optimize": "Performance"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "haar",
|
"type": "haar",
|
||||||
"path": "{TOP}/lib/haar/haarcascade_eye.xml",
|
"path": "{TOP}/lib/haar/haarcascade_eye.xml",
|
||||||
|
@ -38,6 +38,12 @@
|
|||||||
"alignment": 16,
|
"alignment": 16,
|
||||||
"optimize": "Performance"
|
"optimize": "Performance"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "tflite",
|
||||||
|
"path": "{TOP}/lib/models/blazeface_front_128.tflite",
|
||||||
|
"alignment": 16,
|
||||||
|
"optimize": "Performance"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "haar",
|
"type": "haar",
|
||||||
"path": "{TOP}/lib/haar/haarcascade_eye.xml",
|
"path": "{TOP}/lib/haar/haarcascade_eye.xml",
|
||||||
|
@ -32,6 +32,12 @@
|
|||||||
"alignment": 16,
|
"alignment": 16,
|
||||||
"optimize": "Performance"
|
"optimize": "Performance"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "tflite",
|
||||||
|
"path": "{TOP}/lib/models/blazeface_front_128.tflite",
|
||||||
|
"alignment": 16,
|
||||||
|
"optimize": "Performance"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "haar",
|
"type": "haar",
|
||||||
"path": "{TOP}/lib/haar/haarcascade_eye.xml",
|
"path": "{TOP}/lib/haar/haarcascade_eye.xml",
|
||||||
|
@ -19,6 +19,12 @@
|
|||||||
"path": "{TOP}/lib/models/yolo_v5_224_nano.tflite",
|
"path": "{TOP}/lib/models/yolo_v5_224_nano.tflite",
|
||||||
"alignment": 32,
|
"alignment": 32,
|
||||||
"profile": "default"
|
"profile": "default"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "tflite",
|
||||||
|
"path": "{TOP}/lib/models/blazeface_front_128.tflite",
|
||||||
|
"alignment": 32,
|
||||||
|
"profile": "default"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,12 @@
|
|||||||
"alignment": 16,
|
"alignment": 16,
|
||||||
"optimize": "Performance"
|
"optimize": "Performance"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "tflite",
|
||||||
|
"path": "{TOP}/lib/models/blazeface_front_128.tflite",
|
||||||
|
"alignment": 16,
|
||||||
|
"optimize": "Performance"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "haar",
|
"type": "haar",
|
||||||
"path": "{TOP}/lib/haar/haarcascade_eye.xml",
|
"path": "{TOP}/lib/haar/haarcascade_eye.xml",
|
||||||
|
BIN
lib/models/blazeface_front_128.tflite
Normal file
BIN
lib/models/blazeface_front_128.tflite
Normal file
Binary file not shown.
@ -344,7 +344,7 @@ class mediapipe_face_detection_postprocess:
|
|||||||
def __init__(self, threshold=0.6, anchors=None, nms_threshold=0.1, nms_sigma=0.1):
|
def __init__(self, threshold=0.6, anchors=None, nms_threshold=0.1, nms_sigma=0.1):
|
||||||
self.threshold = threshold
|
self.threshold = threshold
|
||||||
self.anchors = anchors
|
self.anchors = anchors
|
||||||
|
|
||||||
if self.anchors is None:
|
if self.anchors is None:
|
||||||
self.anchors = np.empty((896, 2))
|
self.anchors = np.empty((896, 2))
|
||||||
idx = 0
|
idx = 0
|
||||||
@ -364,6 +364,20 @@ class mediapipe_face_detection_postprocess:
|
|||||||
self.nms_threshold = nms_threshold
|
self.nms_threshold = nms_threshold
|
||||||
self.nms_sigma = nms_sigma
|
self.nms_sigma = nms_sigma
|
||||||
|
|
||||||
|
def __call__(self, model, inputs, outputs):
|
||||||
|
ib, ih, iw, ic = model.input_shape[0]
|
||||||
|
nms = NMS(iw, ih, inputs[0].roi)
|
||||||
|
output_len = outputs[0].shape[1]
|
||||||
|
|
||||||
|
self.blazeface_post_process(ih, iw, nms, model, inputs, outputs, 1, 0,
|
||||||
|
self.threshold, self.anchors[:output_len])
|
||||||
|
|
||||||
|
if output_len < len(self.anchors):
|
||||||
|
self.blazeface_post_process(ih, iw, nms, model, inputs, outputs, 2, 3,
|
||||||
|
self.threshold, self.anchors[output_len:])
|
||||||
|
|
||||||
|
return nms.get_bounding_boxes(threshold=self.nms_threshold, sigma=self.nms_sigma)
|
||||||
|
|
||||||
def blazeface_post_process(self, ih, iw, nms, model, inputs, outputs, score_idx, cords_idx, t, anchors):
|
def blazeface_post_process(self, ih, iw, nms, model, inputs, outputs, score_idx, cords_idx, t, anchors):
|
||||||
s_oh, s_ow, s_oc = model.output_shape[score_idx]
|
s_oh, s_ow, s_oc = model.output_shape[score_idx]
|
||||||
scale = model.output_scale[score_idx]
|
scale = model.output_scale[score_idx]
|
||||||
@ -409,17 +423,3 @@ class mediapipe_face_detection_postprocess:
|
|||||||
|
|
||||||
for i in range(bb.shape[0]):
|
for i in range(bb.shape[0]):
|
||||||
nms.add_bounding_box(xmin[i], ymin[i], xmax[i], ymax[i], bb_scores[i], 0, keypoints=keypoints[i])
|
nms.add_bounding_box(xmin[i], ymin[i], xmax[i], ymax[i], bb_scores[i], 0, keypoints=keypoints[i])
|
||||||
|
|
||||||
def __call__(self, model, inputs, outputs):
|
|
||||||
ib, ih, iw, ic = model.input_shape[0]
|
|
||||||
nms = NMS(iw, ih, inputs[0].roi)
|
|
||||||
output_len = outputs[0].shape[1]
|
|
||||||
|
|
||||||
self.blazeface_post_process(ih, iw, nms, model, inputs, outputs, 1, 0,
|
|
||||||
self.threshold, self.anchors[:output_len])
|
|
||||||
|
|
||||||
if output_len < len(self.anchors):
|
|
||||||
self.blazeface_post_process(ih, iw, nms, model, inputs, outputs, 2, 3,
|
|
||||||
self.threshold, self.anchors[output_len:])
|
|
||||||
|
|
||||||
return nms.get_bounding_boxes(threshold=self.nms_threshold, sigma=self.nms_sigma)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user