Skip to content

Commit c44a4c1

Browse files
new composable tasks API + forward options
1 parent 9c00635 commit c44a4c1

40 files changed

+584
-369
lines changed

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"dependencies": {
2626
"@tensorflow/tfjs-core": "^0.13.2",
2727
"tfjs-image-recognition-base": "^0.1.2",
28-
"tfjs-tiny-yolov2": "^0.1.3",
28+
"tfjs-tiny-yolov2": "^0.2.1",
2929
"tslib": "^1.9.3"
3030
},
3131
"devDependencies": {

src/allFacesFactory.ts

Lines changed: 0 additions & 133 deletions
This file was deleted.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { FaceDetection } from './FaceDetection';
2+
import { FaceLandmarks } from './FaceLandmarks';
3+
4+
export class FaceDetectionWithLandmarks {
5+
private _detection: FaceDetection
6+
private _relativeLandmarks: FaceLandmarks
7+
8+
constructor(
9+
detection: FaceDetection,
10+
relativeLandmarks: FaceLandmarks
11+
) {
12+
this._detection = detection
13+
this._relativeLandmarks = relativeLandmarks
14+
}
15+
16+
public get detection(): FaceDetection { return this._detection }
17+
18+
public get relativeLandmarks(): FaceLandmarks { return this._relativeLandmarks }
19+
20+
public get landmarks(): FaceLandmarks {
21+
const { x, y } = this.detection.box
22+
return this._relativeLandmarks.shift(x, y)
23+
}
24+
25+
public forSize(width: number, height: number): FaceDetectionWithLandmarks {
26+
return new FaceDetectionWithLandmarks(
27+
this._detection.forSize(width, height),
28+
this._relativeLandmarks.forSize(width, height)
29+
)
30+
}
31+
}

src/classes/FullFaceDescription.ts

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,25 @@
11
import { FaceDetection } from './FaceDetection';
2+
import { FaceDetectionWithLandmarks } from './FaceDetectionWithLandmarks';
23
import { FaceLandmarks } from './FaceLandmarks';
34

4-
export class FullFaceDescription {
5-
constructor(
6-
private _detection: FaceDetection,
7-
private _landmarks: FaceLandmarks,
8-
private _descriptor: Float32Array
9-
) {}
10-
11-
public get detection(): FaceDetection {
12-
return this._detection
13-
}
5+
export class FullFaceDescription extends FaceDetectionWithLandmarks {
6+
private _descriptor: Float32Array
147

15-
public get landmarks(): FaceLandmarks {
16-
return this._landmarks
8+
constructor(
9+
detection: FaceDetection,
10+
landmarks: FaceLandmarks,
11+
descriptor: Float32Array
12+
) {
13+
super(detection, landmarks)
14+
this._descriptor = descriptor
1715
}
1816

1917
public get descriptor(): Float32Array {
2018
return this._descriptor
2119
}
2220

2321
public forSize(width: number, height: number): FullFaceDescription {
24-
return new FullFaceDescription(
25-
this._detection.forSize(width, height),
26-
this._landmarks.forSize(width, height),
27-
this._descriptor
28-
)
22+
const { detection, landmarks } = super.forSize(width, height)
23+
return new FullFaceDescription(detection, landmarks, this.descriptor)
2924
}
3025
}

src/faceDetectionNet/index.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/faceLandmarkNet/index.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,4 @@ export function createFaceLandmarkNet(weights: Float32Array) {
99
const net = new FaceLandmarkNet()
1010
net.extractWeights(weights)
1111
return net
12-
}
13-
14-
export function faceLandmarkNet(weights: Float32Array) {
15-
console.warn('faceLandmarkNet(weights: Float32Array) will be deprecated in future, use createFaceLandmarkNet instead')
16-
return createFaceLandmarkNet(weights)
1712
}

src/faceRecognitionNet/index.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,4 @@ export function createFaceRecognitionNet(weights: Float32Array) {
66
const net = new FaceRecognitionNet()
77
net.extractWeights(weights)
88
return net
9-
}
10-
11-
export function faceRecognitionNet(weights: Float32Array) {
12-
console.warn('faceRecognitionNet(weights: Float32Array) will be deprecated in future, use createFaceRecognitionNet instead')
13-
return createFaceRecognitionNet(weights)
149
}

0 commit comments

Comments
 (0)