2020-08-20 02:10:42 +02:00
|
|
|
import { FaceDetection } from '../classes';
|
|
|
|
import { TinyYolov2Base } from '../tinyYolov2/TinyYolov2Base';
|
|
|
|
import { BOX_ANCHORS, IOU_THRESHOLD, MEAN_RGB } from './const';
|
|
|
|
export class TinyFaceDetector extends TinyYolov2Base {
|
2020-08-18 14:04:33 +02:00
|
|
|
constructor() {
|
|
|
|
const config = {
|
|
|
|
withSeparableConvs: true,
|
2020-08-20 02:10:42 +02:00
|
|
|
iouThreshold: IOU_THRESHOLD,
|
2020-08-18 14:04:33 +02:00
|
|
|
classes: ['face'],
|
2020-08-20 02:10:42 +02:00
|
|
|
anchors: BOX_ANCHORS,
|
|
|
|
meanRgb: MEAN_RGB,
|
2020-08-18 14:04:33 +02:00
|
|
|
isFirstLayerConv2d: true,
|
|
|
|
filterSizes: [3, 16, 32, 64, 128, 256, 512]
|
|
|
|
};
|
|
|
|
super(config);
|
|
|
|
}
|
|
|
|
get anchors() {
|
|
|
|
return this.config.anchors;
|
|
|
|
}
|
|
|
|
async locateFaces(input, forwardParams) {
|
|
|
|
const objectDetections = await this.detect(input, forwardParams);
|
2020-08-20 02:10:42 +02:00
|
|
|
return objectDetections.map(det => new FaceDetection(det.score, det.relativeBox, { width: det.imageWidth, height: det.imageHeight }));
|
2020-08-18 14:04:33 +02:00
|
|
|
}
|
|
|
|
getDefaultModelName() {
|
|
|
|
return 'tiny_face_detector_model';
|
|
|
|
}
|
|
|
|
extractParamsFromWeigthMap(weightMap) {
|
|
|
|
return super.extractParamsFromWeigthMap(weightMap);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//# sourceMappingURL=TinyFaceDetector.js.map
|