ML / Tensorflow beginner.
I'm having trouble trying to get one of the layers from the coco ssd model imported as a package in a React application. I'm following the Pacman tensorflow.js example to retrain the model.
const modelPromise = cocoSsd.load();
Promise.all([modelPromise])
.then(cocoModel => {
console.log(cocoModel[0]);
var cocoModel = cocoModel[0].model;
console.log(cocoModel);
const layer = cocoModel.getLayer('conv_pw_13_relu');
this.truncatedCocoModel = tf.model({inputs: cocoModel.inputs, outputs:
layer.output});
})
.catch(error => {
console.error(error);
});
In the const layer line I get the error message that 'cocoModel.getLayer is not a function'. The Pacman example is using the mobilenet model which I guess has this function.
What are my options here? I looked around using the browser console but I can't find this function anywhere and looking online didn't help much (is there any place online where I can see the whole structure of the cocoSSD model by Google?)
Using the npm package https://cdn.jsdelivr.net/npm/@tensorflow-models/coco-ssd , you cannot retrieve any layer.
load returns an instance of ObjectDetection
which does not have the getLayer
property.
If you want to retrieve the layer, you would have to load the graph model as described here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.