Я работал с этим руководством: [https://www.pyimagesearch.com/2019/01/28/keras-regression-and-cnns/][1]
Часть кода:
split = train_test_split(df, images, test_size=0.25, random_state=42)
(trainAttrX, testAttrX, trainImagesX, testImagesX) = split
# train the model
print("[INFO] training model...")
model.fit(trainImagesX, trainY, validation_data=(testImagesX, testY),
epochs=200, batch_size=8)
# make predictions on the testing data
print("[INFO] predicting house prices...")
preds = model.predict(testImagesX)
# compute the difference between the *predicted* house prices and the
# *actual* house prices, then compute the percentage difference and
# the absolute percentage difference
diff = preds.flatten() - testY
percentDiff = (diff / testY) * 100
absPercentDiff = np.abs(percentDiff)
# compute the mean and standard deviation of the absolute percentage
# difference
mean = np.mean(absPercentDiff)
std = np.std(absPercentDiff)
# finally, show some statistics on our model
locale.setlocale(locale.LC_ALL, "en_US.UTF-8")
print("[INFO] avg. house price: {}, std house price: {}".format(
ocale.currency(df["price"].mean(), grouping=True),
locale.currency(df["price"].std(), grouping=True)))
print("[INFO] mean: {:.2f}%, std: {:.2f}%".format(mean, std))
В коде делается предсказание и текстовое значение междуфактическая цена и прогнозируемая цена. Все работает хорошо, однако я хотел бы показать в качестве вывода изображение, где сделан прогноз: я думаю, что первый шаг должен сделать что-то вроде этого: for image in testImagesX:
preds = model.predict([image])
ОттудаВы захотите изменить мое изображение в (H, W, D) порядке и нарисовать прогноз на изображении, но я не знаю, как сделать следующий шаг.
Заранее спасибо