我已经使用自己的图像数据集训练了自己的模型,用于图像中的对象识别,但它似乎无法识别所有对象。我只有 2 个对象(一个人键入特定字母的不同方式的图像)。例如字母“a”和字母“o”,如下所示。
当我在手写文本样本上运行测试代码时,在某种程度上,它确实说明了它的准确率百分比,但没有边界框。这是手写文本的图像:
这是我得到的输出:
我正在使用 imageai 来训练自定义模型。我想知道是否可以使用这个训练有素的模型在手写图像上运行多个对象检测并可能显示边界框?
这是我的工作目录的样子,以防它提供额外的帮助:
这是我训练模型的代码(custom_detector.py):
from imageai.Prediction.Custom import ModelTraining
# Instanciating the model
model_trainer = ModelTraining()
model_trainer.setModelTypeAsResNet()
# Setting our dataset directyory
model_trainer.setDataDirectory("characters")
# training the model
model_trainer.trainModel(num_objects=2, num_experiments=100, enhance_data=True, batch_size=10)
这是我用于测试训练模型(test.py)的代码:
from imageai.Prediction.Custom import CustomImagePrediction
import os
# get the working directory
execution_path = os.getcwd()
print(execution_path)
# instanciate prediction
prediction = CustomImagePrediction()
prediction.setModelTypeAsResNet()
# Set model path
prediction.setModelPath(os.path.join(execution_path, "characters", "models", "myModel.h5"))
# Set JSON path
# This is how the JSON file looks like:
#{
# "0" : "A",
# "1" : "O"
#}
prediction.setJsonPath(os.path.join(execution_path, "characters", "json", "model_class.json"))
# Initialize the number of objects you have retrained
prediction.loadModel(num_objects=2)
# run prediction
predictions, probabilities = prediction.predictImage(os.path.join(execution_path, "HandTextTest.jpg"), result_count=2)
# Print each prediction
for eachPrediction, eachProbability in zip(predictions, probabilities):
print(eachPrediction, " : ", eachProbability)
任何帮助或建议都将受到高度赞赏。