Mask RCNN 实战-tensorFlow 2版本运行代码遇到的问题和解决办法

参考博客

  1. 打开github源码链接:github源码项目
    2022-03-02_19h00_15.png
  2. 打开上方地址下载数据集和权重:

2022-03-02_19h03_02.png
2022-03-02_19h03_15.png
3. 解压源码文件夹:把着标记的三个文件放到源码文件夹里
2022-03-02_19h06_29.png
2022-03-02_19h08_42.png

改model.py中这些函数:

在代码开头加上:
import os
os.environ['CUDA_VISIBLE_DEVICES'] = '/gpu:0'
函数替代:
tf.log() -> tf.math.log()
tf.sets.set_intersection() -> tf.sets.intersection()
tf.sparse_tensor_to_dense() -> tf.sparse.to_dense()
tf.to_float() -> tf.cast([value], tf.float32)
tf.to_int-> tf.cast(my_tensor, tf.int32)
tf.rint()-> tf.math.rint()

#refined_rois = tf.to_int32(tf.rint(refined_rois))-------错误
   refined_rois = tf.cast(tf.math.rint(refined_rois), tf.int32)-----正确
#tf.to_float([tf.gather(pre_nms_rois, ixs)]),
   tf.cast(tf.gather(pre_nms_rois, ixs), tf.float32),

照着下面图片改:
2022-03-02_19h20_05.png

balloon.py的parameters配置:

splash --weights=../../mask_rcnn_balloon.h5 --image=../../balloon/val/3800636873_ace2c2795f_b.jpg

运行ballon.py

结果:
2022-03-02_19h27_22.png
原图:
3800636873_ace2c2795f_b.jpg


版权声明:本文为weixin_43694742原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。