MCPcopy Create free account
hub / github.com/tensorflow/tfjs / preprocess

Method preprocess

tfjs-automl/src/img_classification.ts:57–64  ·  view source on GitHub ↗
(input: ImageInput, options: ImageClassificationOptions)

Source from the content-addressed store, hash-verified

55 }
56
57 private preprocess(input: ImageInput, options: ImageClassificationOptions) {
58 // Preprocessing involves center crop and normalizing between [-1, 1].
59 const img = imageToTensor(input);
60 const croppedImg = options.centerCrop ?
61 centerCropAndResize(img) :
62 expandDims(image.resizeBilinear(img, IMG_SIZE));
63 return sub(div(croppedImg, DIV_FACTOR), SUB_FACTOR);
64 }
65}
66
67export async function loadImageClassification(modelUrl: string):

Callers 1

classifyMethod · 0.95

Calls 4

imageToTensorFunction · 0.90
centerCropAndResizeFunction · 0.85
resizeBilinearMethod · 0.80
expandDimsFunction · 0.50

Tested by

no test coverage detected