Hi TF-JS folks…!
I’m trying to learn to use pre-trained models for face detection, and having some difficulties. This is what I am doing:
- Download this Model from the Hub)
- Load it with this code:
import * as tf from "@tensorflow/tfjs";
import "@tensorflow/tfjs-node";
import { join } from "path";
const model = tf.loadGraphModel(
`file://${join(__dirname, "hub-models/model.json")}`
).then((model) => {
// to see what format it expects
console.log(model.inputs)
})
But I can’t quite get how to input an image to it
The previous code shows the expected input shape:
[ { name: 'input', shape: [ -1, 128, 128, 3 ], dtype: 'float32' } ]
The page for the model states otherwise though:
This is a TF.js model for use with TF.js library. The model has FP16 precision.
I should probably do this:
- Resize image (altering aspect ratio unless they are squared ?) to 128 pixels
- Remove the alpha channel ?
- Get it to float32 format (the one I am most confused with.)
Anyone experienced on this with any advice ?