I am writing a very simple neural network to see whether it can be used for my scoped case of drawing a bounding box around a specific object (barcode) in an image.
The layers i am thinking of are:
- One convolution to detect edges and learn features of the barcode
- a few dense layers to adjust for predicting the 4 data points (x1,y1,x2,y2) of the specific object in the image.
In code, this is the basic schema:
// Generate a sequential model
const baseModel = tf.sequential();
// Layer 1: Convolutional
baseModel.add(
tf.layers.conv2d({
inputShape: [224, 224, 1],
filters: 64,
kernelSize: 4,
padding: "same",
activation: "relu",
})
);
baseModel.add(tf.layers.flatten())
baseModel.add(tf.layers.dense({ units: 128, activation: "relu" }))
baseModel.add(tf.layers.dense({ units: 64, activation: "relu" }))
baseModel.add(tf.layers.dense({ units: 4, activation: "sigmoid" }))
baseModel.compile({
optimizer: tf.train.adam(0.00001), //could be a parameter as well.
loss: tf.losses.meanSquaredError,
});
Would this steps be reasonable towards my goal of predicting bounding boxes?
I have read other posts and models, they normally use huge models with pretrained weights, but I wonder if, for a specific case, this schema could be enough.