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

Method estimateSinglePose

posenet/src/posenet_model.ts:344–376  ·  view source on GitHub ↗

* Infer through PoseNet, and estimates a single pose 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: SinglePersonInterfaceConfig = SINGLE_PERSON_INFERENCE_CONFIG)

Source from the content-addressed store, hash-verified

342 * in the same scale as the original image
343 */
344 async estimateSinglePose(
345 input: PosenetInput,
346 config: SinglePersonInterfaceConfig = SINGLE_PERSON_INFERENCE_CONFIG):
347 Promise<Pose> {
348 const configWithDefaults = {...SINGLE_PERSON_INFERENCE_CONFIG, ...config};
349
350 validateSinglePersonInferenceConfig(configWithDefaults);
351
352 const outputStride = this.baseModel.outputStride;
353 const inputResolution = this.inputResolution;
354
355 const [height, width] = getInputTensorDimensions(input);
356
357 const {resized, padding} = padAndResizeTo(input, inputResolution);
358
359 const {heatmapScores, offsets, displacementFwd, displacementBwd} =
360 this.baseModel.predict(resized);
361
362 const pose = await decodeSinglePose(heatmapScores, offsets, outputStride);
363 const poses = [pose];
364
365 const resultPoses = scaleAndFlipPoses(
366 poses, [height, width], inputResolution, padding,
367 configWithDefaults.flipHorizontal);
368
369 heatmapScores.dispose();
370 offsets.dispose();
371 displacementFwd.dispose();
372 displacementBwd.dispose();
373 resized.dispose();
374
375 return resultPoses[0];
376 }
377
378 /** Deprecated: Use either estimateSinglePose or estimateMultiplePoses */
379 async estimatePoses(

Callers 2

estimatePosesMethod · 0.95
posenet_test.tsFile · 0.45

Calls 7

getInputTensorDimensionsFunction · 0.90
padAndResizeToFunction · 0.90
decodeSinglePoseFunction · 0.90
scaleAndFlipPosesFunction · 0.90
disposeMethod · 0.65
predictMethod · 0.45

Tested by

no test coverage detected