MaskRCNN用于检测路标,作为更详细的目标检测,用以得到更精准的额路标位置,路标的几何中心点,用于构建更为精准的拓扑地图,减少构图误差。

抠图工具已经完成,把框抠出来,用0值表示背景。

python代码:

def mainex():#initDir();# Root directory of the projectROOT_DIR = os.getcwd()# Directory to save logs and trained modelMODEL_DIR = os.path.join(ROOT_DIR, "logs")# Path to trained weights file# Download this file and place in the root of your# project (See README file for details)#COCO_MODEL_PATH = os.path.join(ROOT_DIR, "mask_rcnn_coco.h5")COCO_MODEL_PATH= "D:/Works/PyProj/MaskRCNN-tensor/data/model/mask_rcnn_coco.h5";# Directory of images to run detection on#IMAGE_DIR = os.path.join(ROOT_DIR, "images");IMAGE_DIR = "data/MedSeaTest/";config = InferenceConfig()config.display();# 3.# Create model object in inference mode.model = modellib.MaskRCNN(mode="inference", model_dir=MODEL_DIR, config=config)# Load weights trained on MS-COCOmodel.load_weights(COCO_MODEL_PATH, by_name=True);# 4class_names= init_classname();IMAGE_DIR = "D:/DataSet/PicStyleTest/Medsea3/deskfilter/";proDir(model, class_names, IMAGE_DIR);

处理目录:

def proDir( model,class_names,IMAGE_DIR ):# Load a random image from the images folderprint(IMAGE_DIR);extention =".jpg";filelist =traverseFolder( IMAGE_DIR , extention);#traverse( IMAGE_DIR , extention);#for file in filelist:print("Is processing: ");print(file);image = skimage.io.imread( file );# Run detectionresults = model.detect([image], verbose=1);# Visualize results#r = results[0];fileName = file;getAllLabelMask(fileName, image, results[0], class_names)
def getAllLabelMask(fileName,image, maskResult,class_names ):"""boxes: [num_instance, (y1, x1, y2, x2, class_id)] in image coordinates.masks: [num_instances, height, width]class_ids: [num_instances]class_names: list of class names of the datasetscores: (optional) confidence scores for each boxfigsize: (optional) the size of the image."""boxes  = maskResult['rois'];masks  = maskResult['masks']; scores = maskResult['scores'];class_ids = maskResult['class_ids'];# Number of instancesN = boxes.shape[0];if not( N<1 or boxes.shape[0] == masks.shape[-1] == class_ids.shape[0]):returnrow = image.shape[1];col = image.shape[0];for i in range(N):# Bounding boxif not np.any(boxes[i]): continue;y1, x1, y2, x2 = boxes[i];# Labelclass_id = class_ids[i];score = scores[i] if scores is not None else Nonelabel = class_names[class_id];# Maskmask = masks[:, :, i];masked_image = np.zeros((col, row, 3), dtype=np.uint8);masked_image = apply_maskX(masked_image, mask);#frontImage = np.zeros( (col, row), dtype=np.uint8 );frontImage = image.copy();for m in range(row):for n in range(col):if(masked_image[n, m, 0]<254):#frontImage[n, m] = 255;frontImage[n,m,0] =0;frontImage[n, m, 1] = 0;frontImage[n, m, 2] = 0;#roiMask = masked_image[y1:y2, x1:x2];roiImg = frontImage[y1:y2, x1:x2];roiImg = cv2.cvtColor(roiImg, cv2.COLOR_BGR2RGB);fileMask = fileName[0: len(fileName)-4];fileMask = fileMask +"."+ str(i)+"."+label+"."+"Mask.png";cv2.imwrite(fileMask, roiImg);

结果:

