Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

conversion to tensorflow.js #6

Open
jan-bogaerts opened this issue May 25, 2022 · 0 comments
Open

conversion to tensorflow.js #6

jan-bogaerts opened this issue May 25, 2022 · 0 comments

Comments

@jan-bogaerts
Copy link

Hi,
I've been trying to convert the mtcnn model to tensorflow.js, but so far, I keep getting empty results back. Do you have any idea what I'm doing wrong?

here's my test code snippet:

const tf = require('@tensorflow/tfjs-node');
const fs = require('fs');

const MIN_SIZE = 40;
const FACTOR = 0.7;
const THRESHOLDS = [0.6, 0.7, 0.8];

async function load() {
    await tf.ready();
    const MODEL_URL = tf.io.fileSystem('./src/models/mtcnn_web/model.json');
    const model = await tf.loadGraphModel(MODEL_URL);
    return model;
}

load().then( async (model) => {
    const image = fs.readFileSync('./test_data/test_image2.jpg');
    const tensor = tf.node.decodeImage(image);
    const floatTensor = tf.cast(tensor, 'float32');
    const input = {
        'input': floatTensor,
        'min_size': tf.tensor(MIN_SIZE),
        'thresholds': tf.tensor(THRESHOLDS),
        'factor': tf.tensor(FACTOR),
    }
    const result = await model.executeAsync(input);
    const values = result[0].dataSync();
    const arr = Array.from(values);
    console.log(arr);
}).catch((error) => {
    console.log(error.toString());
})
  • I first converted the model to RGB mode as you mentioned here: Detection differences to facenet-mtcnn #5
  • next, I converted the model using this command (details here: https://github.com/tensorflow/tfjs/tree/master/tfjs-converter):
    tensorflowjs_converter --input_format=tf_frozen_model --output_node_names='prob,landmarks,box' /python/mtcnn.pb /python/mtcnn_web
    also tried:
    tensorflowjs_converter --input_format=tf_frozen_model --output_node_names='prob:0,landmarks:0,box:0' /python/mtcnn.pb /python/mtcnn_web
  • I also tried with inputs like 'input:0', 'min_size:0'
    I'm not getting any errors, but nothing is detected either. So I'm thinking, maybe somehting is wrong with the model conversion?
    One thing I'm thinking about: I currently presume that the input format is 'frozen_model' cause of the .pb extension?

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant