【问题标题】:How can I visualize validation with predicted arrays using Python?如何使用 Python 可视化使用预测数组的验证?
【发布时间】:2021-07-04 09:52:31
【问题描述】:
test_images_path, test_masks_path = get_data_paths(df, openimages_path, "test")
for i in test_images_path:
  img = cv2.imread(epicPath +"/" +i)
  img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
  img = cv2.resize(img, (256, 256),interpolation = cv2.INTER_NEAREST)
  img = (img-img.min())/(img.max()-img.min())
  norm = cv2.normalize(img, None, alpha=0, beta=1, norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_32F)
  epicPrediction = model.predict(np.expand_dims(norm, axis=0))
  #print(epicPrediction)

val_images_path, val_masks_path = get_data_paths(df, openimages_path, "validation")

for i in val_images_path:
  img = cv2.imread(epicPath +"/" +i)
  img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
  img = cv2.resize(img, (256, 256),interpolation = cv2.INTER_NEAREST)
  img = (img-img.min())/(img.max()-img.min())
  norm = cv2.normalize(img, None, alpha=0, beta=1, norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_32F)
  epicPrediction = model.predict(np.expand_dims(norm, axis=0))
  print(epicPrediction)

正如我在标题中提到的,我如何使用这些系列进行预测?我想指出,这是我的第一次经历。 提前致谢!

【问题讨论】:

  • 您是如何对标签进行编码的?整数还是分类?
  • 据我记忆,它是绝对的。

标签: python tensorflow keras prediction cv2


【解决方案1】:

如果您的输入是分类的,则预测是图像所属类别的概率值。要找出类别,请执行

class_index=np.argmax(epicPrediction) this will give you and index into the list of classes. I assume you have that stored somewhere . For example if your classes are stored in an ordered list like say [dog, cat, mouuse,etc] then the index points to the class.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-07-05
    • 2020-11-07
    • 2017-12-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多