TinyFaceDetector.js 2.1 KB

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