【发布时间】:2021-04-04 03:35:43
【问题描述】:
我正在尝试创建一个对象定位模型来检测汽车图像中的车牌。我使用 VGG16 模型并排除顶层以添加我自己的密集层,最后一层有 4 个节点和 sigmoid 激活以获得 (xmin, ymin, xmax, ymax)。
我使用 keras 提供的函数读取图像,并将其调整为 (224, 244, 3),还使用 preprocess_input() 函数处理输入。我还尝试通过使用填充调整大小以保持比例来手动处理图像,并通过除以 255 来标准化输入。
我训练时似乎没有任何效果。我得到 0% 的训练和测试准确率。下面是我的这个模型的代码。
def get_custom(output_size, optimizer, loss):
vgg = VGG16(weights="imagenet", include_top=False, input_tensor=Input(shape=IMG_DIMS))
vgg.trainable = False
flatten = vgg.output
flatten = Flatten()(flatten)
bboxHead = Dense(128, activation="relu")(flatten)
bboxHead = Dense(32, activation="relu")(bboxHead)
bboxHead = Dense(output_size, activation="sigmoid")(bboxHead)
model = Model(inputs=vgg.input, outputs=bboxHead)
model.compile(loss=loss, optimizer=optimizer, metrics=['accuracy'])
return model
X 和 y 的形状分别为 (616, 224, 224, 3) 和 (616, 4)。我将坐标除以各边的长度,因此 y 中的每个值都在 (0,1) 范围内。
我将从 github 链接下面的 python 笔记本,以便您查看完整代码。我正在使用 google colab 来训练模型。 https://github.com/gauthamramesh3110/image_processing_scripts/blob/main/License_Plate_Detection.ipynb
提前致谢。我真的很需要帮助。
【问题讨论】:
标签: tensorflow machine-learning keras deep-learning object-detection