How to use the @tensorflow-models/posenet/dist/util.scaleAndFlipPoses function in @tensorflow-models/posenet

To help you get started, we’ve selected a few @tensorflow-models/posenet examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github googlecreativelab / teachablemachine-community / libraries / pose / src / custom-posenet.ts View on Github external
scoreThreshold: 0.5,
			nmsRadius: 20
		};

		const [height, width] = getInputTensorDimensions(input);

		const outputStride = this.posenetModel.baseModel.outputStride;
		const inputResolution = this.posenetModel.inputResolution;

		const [scoresBuffer, offsetsBuffer, displacementsFwdBuffer, displacementsBwdBuffer] 
			= await toTensorBuffers3D([heatmapScores, offsets, displacementFwd, displacementBwd]);

		const poses = await decodeMultiplePoses(scoresBuffer, offsetsBuffer, displacementsFwdBuffer,
			displacementsBwdBuffer, outputStride, config.maxDetections, config.scoreThreshold, config.nmsRadius);

		const resultPoses = scaleAndFlipPoses(poses, [height, width], inputResolution,
			padding, flipHorizontal);

		heatmapScores.dispose();
		offsets.dispose();
		displacementFwd.dispose();
		displacementBwd.dispose();
		
		return resultPoses[0];
	}