[win 10] maskrcnn-benchmark 上手(1)——配置环境与coco数据集介绍

全系列
[win 10] maskrcnn-benchmark 上手(1)——配置环境与coco数据集介绍
[win 10] maskrcnn-benchmark 上手(2)——开始训练
[win 10] maskrcnn-benchmark 上手(3)—— faster-rcnn 推理

博主win10

)

0. 配置环境

按照官网配置,遇到问题参考我之前的博客。这次我是在win10上完成全部的配置,demo都可以顺利运行。主要的pytorch 版本虽然官网说一定要1.0.0,但是1.1.0实测后其实也可以。torchvision==0.3.0,不能是0.4.0,不然报错,issue中有描述。

conda install pytorch==1.1.0 torchvision==0.3.0 cudatoolkit=10.0 -c pytorch

1. Coco数据集介绍

略过demo运行那,由于我是第一次使用coco,去coco官网需要自己下载数据集。这就遇到一个很烦的问题,不知道下载哪一个,找不到instance的数据集,只有stuff。
在这里插入图片描述
多亏了知乎文章,对coco api有了一定了解。因为这是个公共大的数据集,所以有公共的api和规范,dataloader和平常的就不一样。COCO的 全称是Common Objects in COntext,是微软团队提供的一个可以用来进行图像识别的数据集。MS COCO数据集中的图像分为训练、验证和测试集。COCO通过在Flickr上搜索80个对象类别和各种场景类型来收集图像,其使用了亚马逊的Mechanical Turk(AMT)。

object instances(目标实例)、object keypoints(目标上的关键点)、image captions(看图说话)这3种类型共享这些基本类型:info、image、license。

在instance segmentation 中,包含这么5种key。

{
    "info": info,
    "licenses": [license],
    "images": [image],
    "annotations": [annotation],
    "categories": [category]
}

共有的三种key结构

info{
    "year": int,
    "version": str,
    "description": str,
    "contributor": str,
    "url": str,
    "date_created": datetime,
}
license{
    "id": int,
    "name": str,
    "url": str,
} 
image{
    "id": int,
    "width": int,
    "height": int,
    "file_name": str,
    "license": int,
    "flickr_url": str,
    "coco_url": str,
    "date_captured": datetime,
}

由于打开那个json太卡了。。。仅仅详细展开了很少部分。

1.1 info

"info": 
{"description": "COCO 2017 Dataset",
"url": "http://cocodataset.org",
"version": "1.0",
"year": 2017,
"contributor": "COCO Consortium",
"date_created": "2017/09/01"},

1.2 images

images 是一个数组,其中包含了很多image的实例,image的结构参照共有部分结构。

