TinyYolov2.js 2.5 KB

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