[英]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.