且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Tensorflow中使用经过训练的CNN模型进行对象识别

更新时间:2022-06-26 01:22:33

我不明白您的问题。通过120个样本,您是说有120个类别,每个类别的示例图像很少?在那种情况下,这是分类问题,您训练一个用于分类的模型,其中输入作为图像,输出作为输入属于120个类别之一的概率(+不属于任何这些类别的额外类别)。在这种情况下,将完全连接的层馈入softmax函数,该函数输出120个类的概率,该类本质上是长度为120的向量。但是,为此,每个类需要多个训练示例。

I didn't understand your question. By 120 samples, do you mean there are 120 classes with few examples images per class? In that case, this is classification problem where you train a model for classification with input as image and output as probability that the input will belong to one of the 120 classes (+ extra class that it doesnt belong to any of those). In this case, fully connected layer is fed into softmax function that outputs this probability for 120 classes which is essentially vector of length 120. But for this, you need multiple training examples per class.

如果您只有120张图像,并且您需要知道其他测试图像是否与这些图像之一相似,则可以为已经存在的神经网络的那120张图像获取完全连接的层之前的层输出矢量在较大的图像样本(例如初始模型)上进行训练,然后将测试图像向量与这120个向量进行相似性处理。

In case you just have 120 images and you need to know if another test image similarity with one of these images, you can just take output vector of layer before fully connected layer for those 120 images for a neural network that is already trained on a larger sample of images (like inception model) and then just similarity of the test image vector with those 120 vectors.

我主持了一个简单易用的演示程序,使用以上技术此处。检查是否可以为您解决,否则请进一步完善问题说明。

I have hosted a simple to use demo using above technique here. Check if works out for you otherwise refine the problem statement more.