labelme使用教程

labelme使用教程

官方代码

0. 安装

pip install labelme

1. 运行

demo

labelme img_dir --nodata --autosave --output output_dir

运行上面的命令会弹出labelme的标注界面,标注完成之后会在output_dir目录下生成json文件,生成的文件如下.

其中的一些key的含义:

  • label:类别名称
  • points:[[x1,y1],[x2,y2],…] 图像左上角为坐标原点
  • shape_type
    • rectangle:矩形框标注
    • polygon:多边形框标注
{
  "version": "5.0.1",
  "flags": {},
  "shapes": [
    {
      "label": "window",
      "points": [
        [
          618.8,
          279.2
        ],
        [
          1278.0,
          716.8
        ]
      ],
      "group_id": null,
      "shape_type": "rectangle",
      "flags": {}
    },
    {
      "label": "window",
      "points": [
        [
          678.8,
          347.2
        ],
        [
          707.6,
          700.8
        ],
        [
          1266.0,
          652.0
        ],
        [
          1205.2,
          288.0
        ]
      ],
      "group_id": null,
      "shape_type": "polygon",
      "flags": {}
    }
  ],
  "imagePath": "0.jpg",
  "imageData": null,
  "imageHeight": 720,
  "imageWidth": 1280
}

标注视频

需要先将视频帧转换成图像帧,然后运行下面的命令对生成的图像文件夹进行标注

labelme img_dir --nodata --keep-prev --autosave -o output_dir

其中--keep-prev参数会将上一帧的标注保存到当前帧

labelme D:\DataSet\img\left_fish --nodata --keep-prev --autosave -o D:\DataSet\img\left_fish_label

语义分割

./labelme2voc.py data_annotated data_dataset_voc --labels labels.txt

其中,

  • labelme2voc是官方的转换文件
  • data_annotated是你标注得到的json文件路径
  • data_dataset_voc是输出的文件目录
  • label.txt是标注信息

data_dataset_voc的目录结构如下:

data_dataset_voc
├── JPEGImages
├── SegmentationClass
├── SegmentationClassVisualization

2. 命令行参数

positional arguments:
  filename              image or label filename

optional arguments:
  -h, --help            show this help message and exit
  --version, -V         show version
  --reset-config        reset qt config
  --logger-level {debug,info,warning,fatal,error}
                        logger level
  --output OUTPUT, -O OUTPUT, -o OUTPUT
                        output file or directory (if it ends with .json it is recognized as file, else as directory)
  --config CONFIG       config file or yaml-format string (default: C:\Users\Lenovo\.labelmerc)
  --nodata              stop storing image data to JSON file
  --autosave            auto save
  --nosortlabels        stop sorting labels
  --flags FLAGS         comma separated list of flags OR file containing flags
  --labelflags LABEL_FLAGS
                        yaml string of label specific flags OR file containing json string of label specific flags
                        (ex. {person-\d+: [male, tall], dog-\d+: [black, brown, white], .*: [occluded]})
  --labels LABELS       comma separated list of labels OR file containing labels
  --validatelabel {exact}
                        label validation types
  --keep-prev           keep annotation of previous frame
  --epsilon EPSILON     epsilon to find nearest vertex on canvas

3. labelme2voc.py

可以将标注生成的json文件生成voc格式的语义mask,可以通过运行一下命令来使用。

./labelme2voc.py data_annotated data_dataset_voc --labels labels.txt
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值