MaskRCNN路标:TensorFlow版本用于抠图相关推荐

  1. tensorflow2.0支持的python版本-TensorFlow 版本兼容性

    本文面向需要在不同版本的 TensorFlow 之间向后兼容(针对代码或者数据)的用户,以及想要修改 TensorFlow 并同时保持兼容性的开发者. 语义化版本控制 2.0 TensorFlow 的 ...

  2. Detectron-MaskRCnn: 用于抠图的FCNN

    市面上暂时还没有找到可以在消费机显卡上实时运行的MaskRCnn,TensorFlow即使是C++版本训练在coco数据集上的模型也是慢的要死,最后不堪忍受,只能放弃. 经历了一些列fuckingDo ...

  3. ROS开发笔记(10)——ROS 深度强化学习dqn应用之tensorflow版本(double dqn/dueling dqn/prioritized replay dqn)

    ROS开发笔记(10)--ROS 深度强化学习dqn应用之tensorflow版本(double dqn/dueling dqn/prioritized replay dqn) 在ROS开发笔记(9) ...

  4. 查看已安装tensorflow版本

    查看已安装tensorflow版本 2017年08月07日 20:40:23 imperfect00 阅读数 187297更多 个人分类: tensorflow学习笔记 版权声明:本文为博主原创文章, ...

  5. TensorFlow 版本 1.10.0 发布

    我们非常开心的跟大家分享一条新消息!TensorFlow 版本 1.10.0 已经正式发布啦!请阅读本文,及时了解一些主要特点和功能改进,以及一些突破性变化! ▌重大改变 TensorFlow 1.1 ...

  6. tensorflow版本问题导致的错误AttributeError: module ‘tensorflow‘ has no attribute ‘***‘

    问题解决--AttributeError: module 'tensorflow' has no attribute 'placeholder' - yuanyuanWu11 - 博客园 tensor ...

  7. TF版本升级问题集合:成功解决由于不同的TensorFlow版本之间某些函数的用法引起的错误

    TF版本升级问题集合:成功解决由于不同的TensorFlow版本之间某些函数的用法引起的错误 目录 遇到的问题以及对应解决方法 遇到的问题以及对应解决方法 Transitioning to Tenso ...

  8. tensorflow版本及其对应环境

    tensorflow版本及其对应环境 Windows CPU GPU 安装命令 下载地址 来自官网的发布 https://www.tensorflow.org/install/source_windo ...

  9. 解决Keras 与 Tensorflow 版本之间的兼容性问题,导入keras报错:module 'tensorflow.python.keras.backend' has no attribute

    解决Keras 与 Tensorflow 版本之间的兼容性问题 原因是:不同版本的Keras对应不同的版本的TensorFlow https://docs.floydhub.com/guides/en ...

最新文章

  1. python环境问题踩坑
  2. 转正答辩ppt_同心同行 乘风破浪 兴业装饰新员工转正考核圆满完成
  3. DirectX下 Viewing Frustum 的详细实现
  4. 使用 OAuth2-Server-php 搭建 OAuth2 Server
  5. 线性表(代码、分析、汇编)
  6. 浅析tornado协程运行原理
  7. 【Acm】算法之美—Fire Net
  8. 在WinForm程序中嵌入ASP.NET[转]
  9. mysql远程连接出错
  10. 暂别ACM,转移阵地
  11. 拥塞控制,图文并茂(挺丰富,借鉴较多大佬的思想)
  12. Vue-Devtools 安装教程
  13. word论文排版插件_word论文排版自动编号设置
  14. “任期”已近20年,这个AI训练工具有点儿问题
  15. utf-8的中文是一个汉字占三个字节长度吗?
  16. 数据分析之Excel的基本功能(上)
  17. 浅谈在软件开发中的开发与测试 - 下
  18. Androud7.0之IPC机制(多进程、及其通信)
  19. 批处理设置windows防火墙协议规则
  20. python恢复手机数据的软件_有什么万能的手机数据恢复软件吗?

热门文章

  1. HBase之BloomFilter
  2. 分析攻击IP来源地并画出饼图
  3. 《iOS应用软件设计之道》—— 2.11 小结
  4. 外贸电商选择美国服务器的优势分析
  5. HDU 3549 Flow Problem
  6. POJ 3104 Drying [二分 有坑点 好题]
  7. 精简系统绝对不可删除的应用程序
  8. 职场透视:我们都是猪八戒?
  9. 汽车维修行业呼吁大学生加入修车行列
  10. WIN SERVER8更改MYSQL的datadir后,数据库启动不起来