"images": 
[{"license": 4,
"file_name": "000000397133.jpg",
"coco_url": "http://images.cocodataset.org/val2017/000000397133.jpg",
"height": 427,
"width": 640,
"date_captured": "2013-11-14 17:02:52",
"flickr_url": "http://farm7.staticflickr.com/6116/6255196340_da26cf2c9e_z.jpg",
"id": 397133},
{"license": 1,
"file_name": "000000037777.jpg",
"coco_url": "http://images.cocodataset.org/val2017/000000037777.jpg",
"height": 230,
"width": 352,
"date_captured": "2013-11-14 20:55:31",
"flickr_url": "http://farm9.staticflickr.com/8429/7839199426_f6d48aa585_z.jpg",
"id": 37777},
{"license": 4,
"file_name": "000000252219.jpg",
"coco_url": "http://images.cocodataset.org/val2017/000000252219.jpg",
"height": 428,
"width": 640,
...

1.3 licenses

licenses也是个数组,同images。

"licenses": 
[{"url": "http://creativecommons.org/licenses/by-nc-sa/2.0/",
"id": 1,
"name": "Attribution-NonCommercial-ShareAlike License"},
{"url": "http://creativecommons.org/licenses/by-nc/2.0/",
"id": 2,
"name": "Attribution-NonCommercial License"},
{"url": "http://creativecommons.org/licenses/by-nc-nd/2.0/",
"id": 3,
"name": "Attribution-NonCommercial-NoDerivs License"},
{"url": "http://creativecommons.org/licenses/by/2.0/",
"id": 4,
"name": "Attribution License"},
{"url": "http://creativecommons.org/licenses/by-sa/2.0/",
"id": 5,
"name": "Attribution-ShareAlike License"},
{"url": "http://creativecommons.org/licenses/by-nd/2.0/",
"id": 6,"name": "Attribution-NoDerivs License"},
...

1.4 annotations

基本的annotation如下,“segmentation”: RLE or [polygon]需要解释下。segmentation格式取决于这个实例是一个单个的对象(即iscrowd=0,将使用polygons格式)还是一组对象(即iscrowd=1,将使用RLE格式)。当三个人重叠时候,iscrowd=1,而旁边一个单独的人就是0。

annotation{
    "id": int,    
    "image_id": int,
    "category_id": int,
    "segmentation": RLE or [polygon],
    "area": float,
    "bbox": [x,y,width,height],
    "iscrowd": 0 or 1,
}

polygons中文多边形,而RLE是游程编码(run-length encoding)?官网对RLE的注释如下,那么大概翻译一下例子。given M=[0 0 1 1 1 0 1] the RLE counts would be [2 3 1 1], or for M=[1 1 1 1 1 1 0] the counts would be [0 6 1] (note that the odd counts are always the numbers of zeros). 大家注意,M开头是1,则编码后第一个是0,就这么简单,编码牛逼!

# RLE is a simple yet efficient format for storing binary masks. RLE
# first divides a vector (or vectorized image) into a series of piecewise
# constant regions and then for each piece simply stores the length of
# that piece. For example, given M=[0 0 1 1 1 0 1] the RLE counts would
# be [2 3 1 1], or for M=[1 1 1 1 1 1 0] the counts would be [0 6 1]
# (note that the odd counts are always the numbers of zeros). Instead of
# storing the counts directly, additional compression is achieved with a
# variable bitrate representation based on a common scheme called LEB128.

具体地:
ploygon:这是对于单个对象来说的,表示的是多边形轮廓的写x,y坐标,肯定是偶数,如果有n个数,表示有n/2个坐标

RLE:为了表示像素标注,可以用0,1表示,1表示有对象,然后利用RLE编码。

area是area of encoded masks,是标注区域的面积。如果是矩形框,那就是高乘宽,polygon或者RLE另算。

1.5 categories

上一章节知识点很多,消化了不少。categories就是cls的字段了。

{
    "id": int,
    "name": str,
    "supercategory": str,
}

举例:

{
	"supercategory": "person",
	"id": 1,
	"name": "person"
},
{
	"supercategory": "vehicle",
	"id": 2,
	"name": "bicycle"
},

Reference

  • https://zhuanlan.zhihu.com/p/29393415
  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
Windows下配置 maskrcnn-benchmark 环境需要遵循以下步骤: 1. 首先,确保计算机已安装好 Python3 和 CUDA。如果没有,请先安装这些依赖项。 2. 在命令行中使用 Git 命令克隆 maskrcnn-benchmark 仓库。可以使用以下命令: ``` git clone https://github.com/facebookresearch/maskrcnn-benchmark.git ``` 3. 进入克隆的仓库目录: ``` cd maskrcnn-benchmark ``` 4. 使用以下命令创建并激活 Python 虚拟环境: ``` python -m venv .env .env\Scripts\activate ``` 5. 安装 PyTorch。可以从 PyTorch 官方网站选择适合你的 CUDA 和操作系统的版本进行安装。例如,如果你的 CUDA 版本是 10.1,可以使用以下命令安装: ``` pip install torch==1.7.1 torchvision==0.8.2 torchaudio==0.7.2 -f https://download.pytorch.org/whl/cu101/torch_stable.html ``` 6. 安装依赖项。运行以下命令来安装所需的依赖项: ``` pip install -r requirements.txt ``` 7. 编译 maskrcnn_benchmark。运行以下命令完成编译: ``` python setup.py build develop ``` 8. 配置 COCO API(可选)。如果你想在 COCO 数据集上进行训练和评估,可以安装 COCO API。在命令行中运行以下命令: ``` pip install cython; pip install 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI' ``` 9. 最后,测试安装是否成功。可以运行以下命令执行一个简单的示例: ``` python demo/demo.py ``` 按照以上步骤配置 maskrcnn-benchmark 环境后,你将能够在 Windows 下使用该库进行目标检测和实例分割任务。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值