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

Function toInputTensor

deeplab/src/utils.ts:133–144  ·  view source on GitHub ↗
(input: DeepLabInput)

Source from the content-addressed store, hash-verified

131 * The input tensor to run through the model.
132 */
133export function toInputTensor(input: DeepLabInput) {
134 return tf.tidy(() => {
135 const image =
136 input instanceof tf.Tensor ? input : tf.browser.fromPixels(input);
137 const [height, width] = image.shape;
138 const resizeRatio = config['CROP_SIZE'] / Math.max(width, height);
139 const targetHeight = Math.round(height * resizeRatio);
140 const targetWidth = Math.round(width * resizeRatio);
141 return tf.expandDims(
142 tf.image.resizeBilinear(image, [targetHeight, targetWidth]));
143 });
144}
145
146/**
147 * @param colormap :: `Color[]`

Callers 1

predictMethod · 0.90

Calls 1

maxMethod · 0.45

Tested by

no test coverage detected