TinyFaceDetector.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { __awaiter, __extends, __generator } from "tslib";
  2. import { FaceDetection } from '../classes';
  3. import { TinyYolov2Base } from '../tinyYolov2/TinyYolov2Base';
  4. import { BOX_ANCHORS, IOU_THRESHOLD, MEAN_RGB } from './const';
  5. var TinyFaceDetector = /** @class */ (function (_super) {
  6. __extends(TinyFaceDetector, _super);
  7. function TinyFaceDetector() {
  8. var _this = this;
  9. var config = {
  10. withSeparableConvs: true,
  11. iouThreshold: IOU_THRESHOLD,
  12. classes: ['face'],
  13. anchors: BOX_ANCHORS,
  14. meanRgb: MEAN_RGB,
  15. isFirstLayerConv2d: true,
  16. filterSizes: [3, 16, 32, 64, 128, 256, 512]
  17. };
  18. _this = _super.call(this, config) || this;
  19. return _this;
  20. }
  21. Object.defineProperty(TinyFaceDetector.prototype, "anchors", {
  22. get: function () {
  23. return this.config.anchors;
  24. },
  25. enumerable: true,
  26. configurable: true
  27. });
  28. TinyFaceDetector.prototype.locateFaces = function (input, forwardParams) {
  29. return __awaiter(this, void 0, void 0, function () {
  30. var objectDetections;
  31. return __generator(this, function (_a) {
  32. switch (_a.label) {
  33. case 0: return [4 /*yield*/, this.detect(input, forwardParams)];
  34. case 1:
  35. objectDetections = _a.sent();
  36. return [2 /*return*/, objectDetections.map(function (det) { return new FaceDetection(det.score, det.relativeBox, { width: det.imageWidth, height: det.imageHeight }); })];
  37. }
  38. });
  39. });
  40. };
  41. TinyFaceDetector.prototype.getDefaultModelName = function () {
  42. return 'tiny_face_detector_model';
  43. };
  44. TinyFaceDetector.prototype.extractParamsFromWeigthMap = function (weightMap) {
  45. return _super.prototype.extractParamsFromWeigthMap.call(this, weightMap);
  46. };
  47. return TinyFaceDetector;
  48. }(TinyYolov2Base));
  49. export { TinyFaceDetector };
  50. //# sourceMappingURL=TinyFaceDetector.js.map