Skip to content

Commit 6d8734a

Browse files
authoredMar 12, 2021
Add base class and types. (#607)
FEATURE
1 parent 8adaca6 commit 6d8734a

File tree

6 files changed

+384
-0
lines changed

6 files changed

+384
-0
lines changed
 

‎pose-detection/.vscode/settings.json

+145
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
// Place your settings in this file to overwrite default and user settings.
2+
{
3+
"search.exclude": {
4+
"**/node_modules": true,
5+
"**/coverage/": true,
6+
"**/dist/": true,
7+
"**/yarn.lock": true,
8+
"**/.rpt2_cache/": true,
9+
"**/.yalc/**/*": true,
10+
"**/.cache/**/*": true,
11+
"**/bazel-bin/**/*": true,
12+
"**/bazel-out/**/*": true,
13+
"**/bazel-genfiles/**/*": true,
14+
"**/bazel-testlogs/**/*": true,
15+
"**/bazel-tfjs*/**/*": true,
16+
},
17+
"files.trimTrailingWhitespace": true,
18+
"editor.tabSize": 2,
19+
"editor.insertSpaces": true,
20+
"[typescript]": {
21+
"editor.formatOnSave": true
22+
},
23+
"[javascript]": {
24+
"editor.formatOnSave": true
25+
},
26+
"[cpp]": {
27+
"editor.formatOnSave": true
28+
},
29+
"emeraldwalk.runonsave": {
30+
"commands": [
31+
{
32+
"match": "(BUILD|.*bzl)",
33+
"cmd": "yarn bazel:format && yarn bazel:lint"
34+
}
35+
]
36+
},
37+
"editor.defaultFormatter": "xaver.clang-format",
38+
"editor.rulers": [80],
39+
"clang-format.style": "Google",
40+
"files.insertFinalNewline": true,
41+
"editor.detectIndentation": false,
42+
"editor.wrappingIndent": "none",
43+
"typescript.tsdk": "node_modules/typescript/lib",
44+
"clang-format.executable": "${workspaceRoot}/node_modules/.bin/clang-format",
45+
"files.associations": {
46+
"memory": "cpp",
47+
"any": "cpp",
48+
"array": "cpp",
49+
"atomic": "cpp",
50+
"strstream": "cpp",
51+
"*.tcc": "cpp",
52+
"bitset": "cpp",
53+
"cctype": "cpp",
54+
"chrono": "cpp",
55+
"cinttypes": "cpp",
56+
"clocale": "cpp",
57+
"cmath": "cpp",
58+
"codecvt": "cpp",
59+
"complex": "cpp",
60+
"condition_variable": "cpp",
61+
"cstdarg": "cpp",
62+
"cstddef": "cpp",
63+
"cstdint": "cpp",
64+
"cstdio": "cpp",
65+
"cstdlib": "cpp",
66+
"cstring": "cpp",
67+
"ctime": "cpp",
68+
"cwchar": "cpp",
69+
"cwctype": "cpp",
70+
"deque": "cpp",
71+
"list": "cpp",
72+
"unordered_map": "cpp",
73+
"unordered_set": "cpp",
74+
"vector": "cpp",
75+
"exception": "cpp",
76+
"algorithm": "cpp",
77+
"filesystem": "cpp",
78+
"functional": "cpp",
79+
"iterator": "cpp",
80+
"map": "cpp",
81+
"memory_resource": "cpp",
82+
"numeric": "cpp",
83+
"optional": "cpp",
84+
"random": "cpp",
85+
"ratio": "cpp",
86+
"regex": "cpp",
87+
"set": "cpp",
88+
"string": "cpp",
89+
"string_view": "cpp",
90+
"system_error": "cpp",
91+
"tuple": "cpp",
92+
"type_traits": "cpp",
93+
"utility": "cpp",
94+
"fstream": "cpp",
95+
"future": "cpp",
96+
"initializer_list": "cpp",
97+
"iomanip": "cpp",
98+
"iosfwd": "cpp",
99+
"iostream": "cpp",
100+
"istream": "cpp",
101+
"limits": "cpp",
102+
"mutex": "cpp",
103+
"new": "cpp",
104+
"ostream": "cpp",
105+
"shared_mutex": "cpp",
106+
"sstream": "cpp",
107+
"stdexcept": "cpp",
108+
"streambuf": "cpp",
109+
"thread": "cpp",
110+
"cfenv": "cpp",
111+
"typeinfo": "cpp",
112+
"valarray": "cpp",
113+
"variant": "cpp",
114+
"charconv": "cpp",
115+
"__bit_reference": "cpp",
116+
"__config": "cpp",
117+
"__debug": "cpp",
118+
"__errc": "cpp",
119+
"__functional_base": "cpp",
120+
"__hash_table": "cpp",
121+
"__locale": "cpp",
122+
"__mutex_base": "cpp",
123+
"__node_handle": "cpp",
124+
"__nullptr": "cpp",
125+
"__split_buffer": "cpp",
126+
"__sso_allocator": "cpp",
127+
"__std_stream": "cpp",
128+
"__string": "cpp",
129+
"__threading_support": "cpp",
130+
"__tree": "cpp",
131+
"__tuple": "cpp",
132+
"bit": "cpp",
133+
"ios": "cpp",
134+
"locale": "cpp",
135+
"queue": "cpp",
136+
"stack": "cpp",
137+
"*.ipp": "cpp",
138+
"forward_list": "cpp",
139+
"typeindex": "cpp",
140+
"*.inc": "cpp",
141+
"hash_map": "cpp",
142+
"__refstring": "cpp"
143+
},
144+
"editor.formatOnSave": true
145+
}

‎pose-detection/src/index.ts

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* @license
3+
* Copyright 2021 Google LLC. All Rights Reserved.
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
* =============================================================================
16+
*/
17+
18+
import {PoseDetector} from './pose_detector';
19+
import {ModelConfig, SupportedModels} from './types';
20+
21+
/** Supported models. */
22+
export {SupportedModels};
23+
24+
/**
25+
* Create a pose detector instance.
26+
*
27+
* @param model The name of the pipeline to load.
28+
*/
29+
export async function createDetector(
30+
model: SupportedModels,
31+
modelConfig: ModelConfig = {}): Promise<PoseDetector> {
32+
switch (model) {
33+
default:
34+
throw new Error(`${model} is not a valid package name.`);
35+
}
36+
}

‎pose-detection/src/pose_detector.ts

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* @license
3+
* Copyright 2021 Google LLC. All Rights Reserved.
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
* =============================================================================
16+
*/
17+
import {EstimationConfig, Keypoint, PoseDetectorInput} from './types';
18+
19+
/**
20+
* User-facing interface for all pose detectors.
21+
*/
22+
export interface PoseDetector {
23+
/**
24+
* Estimate poses for an image or video frame.
25+
* @param image An image or video frame.
26+
* @param config See `EstimationConfig` for available options.
27+
* @returns An array of poses, each pose contains an array of `Keypoint`s.
28+
*/
29+
estimatePoses(image: PoseDetectorInput, config?: EstimationConfig):
30+
Promise<[Keypoint[]]>;
31+
}
32+
33+
/**
34+
* Internal interface for all pose detectors to create instance and load models.
35+
*/
36+
export interface PoseDetectorLoader {
37+
/**
38+
* Load models.
39+
*/
40+
load(): Promise<void>;
41+
}

‎pose-detection/src/types.ts

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/**
2+
* @license
3+
* Copyright 2021 Google LLC. All Rights Reserved.
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
* =============================================================================
16+
*/
17+
import * as tf from '@tensorflow/tfjs-core';
18+
19+
export enum SupportedModels {
20+
posenet = 'posenet'
21+
}
22+
23+
/**
24+
* Common config to create the pose detector.
25+
*/
26+
export interface ModelConfig {
27+
quantBytes?: number;
28+
}
29+
30+
/**
31+
* Allowed input format for the `estimatePoses` method.
32+
*/
33+
export type PoseDetectorInput =
34+
tf.Tensor3D|ImageData|HTMLVideoElement|HTMLImageElement|HTMLCanvasElement;
35+
36+
/**
37+
* Common config for the `estimatePoses` method.
38+
*/
39+
export interface EstimationConfig {
40+
maxPoses?: number;
41+
flipHorizontal?: boolean;
42+
smoothLandmarks?: boolean;
43+
maxContinousChecks?: number;
44+
}
45+
46+
/**
47+
* A keypoint that contains coordinate information.
48+
*/
49+
export interface Keypoint {
50+
x: number, y: number
51+
}

‎pose-detection/src/version.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/** @license See the LICENSE file. */
2+
3+
// This code is auto-generated, do not modify this file!
4+
const version = '0.0.1';
5+
export {version};

‎workspace.code-workspace

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
{
2+
"folders": [
3+
{
4+
"name": "Common",
5+
"path": "."
6+
},
7+
{
8+
"name": "Blazeface",
9+
"path": "blazeface"
10+
},
11+
{
12+
"name": "FaceLandmarksDetection",
13+
"path": "face-landmarks-detection"
14+
},
15+
{
16+
"name": "HandPose",
17+
"path": "handpose"
18+
},
19+
{
20+
"name": "PoseDetection",
21+
"path": "pose-detection"
22+
},
23+
{
24+
"name": "Posenet",
25+
"path": "posenet"
26+
},
27+
{
28+
"name": "Bodypix",
29+
"path": "body-pix"
30+
},
31+
{
32+
"name": "CocoSsd",
33+
"path": "coco-ssd"
34+
},
35+
{
36+
"name": "Deeplab",
37+
"path": "deeplab"
38+
},
39+
{
40+
"name": "Mobilenet",
41+
"path": "mobilenet"
42+
},
43+
{
44+
"name": "QnA",
45+
"path": "qna"
46+
},
47+
{
48+
"name": "SpeechCommands",
49+
"path": "speech-commands"
50+
},
51+
{
52+
"name": "Toxicity",
53+
"path": "toxicity"
54+
},
55+
{
56+
"name": "UniversalSentenceEncoder",
57+
"path": "universal-sentence-encoder"
58+
},
59+
{
60+
"name": "Knn",
61+
"path": "knn-classifier"
62+
}
63+
],
64+
"settings": {
65+
"search.exclude": {
66+
"**/node_modules": true,
67+
"**/coverage/": true,
68+
"**/dist/": true,
69+
"**/yarn.lock": true,
70+
"**/.rpt2_cache/": true,
71+
"**/.yalc/**/*": true,
72+
"**/.cache/**/*": true
73+
},
74+
"tslint.configFile": "tslint.json",
75+
"files.trimTrailingWhitespace": true,
76+
"editor.tabSize": 2,
77+
"editor.insertSpaces": true,
78+
"[typescript]": {
79+
"editor.formatOnSave": true
80+
},
81+
"[javascript]": {
82+
"editor.formatOnSave": true
83+
},
84+
"[cpp]": {
85+
"editor.formatOnSave": true
86+
},
87+
"editor.defaultFormatter": "xaver.clang-format",
88+
"editor.rulers": [80],
89+
"clang-format.style": "Google",
90+
"files.insertFinalNewline": true,
91+
"editor.detectIndentation": false,
92+
"editor.wrappingIndent": "none",
93+
"typescript.tsdk": "${workspaceRoot}/node_modules/typescript/lib",
94+
"clang-format.executable": "${workspaceRoot}/node_modules/.bin/clang-format"
95+
},
96+
"extensions": {
97+
"recommendations": [
98+
// Formats typescript, javascript and c++ code.
99+
"xaver.clang-format",
100+
// Lints typescipt code.
101+
"ms-vscode.vscode-typescript-tslint-plugin",
102+
// Running custom linters on save.
103+
"emeraldwalk.RunOnSave"
104+
]
105+
}
106+
}

0 commit comments

Comments
 (0)
Please sign in to comment.