![](/img/trans.png)
[英]how to train a custom object detection model ssd_mobilenet_v1_coco and ssd_inception_v2_coco on google colab tensorflow 1.15.2?
[英]How can I load/retrain/save ssd_inception_v2_coco on tensorflow.js?
ML / Tensorflow初学者。
是否可以将这些已经训练过的模型中的任何一个加载到tfjs上并在那里进行再训练,然后导出到Downloads或Tensorflow python是唯一的选择?
我看到此过程在Tensorflow Python的本教程中得到了很好的描述和记录,但是不幸的是,我找不到任何文档/教程来使用tfjs在浏览器上重新训练对象检测模型(图像分类是,对象检测否)。
我看到了如何使用npm加载coco-ssd模型,然后甚至可能触发将其保存到下载中,但是呢:
是否有任何方法可以重新训练诸如ssd_inception_v2_coco之类的ssd模型,而我没有找到正确的Google关键字,或者在当前框架状态下是否不可能?
您可以通过将coco-ssd模型用作特征提取器来使用转移学习。 这里可以看到一个转移学习的例子。
这是一个使用特征提取器作为新顺序模型的输入来提取特征的模型。
const loadModel = async () => {
const loadedModel = await tf.loadModel(MODEL_URL)
console.log(loadedModel)
// take whatever layer except last output
loadedModel.layers.forEach(layer => console.log(layer.name))
const layer = loadedModel.getLayer(LAYER_NAME)
return tf.model({ inputs: loadedModel.inputs, outputs: layer.output });
}
loadModel().then(featureExtractor => {
model = tf.sequential({
layers: [
// Flattens the input to a vector so we can use it in a dense layer. While
// technically a layer, this only performs a reshape (and has no training
// parameters).
// slice so as not to take the batch size
tf.layers.flatten(
{ inputShape: featureExtractor.outputs[0].shape.slice(1) }),
// add all the layers of the model to train
tf.layers.dense({
units: UNITS,
activation: 'relu',
kernelInitializer: 'varianceScaling',
useBias: true
}),
// Last Layer. The number of units of the last layer should correspond
// to the number of classes to predict.
tf.layers.dense({
units: NUM_CLASSES,
kernelInitializer: 'varianceScaling',
useBias: false,
activation: 'softmax'
})
]
});
})
要从90种coco-ssd中检测出单个物体,可以简单地对coco-ssd的预测使用条件测试。
const image = document.getElementById(id)
cocoSsd.load()
.then(model => model.detect(image))
.then(prediction => {
if (prediction.class === OBJECT_DETECTED) {
// display it the bbox to the user}
})
如果该类在coco-ssd中不存在,则需要构建一个检测器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.