MCPcopy
hub / github.com/tensorflow/tfjs-models / estimateMultiplePoses

Method estimateMultiplePoses

posenet/src/posenet_model.ts:279–324  ·  view source on GitHub ↗

* Infer through PoseNet, and estimates multiple poses using the outputs. * This does standard ImageNet pre-processing before inferring through the * model. The image should pixels should have values [0-255]. It detects * multiple poses and finds their parts from part scores and displacement

(
      input: PosenetInput,
      config: MultiPersonInferenceConfig = MULTI_PERSON_INFERENCE_CONFIG)

Source from the content-addressed store, hash-verified

277 * in the same scale as the original image
278 */
279 async estimateMultiplePoses(
280 input: PosenetInput,
281 config: MultiPersonInferenceConfig = MULTI_PERSON_INFERENCE_CONFIG):
282 Promise<Pose[]> {
283 const configWithDefaults: MultiPersonInferenceConfig = {
284 ...MULTI_PERSON_INFERENCE_CONFIG,
285 ...config
286 };
287
288 validateMultiPersonInputConfig(config);
289
290 const outputStride = this.baseModel.outputStride;
291 const inputResolution = this.inputResolution;
292
293 const [height, width] = getInputTensorDimensions(input);
294
295 const {resized, padding} = padAndResizeTo(input, inputResolution);
296
297 const {heatmapScores, offsets, displacementFwd, displacementBwd} =
298 this.baseModel.predict(resized);
299
300 const allTensorBuffers = await toTensorBuffers3D(
301 [heatmapScores, offsets, displacementFwd, displacementBwd]);
302
303 const scoresBuffer = allTensorBuffers[0];
304 const offsetsBuffer = allTensorBuffers[1];
305 const displacementsFwdBuffer = allTensorBuffers[2];
306 const displacementsBwdBuffer = allTensorBuffers[3];
307
308 const poses = await decodeMultiplePoses(
309 scoresBuffer, offsetsBuffer, displacementsFwdBuffer,
310 displacementsBwdBuffer, outputStride, configWithDefaults.maxDetections,
311 configWithDefaults.scoreThreshold, configWithDefaults.nmsRadius);
312
313 const resultPoses = scaleAndFlipPoses(
314 poses, [height, width], inputResolution, padding,
315 configWithDefaults.flipHorizontal);
316
317 heatmapScores.dispose();
318 offsets.dispose();
319 displacementFwd.dispose();
320 displacementBwd.dispose();
321 resized.dispose();
322
323 return resultPoses;
324 }
325
326 /**
327 * Infer through PoseNet, and estimates a single pose using the outputs.

Callers 2

estimatePosesMethod · 0.95
posenet_test.tsFile · 0.45

Calls 8

getInputTensorDimensionsFunction · 0.90
padAndResizeToFunction · 0.90
toTensorBuffers3DFunction · 0.90
decodeMultiplePosesFunction · 0.90
scaleAndFlipPosesFunction · 0.90
disposeMethod · 0.65
predictMethod · 0.45

Tested by

no test coverage detected