如何在神经网络中检测训练好的图像?

How to detect the trained images in the neural network?

我使用卷积神经网络 (CNN) 训练地图中的图例。这些图例是圆形、椭圆形、菱形、十字形和正方形。神经网络(灵感来源于代码https://towardsdatascience.com/from-raw-images-to-real-time-predictions-with-deep-learning-ddbbda1be0e4) works well in my case. The input images are individual cropped pictures of legends like input trained image and the output I want is to predict these legends in the maps like input maps. My neural network can now classify the images and predict whether they are squares or circles. For example, when I provided this image diamondinput作为输入,输出为菱形

from keras.models import model_from_json
import numpy as np

EMOTIONS_LIST = ["circle","cross","diamond","oval","square"]
def predict_emotion(img):
        preds = model.predict(img)
        return EMOTIONS_LIST[np.argmax(preds)]
import cv2
import numpy as np
from google.colab.patches import cv2_imshow
import keras
#model =  keras.models.load_model('/content/drive/MyDrive/model_weights_updated.h5')
fr=cv2.imread('/content/drive/MyDrive/Images/train/diamond/Copy of 0076.tif')
gray_fr = cv2.cvtColor(fr, cv2.COLOR_BGR2GRAY)
roi = cv2.resize(gray_fr, (48, 48))
pred = predict_emotion(roi[np.newaxis, :, :, np.newaxis])
print(pred)

程序输出:

[[1.7809551e-06 2.4862277e-07 9.9999583e-01 2.1272169e-06 8.9550163e-09]], diamond

如何让神经网络像这样预测地图中的这些图例和地图中的所有其他图例outputmap?

使用您获得的网络,可以将每个地图拆分为一个网格,然后对网格中的每个部分执行 class化,但这种方法存在很多问题。

对您来说更好的解决方案是使用进行语义分割的神经网络。这样,您的网络会为地图上的每个形状回归似然图。使用此似然图,您将知道每个 class 有多少以及它们在哪里。

为此,您可以从以下 MaskRCNN 实现开始。

https://github.com/matterport/Mask_RCNN