提交 d07baccd 编写于 作者: L LaraStuStu

Merge branch 'master' of https://github.com/PaddlePaddle/PaddleX

无法预览此类型文件
### 数据标注
在DataAnnotation模块下,我们依赖LabeMe标注工具,同时提供了数据处理脚本,帮助用户快速准备训练目标检测和语义分割任务所需的数据。
您可以使用LabeMe标注工具对您的数据进行标注,同时提供了数据处理脚本,帮助用户快速准备训练目标检测和语义分割任务所需的数据。
### LabelMe
LabelMe是目前广泛使用的数据标注工具,并且在GitHub上开源给用户使用。
......
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 30
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 7
# Issues with these labels will never be considered stale
exemptLabels:
- bug
# Label to use when marking an issue as stale
staleLabel: stale
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
# Comment to post when removing the stale label. Set to `false` to disable
unmarkComment: false
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: >
This issue is closed as announced. Feel free to re-open it if needed.
/.cache/
/.pytest_cache/
/build/
/dist/
/*.egg-info/
*.py[cdo]
.DS_Store
[submodule "github2pypi"]
path = github2pypi
url = https://github.com/wkentaro/github2pypi.git
language: generic
cache:
- pip
sudo: required
dist: trusty
branches:
only:
- master
- /v\d+\.\d+.\d+/
notifications:
email: false
env:
global:
# used by ci-helpers
- SETUP_XVFB=true
- PIP_DEPENDENCIES='hacking pytest pytest-qt'
- MPLBACKEND=TkAgg # for osx
matrix:
include:
- os: osx
env:
- PYTEST_QT_API=pyqt5
- PYQT_PACKAGE='pyqt=5'
- PYTHON_VERSION=3.6
- RUN_PYINSTALLER=true
- os: linux
dist: trusty
env:
- PYTEST_QT_API=pyqt4v2
- PYQT_PACKAGE='pyqt=4'
- PYTHON_VERSION=2.7
- os: linux
dist: trusty
env:
- PYTEST_QT_API=pyside2
- CONDA_CHANNELS='conda-forge'
- PYQT_PACKAGE='pyside2!=5.12.4'
- PYTHON_VERSION=2.7
- os: linux
dist: trusty
env:
- PYTEST_QT_API=pyside2
- CONDA_CHANNELS='conda-forge'
- PYQT_PACKAGE='pyside2'
- PYTHON_VERSION=3.6
- os: linux
dist: trusty
env:
- PYTEST_QT_API=pyqt5
- PYQT_PACKAGE='pyqt=5'
- PYTHON_VERSION=2.7
- os: linux
dist: trusty
env:
- PYTEST_QT_API=pyqt5
- PYQT_PACKAGE='pyqt=5'
- PYTHON_VERSION=3.6
- RUN_PYINSTALLER=true
install:
# Setup X
- |
if [ $TRAVIS_OS_NAME = "linux" ]; then
sudo apt-get update
# Xvfb / window manager
sudo apt-get install -y xvfb herbstluftwm
elif [ $TRAVIS_OS_NAME = "osx" ]; then
brew cask install xquartz
fi
# Setup miniconda
- git clone --depth 1 git://github.com/astropy/ci-helpers.git
- CONDA_DEPENDENCIES=$PYQT_PACKAGE source ci-helpers/travis/setup_conda.sh
- source activate test && export LD_LIBRARY_PATH=$CONDA_PREFIX/lib:$LD_LIBRARY_PATH
- pip install .
- rm -rf ci-helpers miniconda.sh
before_script:
- if [ $TRAVIS_OS_NAME = "linux" ]; then (herbstluftwm )& fi
- if [ $TRAVIS_OS_NAME = "osx" ]; then (sudo Xvfb :99 -ac -screen 0 1024x768x8 )& fi
- sleep 1
script:
# Run flake8
- flake8 examples labelme setup.py tests
# Run help2man
- conda install -y help2man
# Run pytest
- pytest -v tests
- labelme --help
- labelme --version
# Run examples
- (cd examples/primitives && labelme_json_to_dataset primitives.json && rm -rf primitives_json)
- (cd examples/tutorial && rm -rf apc2016_obj3_json && labelme_json_to_dataset apc2016_obj3.json && python load_label_png.py && git checkout -- .)
- (cd examples/semantic_segmentation && rm -rf data_dataset_voc && ./labelme2voc.py data_annotated data_dataset_voc --labels labels.txt && git checkout -- .)
- (cd examples/instance_segmentation && rm -rf data_dataset_voc && ./labelme2voc.py data_annotated data_dataset_voc --labels labels.txt && git checkout -- .)
- (cd examples/video_annotation && rm -rf data_dataset_voc && ./labelme2voc.py data_annotated data_dataset_voc --labels labels.txt && git checkout -- .)
- pip install lxml # for bbox_detection/labelme2voc.py
- (cd examples/bbox_detection && rm -rf data_dataset_voc && ./labelme2voc.py data_annotated data_dataset_voc --labels labels.txt && git checkout -- .)
- pip install cython && pip install pycocotools # for instance_segmentation/labelme2coco.py
- (cd examples/instance_segmentation && rm -rf data_dataset_coco && ./labelme2coco.py data_annotated data_dataset_coco --labels labels.txt && git checkout -- .)
# Run pyinstaller
- |
if [ "$RUN_PYINSTALLER" = "true" ]; then
# Cleanup
pip uninstall -y $PIP_DEPENDENCIES
# https://github.com/wkentaro/labelme/issues/183
if [ $TRAVIS_OS_NAME = "osx" ]; then
pip uninstall -y Pillow
conda install -y Pillow
fi
# Build the standalone executable
pip install 'pyinstaller!=3.4' # 3.4 raises error
# numpy 1.17 raises error
# See https://github.com/wkentaro/labelme/issues/465
pip install 'numpy<1.17'
pyinstaller labelme.spec
dist/labelme --version
fi
after_script:
- true # noop
Copyright (C) 2016-2018 Kentaro Wada.
Copyright (C) 2011 Michael Pitidis, Hussein Abdulwahid.
Labelme is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Labelme is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Labelme. If not, see <http://www.gnu.org/licenses/>.
<h1 align="center">
<img src="labelme/icons/icon.png"><br/>labelme
</h1>
<h4 align="center">
Image Polygonal Annotation with Python
</h4>
<div align="center">
<a href="https://pypi.python.org/pypi/labelme"><img src="https://img.shields.io/pypi/v/labelme.svg"></a>
<a href="https://pypi.org/project/labelme"><img src="https://img.shields.io/pypi/pyversions/labelme.svg"></a>
<a href="https://travis-ci.org/wkentaro/labelme"><img src="https://travis-ci.org/wkentaro/labelme.svg?branch=master"></a>
<a href="https://hub.docker.com/r/wkentaro/labelme"><img src="https://img.shields.io/docker/build/wkentaro/labelme.svg"></a>
</div>
<br/>
<div align="center">
<img src="examples/instance_segmentation/.readme/annotation.jpg" width="70%">
</div>
## Description
Labelme is a graphical image annotation tool inspired by <http://labelme.csail.mit.edu>.
It is written in Python and uses Qt for its graphical interface.
<img src="examples/instance_segmentation/data_dataset_voc/JPEGImages/2011_000006.jpg" width="19%" /> <img src="examples/instance_segmentation/data_dataset_voc/SegmentationClassPNG/2011_000006.png" width="19%" /> <img src="examples/instance_segmentation/data_dataset_voc/SegmentationClassVisualization/2011_000006.jpg" width="19%" /> <img src="examples/instance_segmentation/data_dataset_voc/SegmentationObjectPNG/2011_000006.png" width="19%" /> <img src="examples/instance_segmentation/data_dataset_voc/SegmentationObjectVisualization/2011_000006.jpg" width="19%" />
<i>VOC dataset example of instance segmentation.</i>
<img src="examples/semantic_segmentation/.readme/annotation.jpg" width="32%" /> <img src="examples/bbox_detection/.readme/annotation.jpg" width="30%" /> <img src="examples/classification/.readme/annotation_cat.jpg" width="35%" />
<i>Other examples (semantic segmentation, bbox detection, and classification).</i>
<img src="https://user-images.githubusercontent.com/4310419/47907116-85667800-de82-11e8-83d0-b9f4eb33268f.gif" width="30%" /> <img src="https://user-images.githubusercontent.com/4310419/47922172-57972880-deae-11e8-84f8-e4324a7c856a.gif" width="30%" /> <img src="https://user-images.githubusercontent.com/14256482/46932075-92145f00-d080-11e8-8d09-2162070ae57c.png" width="32%" />
<i>Various primitives (polygon, rectangle, circle, line, and point).</i>
## Features
- [x] Image annotation for polygon, rectangle, circle, line and point. ([tutorial](examples/tutorial))
- [x] Image flag annotation for classification and cleaning. ([#166](https://github.com/wkentaro/labelme/pull/166))
- [x] Video annotation. ([video annotation](examples/video_annotation))
- [x] GUI customization (predefined labels / flags, auto-saving, label validation, etc). ([#144](https://github.com/wkentaro/labelme/pull/144))
- [x] Exporting VOC-format dataset for semantic/instance segmentation. ([semantic segmentation](examples/semantic_segmentation), [instance segmentation](examples/instance_segmentation))
- [x] Exporting COCO-format dataset for instance segmentation. ([instance segmentation](examples/instance_segmentation))
## Requirements
- Ubuntu / macOS / Windows
- Python2 / Python3
- [PyQt4 / PyQt5](http://www.riverbankcomputing.co.uk/software/pyqt/intro) / [PySide2](https://wiki.qt.io/PySide2_GettingStarted)
## Installation
There are options:
- Platform agonistic installation: [Anaconda](#anaconda), [Docker](#docker)
- Platform specific installation: [Ubuntu](#ubuntu), [macOS](#macos), [Windows](#windows)
### Anaconda
You need install [Anaconda](https://www.continuum.io/downloads), then run below:
```bash
# python2
conda create --name=labelme python=2.7
source activate labelme
# conda install -c conda-forge pyside2
conda install pyqt
pip install labelme
# if you'd like to use the latest version. run below:
# pip install git+https://github.com/wkentaro/labelme.git
# python3
conda create --name=labelme python=3.6
source activate labelme
# conda install -c conda-forge pyside2
# conda install pyqt
pip install pyqt5 # pyqt5 can be installed via pip on python3
pip install labelme
```
### Docker
You need install [docker](https://www.docker.com), then run below:
```bash
wget https://raw.githubusercontent.com/wkentaro/labelme/master/labelme/cli/on_docker.py -O labelme_on_docker
chmod u+x labelme_on_docker
# Maybe you need http://sourabhbajaj.com/blog/2017/02/07/gui-applications-docker-mac/ on macOS
./labelme_on_docker examples/tutorial/apc2016_obj3.jpg -O examples/tutorial/apc2016_obj3.json
./labelme_on_docker examples/semantic_segmentation/data_annotated
```
### Ubuntu
```bash
# Ubuntu 14.04 / Ubuntu 16.04
# Python2
# sudo apt-get install python-qt4 # PyQt4
sudo apt-get install python-pyqt5 # PyQt5
sudo pip install labelme
# Python3
sudo apt-get install python3-pyqt5 # PyQt5
sudo pip3 install labelme
```
### Ubuntu 19.10+ / Debian (sid)
```bash
sudo apt-get install labelme
```
### macOS
```bash
# macOS Sierra
brew install pyqt # maybe pyqt5
pip install labelme # both python2/3 should work
# or install standalone executable / app
# NOTE: this only installs the `labelme` command
brew install wkentaro/labelme/labelme
brew cask install wkentaro/labelme/labelme
```
### Windows
Firstly, follow instruction in [Anaconda](#anaconda).
```bash
# Pillow 5 causes dll load error on Windows.
# https://github.com/wkentaro/labelme/pull/174
conda install pillow=4.0.0
```
## Usage
Run `labelme --help` for detail.
The annotations are saved as a [JSON](http://www.json.org/) file.
```bash
labelme # just open gui
# tutorial (single image example)
cd examples/tutorial
labelme apc2016_obj3.jpg # specify image file
labelme apc2016_obj3.jpg -O apc2016_obj3.json # close window after the save
labelme apc2016_obj3.jpg --nodata # not include image data but relative image path in JSON file
labelme apc2016_obj3.jpg \
--labels highland_6539_self_stick_notes,mead_index_cards,kong_air_dog_squeakair_tennis_ball # specify label list
# semantic segmentation example
cd examples/semantic_segmentation
labelme data_annotated/ # Open directory to annotate all images in it
labelme data_annotated/ --labels labels.txt # specify label list with a file
```
For more advanced usage, please refer to the examples:
* [Tutorial (Single Image Example)](examples/tutorial)
* [Semantic Segmentation Example](examples/semantic_segmentation)
* [Instance Segmentation Example](examples/instance_segmentation)
* [Video Annotation Example](examples/video_annotation)
### Command Line Arguemnts
- `--output` specifies the location that annotations will be written to. If the location ends with .json, a single annotation will be written to this file. Only one image can be annotated if a location is specified with .json. If the location does not end with .json, the program will assume it is a directory. Annotations will be stored in this directory with a name that corresponds to the image that the annotation was made on.
- The first time you run labelme, it will create a config file in `~/.labelmerc`. You can edit this file and the changes will be applied the next time that you launch labelme. If you would prefer to use a config file from another location, you can specify this file with the `--config` flag.
- Without the `--nosortlabels` flag, the program will list labels in alphabetical order. When the program is run with this flag, it will display labels in the order that they are provided.
- Flags are assigned to an entire image. [Example](examples/classification)
- Labels are assigned to a single polygon. [Example](examples/bbox_detection)
## FAQ
- **How to convert JSON file to numpy array?** See [examples/tutorial](examples/tutorial#convert-to-dataset).
- **How to load label PNG file?** See [examples/tutorial](examples/tutorial#how-to-load-label-png-file).
- **How to get annotations for semantic segmentation?** See [examples/semantic_segmentation](examples/semantic_segmentation).
- **How to get annotations for instance segmentation?** See [examples/instance_segmentation](examples/instance_segmentation).
## Testing
```bash
pip install hacking pytest pytest-qt
flake8 .
pytest -v tests
```
## Developing
```bash
git clone https://github.com/wkentaro/labelme.git
cd labelme
# Install anaconda3 and labelme
curl -L https://github.com/wkentaro/dotfiles/raw/master/local/bin/install_anaconda3.sh | bash -s .
source .anaconda3/bin/activate
pip install -e .
```
## How to build standalone executable
Below shows how to build the standalone executable on macOS, Linux and Windows.
Also, there are pre-built executables in
[the release section](https://github.com/wkentaro/labelme/releases).
```bash
# Setup conda
conda create --name labelme python==3.6.0
conda activate labelme
# Build the standalone executable
pip install .
pip install pyinstaller
pyinstaller labelme.spec
dist/labelme --version
```
## Acknowledgement
This repo is the fork of [mpitid/pylabelme](https://github.com/mpitid/pylabelme),
whose development has already stopped.
## Cite This Project
If you use this project in your research or wish to refer to the baseline results published in the README, please use the following BibTeX entry.
```bash
@misc{labelme2016,
author = {Ketaro Wada},
title = {{labelme: Image Polygonal Annotation with Python}},
howpublished = {\url{https://github.com/wkentaro/labelme}},
year = {2016}
}
```
FROM ubuntu:xenial
# http://fabiorehm.com/blog/2014/09/11/running-gui-apps-with-docker/
RUN export uid=1000 gid=1000 && \
mkdir -p /home/developer && \
echo "developer:x:${uid}:${gid}:Developer,,,:/home/developer:/bin/bash" >> /etc/passwd && \
echo "developer:x:${uid}:" >> /etc/group && \
mkdir -p /etc/sudoers.d && \
echo "developer ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/developer && \
chmod 0440 /etc/sudoers.d/developer && \
chown ${uid}:${gid} -R /home/developer
RUN \
apt-get update -qq && \
apt-get upgrade -qq -y && \
apt-get install -qq -y \
# requirements
git \
python3 \
python3-pip \
python3-matplotlib \
python3-pyqt5 \
# utilities
sudo
RUN pip3 install -v git+https://github.com/wkentaro/labelme.git
USER developer
ENV HOME /home/developer
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.8.
.TH LABELME "1" "August 2019" "labelme 3.16.3" "User Commands"
.SH NAME
labelme \- manual page for labelme 3.16.3
.SH DESCRIPTION
usage: labelme [\-h] [\-\-version] [\-\-reset\-config]
.IP
[\-\-logger\-level {debug,info,warning,fatal,error}]
[\-\-output OUTPUT] [\-\-config CONFIG_FILE] [\-\-nodata]
[\-\-autosave] [\-\-nosortlabels] [\-\-flags FLAGS]
[\-\-labelflags LABEL_FLAGS] [\-\-labels LABELS]
[\-\-validatelabel {exact,instance}] [\-\-keep\-prev]
[\-\-epsilon EPSILON]
[filename]
.SS "positional arguments:"
.TP
filename
image or label filename
.SS "optional arguments:"
.TP
\fB\-h\fR, \fB\-\-help\fR
show this help message and exit
.TP
\fB\-\-version\fR, \fB\-V\fR
show version
.TP
\fB\-\-reset\-config\fR
reset qt config
.TP
\fB\-\-logger\-level\fR {debug,info,warning,fatal,error}
logger level
.TP
\fB\-\-output\fR OUTPUT, \fB\-O\fR OUTPUT, \fB\-o\fR OUTPUT
output file or directory (if it ends with .json it is
recognized as file, else as directory)
.TP
\fB\-\-config\fR CONFIG_FILE
config file (default: /home/wkentaro/.labelmerc)
.TP
\fB\-\-nodata\fR
stop storing image data to JSON file
.TP
\fB\-\-autosave\fR
auto save
.TP
\fB\-\-nosortlabels\fR
stop sorting labels
.TP
\fB\-\-flags\fR FLAGS
comma separated list of flags OR file containing flags
.TP
\fB\-\-labelflags\fR LABEL_FLAGS
yaml string of label specific flags OR file containing
json string of label specific flags (ex. {person\-\ed+:
[male, tall], dog\-\ed+: [black, brown, white], .*:
[occluded]})
.TP
\fB\-\-labels\fR LABELS
comma separated list of labels OR file containing
labels
.TP
\fB\-\-validatelabel\fR {exact,instance}
label validation types
.TP
\fB\-\-keep\-prev\fR
keep annotation of previous frame
.TP
\fB\-\-epsilon\fR EPSILON
epsilon to find nearest vertex on canvas
.SH "SEE ALSO"
The full documentation for
.B labelme
is maintained as a Texinfo manual. If the
.B info
and
.B labelme
programs are properly installed at your site, the command
.IP
.B info labelme
.PP
should give you access to the complete manual.
# Bounding Box Detection Example
## Usage
```bash
labelme data_annotated --labels labels.txt --nodata --autosave
```
![](.readme/annotation.jpg)
## Convert to VOC-format Dataset
```bash
# It generates:
# - data_dataset_voc/JPEGImages
# - data_dataset_voc/Annotations
# - data_dataset_voc/AnnotationsVisualization
./labelme2voc.py data_annotated data_dataset_voc --labels labels.txt
```
<img src="data_dataset_voc/JPEGImages/2011_000003.jpg" width="33%" /> <img src="data_dataset_voc/AnnotationsVisualization/2011_000003.jpg" width="33%" />
<i>Fig1. JPEG image (left), Bounding box annotation visualization (right).</i>
{
"flags": {},
"shapes": [
{
"label": "person",
"line_color": null,
"fill_color": null,
"points": [
[
191,
107
],
[
313,
329
]
],
"shape_type": "rectangle"
},
{
"label": "person",
"line_color": null,
"fill_color": null,
"points": [
[
365,
83
],
[
500,
333
]
],
"shape_type": "rectangle"
}
],
"lineColor": [
0,
255,
0,
128
],
"fillColor": [
255,
0,
0,
128
],
"imagePath": "2011_000003.jpg",
"imageData": null
}
\ No newline at end of file
{
"flags": {},
"shapes": [
{
"label": "person",
"line_color": null,
"fill_color": null,
"points": [
[
91,
107
],
[
240,
330
]
],
"shape_type": "rectangle"
},
{
"label": "person",
"line_color": null,
"fill_color": null,
"points": [
[
178,
110
],
[
298,
282
]
],
"shape_type": "rectangle"
},
{
"label": "person",
"line_color": null,
"fill_color": null,
"points": [
[
254,
115
],
[
369,
292
]
],
"shape_type": "rectangle"
},
{
"label": "person",
"line_color": null,
"fill_color": null,
"points": [
[
395,
81
],
[
447,
117
]
],
"shape_type": "rectangle"
}
],
"lineColor": [
0,
255,
0,
128
],
"fillColor": [
255,
0,
0,
128
],
"imagePath": "2011_000006.jpg",
"imageData": null
}
\ No newline at end of file
{
"flags": {},
"shapes": [
{
"label": "bus",
"line_color": null,
"fill_color": null,
"points": [
[
84,
20
],
[
435,
373
]
],
"shape_type": "rectangle"
},
{
"label": "bus",
"line_color": null,
"fill_color": null,
"points": [
[
1,
99
],
[
107,
282
]
],
"shape_type": "rectangle"
},
{
"label": "car",
"line_color": null,
"fill_color": null,
"points": [
[
409,
167
],
[
500,
266
]
],
"shape_type": "rectangle"
}
],
"lineColor": [
0,
255,
0,
128
],
"fillColor": [
255,
0,
0,
128
],
"imagePath": "2011_000025.jpg",
"imageData": null
}
\ No newline at end of file
<annotation>
<folder/>
<filename>2011_000003.jpg</filename>
<database/>
<annotation/>
<image/>
<size>
<height>338</height>
<width>500</width>
<depth>3</depth>
</size>
<segmented/>
<object>
<name>person</name>
<pose/>
<truncated/>
<difficult/>
<bndbox>
<xmin>191</xmin>
<ymin>107</ymin>
<xmax>313</xmax>
<ymax>329</ymax>
</bndbox>
</object>
<object>
<name>person</name>
<pose/>
<truncated/>
<difficult/>
<bndbox>
<xmin>365</xmin>
<ymin>83</ymin>
<xmax>500</xmax>
<ymax>333</ymax>
</bndbox>
</object>
</annotation>
<annotation>
<folder/>
<filename>2011_000006.jpg</filename>
<database/>
<annotation/>
<image/>
<size>
<height>375</height>
<width>500</width>
<depth>3</depth>
</size>
<segmented/>
<object>
<name>person</name>
<pose/>
<truncated/>
<difficult/>
<bndbox>
<xmin>91</xmin>
<ymin>107</ymin>
<xmax>240</xmax>
<ymax>330</ymax>
</bndbox>
</object>
<object>
<name>person</name>
<pose/>
<truncated/>
<difficult/>
<bndbox>
<xmin>178</xmin>
<ymin>110</ymin>
<xmax>298</xmax>
<ymax>282</ymax>
</bndbox>
</object>
<object>
<name>person</name>
<pose/>
<truncated/>
<difficult/>
<bndbox>
<xmin>254</xmin>
<ymin>115</ymin>
<xmax>369</xmax>
<ymax>292</ymax>
</bndbox>
</object>
<object>
<name>person</name>
<pose/>
<truncated/>
<difficult/>
<bndbox>
<xmin>395</xmin>
<ymin>81</ymin>
<xmax>447</xmax>
<ymax>117</ymax>
</bndbox>
</object>
</annotation>
<annotation>
<folder/>
<filename>2011_000025.jpg</filename>
<database/>
<annotation/>
<image/>
<size>
<height>375</height>
<width>500</width>
<depth>3</depth>
</size>
<segmented/>
<object>
<name>bus</name>
<pose/>
<truncated/>
<difficult/>
<bndbox>
<xmin>84</xmin>
<ymin>20</ymin>
<xmax>435</xmax>
<ymax>373</ymax>
</bndbox>
</object>
<object>
<name>bus</name>
<pose/>
<truncated/>
<difficult/>
<bndbox>
<xmin>1</xmin>
<ymin>99</ymin>
<xmax>107</xmax>
<ymax>282</ymax>
</bndbox>
</object>
<object>
<name>car</name>
<pose/>
<truncated/>
<difficult/>
<bndbox>
<xmin>409</xmin>
<ymin>167</ymin>
<xmax>500</xmax>
<ymax>266</ymax>
</bndbox>
</object>
</annotation>
_background_
aeroplane
bicycle
bird
boat
bottle
bus
car
cat
chair
cow
diningtable
dog
horse
motorbike
person
potted plant
sheep
sofa
train
tv/monitor
\ No newline at end of file
#!/usr/bin/env python
from __future__ import print_function
import argparse
import glob
import json
import os
import os.path as osp
import sys
try:
import lxml.builder
import lxml.etree
except ImportError:
print('Please install lxml:\n\n pip install lxml\n')
sys.exit(1)
import numpy as np
import PIL.Image
import labelme
def main():
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter
)
parser.add_argument('input_dir', help='input annotated directory')
parser.add_argument('output_dir', help='output dataset directory')
parser.add_argument('--labels', help='labels file', required=True)
args = parser.parse_args()
if osp.exists(args.output_dir):
print('Output directory already exists:', args.output_dir)
sys.exit(1)
os.makedirs(args.output_dir)
os.makedirs(osp.join(args.output_dir, 'JPEGImages'))
os.makedirs(osp.join(args.output_dir, 'Annotations'))
os.makedirs(osp.join(args.output_dir, 'AnnotationsVisualization'))
print('Creating dataset:', args.output_dir)
class_names = []
class_name_to_id = {}
for i, line in enumerate(open(args.labels).readlines()):
class_id = i - 1 # starts with -1
class_name = line.strip()
class_name_to_id[class_name] = class_id
if class_id == -1:
assert class_name == '__ignore__'
continue
elif class_id == 0:
assert class_name == '_background_'
class_names.append(class_name)
class_names = tuple(class_names)
print('class_names:', class_names)
out_class_names_file = osp.join(args.output_dir, 'class_names.txt')
with open(out_class_names_file, 'w') as f:
f.writelines('\n'.join(class_names))
print('Saved class_names:', out_class_names_file)
for label_file in glob.glob(osp.join(args.input_dir, '*.json')):
print('Generating dataset from:', label_file)
with open(label_file) as f:
data = json.load(f)
base = osp.splitext(osp.basename(label_file))[0]
out_img_file = osp.join(
args.output_dir, 'JPEGImages', base + '.jpg')
out_xml_file = osp.join(
args.output_dir, 'Annotations', base + '.xml')
out_viz_file = osp.join(
args.output_dir, 'AnnotationsVisualization', base + '.jpg')
img_file = osp.join(osp.dirname(label_file), data['imagePath'])
img = np.asarray(PIL.Image.open(img_file))
PIL.Image.fromarray(img).save(out_img_file)
maker = lxml.builder.ElementMaker()
xml = maker.annotation(
maker.folder(),
maker.filename(base + '.jpg'),
maker.database(), # e.g., The VOC2007 Database
maker.annotation(), # e.g., Pascal VOC2007
maker.image(), # e.g., flickr
maker.size(
maker.height(str(img.shape[0])),
maker.width(str(img.shape[1])),
maker.depth(str(img.shape[2])),
),
maker.segmented(),
)
bboxes = []
labels = []
for shape in data['shapes']:
if shape['shape_type'] != 'rectangle':
print('Skipping shape: label={label}, shape_type={shape_type}'
.format(**shape))
continue
class_name = shape['label']
class_id = class_names.index(class_name)
(xmin, ymin), (xmax, ymax) = shape['points']
bboxes.append([xmin, ymin, xmax, ymax])
labels.append(class_id)
xml.append(
maker.object(
maker.name(shape['label']),
maker.pose(),
maker.truncated(),
maker.difficult(),
maker.bndbox(
maker.xmin(str(xmin)),
maker.ymin(str(ymin)),
maker.xmax(str(xmax)),
maker.ymax(str(ymax)),
),
)
)
captions = [class_names[l] for l in labels]
viz = labelme.utils.draw_instances(
img, bboxes, labels, captions=captions
)
PIL.Image.fromarray(viz).save(out_viz_file)
with open(out_xml_file, 'wb') as f:
f.write(lxml.etree.tostring(xml, pretty_print=True))
if __name__ == '__main__':
main()
__ignore__
_background_
aeroplane
bicycle
bird
boat
bottle
bus
car
cat
chair
cow
diningtable
dog
horse
motorbike
person
potted plant
sheep
sofa
train
tv/monitor
\ No newline at end of file
# Classification Example
## Usage
```bash
labelme data_annotated --flags flags.txt --nodata
```
<img src=".readme/annotation_cat.jpg" width="100%" />
<img src=".readme/annotation_dog.jpg" width="100%" />
{
"flags": {
"__ignore__": false,
"cat": true,
"dog": false
},
"shapes": [],
"lineColor": [
0,
255,
0,
128
],
"fillColor": [
255,
0,
0,
128
],
"imagePath": "0001.jpg",
"imageData": null
}
\ No newline at end of file
{
"flags": {
"__ignore__": false,
"cat": false,
"dog": true
},
"shapes": [],
"lineColor": [
0,
255,
0,
128
],
"fillColor": [
255,
0,
0,
128
],
"imagePath": "0002.jpg",
"imageData": null
}
\ No newline at end of file
# Instance Segmentation Example
## Annotation
```bash
labelme data_annotated --labels labels.txt --nodata
labelme data_annotated --labels labels.txt --nodata --labelflags '{.*: [occluded, truncated], person-\d+: [male]}'
```
![](.readme/annotation.jpg)
## Convert to VOC-format Dataset
```bash
# It generates:
# - data_dataset_voc/JPEGImages
# - data_dataset_voc/SegmentationClass
# - data_dataset_voc/SegmentationClassVisualization
# - data_dataset_voc/SegmentationObject
# - data_dataset_voc/SegmentationObjectVisualization
./labelme2voc.py data_annotated data_dataset_voc --labels labels.txt
```
<img src="data_dataset_voc/JPEGImages/2011_000003.jpg" width="33%" /> <img src="data_dataset_voc/SegmentationClassVisualization/2011_000003.jpg" width="33%" /> <img src="data_dataset_voc/SegmentationObjectVisualization/2011_000003.jpg" width="33%" />
Fig 1. JPEG image (left), JPEG class label visualization (center), JPEG instance label visualization (right)
Note that the label file contains only very low label values (ex. `0, 4, 14`), and
`255` indicates the `__ignore__` label value (`-1` in the npy file).
You can see the label PNG file by following.
```bash
labelme_draw_label_png data_dataset_voc/SegmentationClassPNG/2011_000003.png # left
labelme_draw_label_png data_dataset_voc/SegmentationObjectPNG/2011_000003.png # right
```
<img src=".readme/draw_label_png_class.jpg" width="33%" /> <img src=".readme/draw_label_png_object.jpg" width="33%" />
## Convert to COCO-format Dataset
```bash
# It generates:
# - data_dataset_coco/JPEGImages
# - data_dataset_coco/annotations.json
./labelme2coco.py data_annotated data_dataset_coco --labels labels.txt
```
{
"version": "3.14.2",
"flags": {},
"shapes": [
{
"label": "person-1",
"line_color": null,
"fill_color": null,
"points": [
[
250.984126984127,
106.92063492063491
],
[
229.984126984127,
118.92063492063491
],
[
221.984126984127,
134.9206349206349
],
[
223.984126984127,
147.9206349206349
],
[
217.984126984127,
160.9206349206349
],
[
202.984126984127,
167.9206349206349
],
[
192.984126984127,
199.9206349206349
],
[
194.984126984127,
221.9206349206349
],
[
199.984126984127,
226.9206349206349
],
[
191.984126984127,
233.9206349206349
],
[
197.984126984127,
263.92063492063494
],
[
213.984126984127,
294.92063492063494
],
[
214.984126984127,
319.92063492063494
],
[
221.984126984127,
326.92063492063494
],
[
235.984126984127,
325.92063492063494
],
[
240.984126984127,
322.92063492063494
],
[
235.984126984127,
297.92063492063494
],
[
238.984126984127,
286.92063492063494
],
[
234.984126984127,
267.92063492063494
],
[
257.984126984127,
257.92063492063494
],
[
264.984126984127,
263.92063492063494
],
[
256.984126984127,
272.92063492063494
],
[
259.984126984127,
281.92063492063494
],
[
284.984126984127,
287.92063492063494
],
[
297.984126984127,
277.92063492063494
],
[
288.984126984127,
269.92063492063494
],
[
281.984126984127,
269.92063492063494
],
[
283.984126984127,
263.92063492063494
],
[
292.984126984127,
260.92063492063494
],
[
308.984126984127,
235.9206349206349
],
[
313.984126984127,
216.9206349206349
],
[
309.984126984127,
207.9206349206349
],
[
312.984126984127,
201.9206349206349
],
[
308.984126984127,
184.9206349206349
],
[
291.984126984127,
172.9206349206349
],
[
269.984126984127,
158.9206349206349
],
[
261.984126984127,
153.9206349206349
],
[
264.984126984127,
141.9206349206349
],
[
273.984126984127,
136.9206349206349
],
[
278.984126984127,
129.9206349206349
],
[
270.984126984127,
120.92063492063491
]
],
"shape_type": "polygon",
"flags": {
"occluded": true,
"truncated": false,
"male": true
}
},
{
"label": "person-2",
"line_color": null,
"fill_color": null,
"points": [
[
482,
85
],
[
468,
90
],
[
460,
110
],
[
460,
127
],
[
444,
137
],
[
419,
153
],
[
410,
163
],
[
403,
168
],
[
394,
170
],
[
386,
168
],
[
386,
184
],
[
392,
182
],
[
410,
187
],
[
414,
192
],
[
437,
189
],
[
434,
204
],
[
390,
195
],
[
386,
195
],
[
387,
208
],
[
381,
212
],
[
372,
212
],
[
372,
216
],
[
400,
270
],
[
389,
272
],
[
389,
274
],
[
403,
282
],
[
444,
283
],
[
443,
259
],
[
426,
244
],
[
462,
256
],
[
474,
270
],
[
477,
280
],
[
473,
289
],
[
471,
296
],
[
472,
317
],
[
480,
332
],
[
494,
335
],
[
498,
329
],
[
494,
308
],
[
499,
297
],
[
499,
90
]
],
"shape_type": "polygon",
"flags": {
"occluded": true,
"truncated": true,
"male": true
}
},
{
"label": "bottle",
"line_color": null,
"fill_color": null,
"points": [
[
374,
159
],
[
369,
170
],
[
369,
210
],
[
375,
212
],
[
387,
209
],
[
385,
185
],
[
385,
168
],
[
385,
165
],
[
382,
159
]
],
"shape_type": "polygon",
"flags": {
"occluded": false,
"truncated": false
}
},
{
"label": "person-2",
"line_color": null,
"fill_color": null,
"points": [
[
370,
170
],
[
366,
173
],
[
365,
182
],
[
368,
185
]
],
"shape_type": "polygon",
"flags": {
"occluded": true,
"truncated": false,
"male": false
}
},
{
"label": "__ignore__",
"line_color": null,
"fill_color": null,
"points": [
[
338,
266
],
[
313,
269
],
[
297,
277
],
[
282,
288
],
[
273,
302
],
[
272,
320
],
[
279,
337
],
[
428,
337
],
[
432,
316
],
[
423,
296
],
[
403,
283
],
[
370,
270
]
],
"shape_type": "polygon",
"flags": {
"occluded": false,
"truncated": true
}
}
],
"lineColor": [
0,
255,
0,
128
],
"fillColor": [
255,
0,
0,
128
],
"imagePath": "2011_000003.jpg",
"imageData": null,
"imageHeight": 338,
"imageWidth": 500
}
\ No newline at end of file
{
"imagePath": "2011_000006.jpg",
"shapes": [
{
"line_color": null,
"points": [
[
204.936170212766,
108.56382978723406
],
[
183.936170212766,
141.56382978723406
],
[
166.936170212766,
150.56382978723406
],
[
108.93617021276599,
203.56382978723406
],
[
92.93617021276599,
228.56382978723406
],
[
95.93617021276599,
244.56382978723406
],
[
105.93617021276599,
244.56382978723406
],
[
116.93617021276599,
223.56382978723406
],
[
163.936170212766,
187.56382978723406
],
[
147.936170212766,
212.56382978723406
],
[
117.93617021276599,
222.56382978723406
],
[
108.93617021276599,
243.56382978723406
],
[
100.93617021276599,
325.56382978723406
],
[
135.936170212766,
329.56382978723406
],
[
148.936170212766,
319.56382978723406
],
[
150.936170212766,
295.56382978723406
],
[
169.936170212766,
272.56382978723406
],
[
171.936170212766,
249.56382978723406
],
[
178.936170212766,
246.56382978723406
],
[
186.936170212766,
225.56382978723406
],
[
214.936170212766,
219.56382978723406
],
[
242.936170212766,
157.56382978723406
],
[
228.936170212766,
146.56382978723406
],
[
228.936170212766,
125.56382978723406
],
[
216.936170212766,
112.56382978723406
]
],
"fill_color": null,
"label": "person-1"
},
{
"line_color": null,
"points": [
[
271.936170212766,
109.56382978723406
],
[
249.936170212766,
110.56382978723406
],
[
244.936170212766,
150.56382978723406
],
[
215.936170212766,
219.56382978723406
],
[
208.936170212766,
245.56382978723406
],
[
214.936170212766,
220.56382978723406
],
[
188.936170212766,
227.56382978723406
],
[
170.936170212766,
246.56382978723406
],
[
170.936170212766,
275.56382978723406
],
[
221.936170212766,
278.56382978723406
],
[
233.936170212766,
259.56382978723406
],
[
246.936170212766,
253.56382978723406
],
[
245.936170212766,
256.56382978723406
],
[
242.936170212766,
251.56382978723406
],
[
262.936170212766,
256.56382978723406
],
[
304.936170212766,
226.56382978723406
],
[
297.936170212766,
199.56382978723406
],
[
308.936170212766,
164.56382978723406
],
[
296.936170212766,
148.56382978723406
]
],
"fill_color": null,
"label": "person-2"
},
{
"line_color": null,
"points": [
[
308.936170212766,
115.56382978723406
],
[
298.936170212766,
145.56382978723406
],
[
309.936170212766,
166.56382978723406
],
[
297.936170212766,
200.56382978723406
],
[
305.936170212766,
228.56382978723406
],
[
262.936170212766,
258.56382978723406
],
[
252.936170212766,
284.56382978723406
],
[
272.936170212766,
291.56382978723406
],
[
281.936170212766,
250.56382978723406
],
[
326.936170212766,
235.56382978723406
],
[
351.936170212766,
239.56382978723406
],
[
365.936170212766,
223.56382978723406
],
[
371.936170212766,
187.56382978723406
],
[
353.936170212766,
168.56382978723406
],
[
344.936170212766,
143.56382978723406
],
[
336.936170212766,
115.56382978723406
]
],
"fill_color": null,
"label": "person-3"
},
{
"line_color": null,
"points": [
[
308.936170212766,
242.56382978723406
],
[
281.936170212766,
251.56382978723406
],
[
270.936170212766,
287.56382978723406
],
[
174.936170212766,
275.56382978723406
],
[
148.936170212766,
296.56382978723406
],
[
150.936170212766,
319.56382978723406
],
[
159.936170212766,
328.56382978723406
],
[
164.77327127659578,
375.0
],
[
485.936170212766,
373.56382978723406
],
[
497.936170212766,
336.56382978723406
],
[
497.936170212766,
202.56382978723406
],
[
453.936170212766,
193.56382978723406
],
[
434.936170212766,
212.56382978723406
],
[
367.936170212766,
224.56382978723406
],
[
350.936170212766,
241.56382978723406
]
],
"fill_color": null,
"label": "chair"
},
{
"line_color": null,
"points": [
[
425.936170212766,
82.56382978723406
],
[
404.936170212766,
109.56382978723406
],
[
400.936170212766,
114.56382978723406
],
[
437.936170212766,
114.56382978723406
],
[
448.936170212766,
102.56382978723406
],
[
446.936170212766,
91.56382978723406
]
],
"fill_color": null,
"label": "person-4"
},
{
"line_color": null,
"points": [
[
457.936170212766,
85.56382978723406
],
[
439.936170212766,
117.56382978723406
],
[
477.936170212766,
117.56382978723406
],
[
474.936170212766,
87.56382978723406
]
],
"fill_color": null,
"label": "__ignore__"
},
{
"line_color": null,
"points": [
[
183.936170212766,
140.56382978723406
],
[
125.93617021276599,
140.56382978723406
],
[
110.93617021276599,
187.56382978723406
],
[
22.936170212765987,
199.56382978723406
],
[
18.936170212765987,
218.56382978723406
],
[
22.936170212765987,
234.56382978723406
],
[
93.93617021276599,
239.56382978723406
],
[
91.93617021276599,
229.56382978723406
],
[
110.93617021276599,
203.56382978723406
]
],
"fill_color": null,
"label": "sofa"
},
{
"line_color": null,
"points": [
[
103.93617021276599,
290.56382978723406
],
[
58.93617021276599,
303.56382978723406
],
[
97.93617021276599,
311.56382978723406
]
],
"fill_color": null,
"label": "sofa"
},
{
"line_color": null,
"points": [
[
348.936170212766,
146.56382978723406
],
[
472.936170212766,
149.56382978723406
],
[
477.936170212766,
162.56382978723406
],
[
471.936170212766,
196.56382978723406
],
[
453.936170212766,
192.56382978723406
],
[
434.936170212766,
213.56382978723406
],
[
368.936170212766,
226.56382978723406
],
[
375.936170212766,
187.56382978723406
],
[
353.936170212766,
164.56382978723406
]
],
"fill_color": null,
"label": "sofa"
},
{
"line_color": null,
"points": [
[
246.936170212766,
252.56382978723406
],
[
219.936170212766,
277.56382978723406
],
[
254.936170212766,
287.56382978723406
],
[
261.936170212766,
256.56382978723406
]
],
"fill_color": null,
"label": "sofa"
}
],
"imageData": null,
"lineColor": [
0,
255,
0,
128
],
"fillColor": [
255,
0,
0,
128
]
}
\ No newline at end of file
{
"imageData": null,
"shapes": [
{
"fill_color": null,
"line_color": null,
"label": "bus-1",
"points": [
[
260.936170212766,
22.563829787234056
],
[
193.936170212766,
19.563829787234056
],
[
124.93617021276599,
39.563829787234056
],
[
89.93617021276599,
101.56382978723406
],
[
81.93617021276599,
150.56382978723406
],
[
108.93617021276599,
145.56382978723406
],
[
88.93617021276599,
244.56382978723406
],
[
89.93617021276599,
322.56382978723406
],
[
116.93617021276599,
367.56382978723406
],
[
158.936170212766,
368.56382978723406
],
[
165.936170212766,
337.56382978723406
],
[
347.936170212766,
335.56382978723406
],
[
349.936170212766,
369.56382978723406
],
[
391.936170212766,
373.56382978723406
],
[
403.936170212766,
335.56382978723406
],
[
425.936170212766,
332.56382978723406
],
[
421.936170212766,
281.56382978723406
],
[
428.936170212766,
252.56382978723406
],
[
428.936170212766,
236.56382978723406
],
[
409.936170212766,
220.56382978723406
],
[
409.936170212766,
150.56382978723406
],
[
430.936170212766,
143.56382978723406
],
[
433.936170212766,
112.56382978723406
],
[
431.936170212766,
96.56382978723406
],
[
408.936170212766,
90.56382978723406
],
[
395.936170212766,
50.563829787234056
],
[
338.936170212766,
25.563829787234056
]
]
},
{
"fill_color": null,
"line_color": null,
"label": "bus-2",
"points": [
[
88.93617021276599,
115.56382978723406
],
[
0.9361702127659877,
96.56382978723406
],
[
0.0,
251.968085106388
],
[
0.9361702127659877,
265.56382978723406
],
[
27.936170212765987,
265.56382978723406
],
[
29.936170212765987,
283.56382978723406
],
[
63.93617021276599,
281.56382978723406
],
[
89.93617021276599,
252.56382978723406
],
[
100.93617021276599,
183.56382978723406
],
[
108.93617021276599,
145.56382978723406
],
[
81.93617021276599,
151.56382978723406
]
]
},
{
"fill_color": null,
"line_color": null,
"label": "car",
"points": [
[
413.936170212766,
168.56382978723406
],
[
497.936170212766,
168.56382978723406
],
[
497.936170212766,
256.56382978723406
],
[
431.936170212766,
258.56382978723406
],
[
430.936170212766,
236.56382978723406
],
[
408.936170212766,
218.56382978723406
]
]
}
],
"fillColor": [
255,
0,
0,
128
],
"lineColor": [
0,
255,
0,
128
],
"imagePath": "2011_000025.jpg"
}
\ No newline at end of file
{"info": {"description": null, "url": null, "version": null, "year": 2019, "contributor": null, "date_created": "2019-03-09 01:48:36.742451"}, "licenses": [{"url": null, "id": 0, "name": null}], "images": [{"license": 0, "url": null, "file_name": "JPEGImages/2011_000003.jpg", "height": 338, "width": 500, "date_captured": null, "id": 0}, {"license": 0, "url": null, "file_name": "JPEGImages/2011_000025.jpg", "height": 375, "width": 500, "date_captured": null, "id": 1}, {"license": 0, "url": null, "file_name": "JPEGImages/2011_000006.jpg", "height": 375, "width": 500, "date_captured": null, "id": 2}], "type": "instances", "annotations": [{"id": 0, "segmentation": [[251.8142292490119, 107.33596837944665, 230.8142292490119, 119.33596837944665, 222.8142292490119, 135.33596837944665, 224.8142292490119, 148.33596837944665, 218.8142292490119, 161.33596837944665, 203.8142292490119, 168.33596837944665, 193.8142292490119, 200.33596837944665, 195.8142292490119, 222.33596837944665, 200.8142292490119, 227.33596837944665, 192.8142292490119, 234.33596837944665, 198.8142292490119, 264.3359683794467, 214.8142292490119, 295.3359683794467, 215.8142292490119, 320.3359683794467, 222.8142292490119, 327.3359683794467, 236.8142292490119, 326.3359683794467, 241.8142292490119, 323.3359683794467, 236.8142292490119, 298.3359683794467, 239.8142292490119, 287.3359683794467, 235.8142292490119, 268.3359683794467, 258.81422924901193, 258.3359683794467, 265.81422924901193, 264.3359683794467, 257.81422924901193, 273.3359683794467, 260.81422924901193, 282.3359683794467, 285.81422924901193, 288.3359683794467, 298.81422924901193, 278.3359683794467, 289.81422924901193, 270.3359683794467, 282.81422924901193, 270.3359683794467, 284.81422924901193, 264.3359683794467, 293.81422924901193, 261.3359683794467, 309.81422924901193, 236.33596837944665, 314.81422924901193, 217.33596837944665, 310.81422924901193, 208.33596837944665, 313.81422924901193, 202.33596837944665, 309.81422924901193, 185.33596837944665, 292.81422924901193, 173.33596837944665, 270.81422924901193, 159.33596837944665, 262.81422924901193, 154.33596837944665, 265.81422924901193, 142.33596837944665, 274.81422924901193, 137.33596837944665, 279.81422924901193, 130.33596837944665, 271.81422924901193, 121.33596837944665]], "area": 15689.0, "iscrowd": null, "image_id": 0, "category_id": 15}, {"id": 1, "segmentation": [[482.81422924901193, 85.33596837944665, 468.81422924901193, 90.33596837944665, 460.81422924901193, 110.33596837944665, 460.81422924901193, 127.33596837944665, 444.81422924901193, 137.33596837944665, 419.81422924901193, 153.33596837944665, 410.81422924901193, 163.33596837944665, 403.81422924901193, 168.33596837944665, 394.81422924901193, 170.33596837944665, 386.81422924901193, 168.33596837944665, 386.81422924901193, 184.33596837944665, 392.81422924901193, 182.33596837944665, 410.81422924901193, 187.33596837944665, 414.81422924901193, 192.33596837944665, 437.81422924901193, 189.33596837944665, 434.81422924901193, 204.33596837944665, 390.81422924901193, 195.33596837944665, 386.81422924901193, 195.33596837944665, 387.81422924901193, 208.33596837944665, 381.81422924901193, 212.33596837944665, 372.81422924901193, 212.33596837944665, 372.81422924901193, 216.33596837944665, 400.81422924901193, 270.3359683794467, 389.81422924901193, 272.3359683794467, 389.81422924901193, 274.3359683794467, 403.81422924901193, 282.3359683794467, 444.81422924901193, 283.3359683794467, 443.81422924901193, 259.3359683794467, 426.81422924901193, 244.33596837944665, 462.81422924901193, 256.3359683794467, 474.81422924901193, 270.3359683794467, 477.81422924901193, 280.3359683794467, 473.81422924901193, 289.3359683794467, 471.81422924901193, 296.3359683794467, 472.81422924901193, 317.3359683794467, 480.81422924901193, 332.3359683794467, 494.81422924901193, 335.3359683794467, 498.81422924901193, 329.3359683794467, 494.81422924901193, 308.3359683794467, 499.81422924901193, 297.3359683794467, 499.81422924901193, 90.33596837944665], [370.81422924901193, 170.33596837944665, 366.81422924901193, 173.33596837944665, 365.81422924901193, 182.33596837944665, 368.81422924901193, 185.33596837944665]], "area": 17254.0, "iscrowd": null, "image_id": 0, "category_id": 15}, {"id": 2, "segmentation": [[374.81422924901193, 159.33596837944665, 369.81422924901193, 170.33596837944665, 369.81422924901193, 210.33596837944665, 375.81422924901193, 212.33596837944665, 387.81422924901193, 209.33596837944665, 385.81422924901193, 185.33596837944665, 385.81422924901193, 168.33596837944665, 385.81422924901193, 165.33596837944665, 382.81422924901193, 159.33596837944665]], "area": 873.0, "iscrowd": null, "image_id": 0, "category_id": 5}, {"id": 3, "segmentation": [[260.936170212766, 22.563829787234056, 193.936170212766, 19.563829787234056, 124.93617021276599, 39.563829787234056, 89.93617021276599, 101.56382978723406, 81.93617021276599, 150.56382978723406, 108.93617021276599, 145.56382978723406, 88.93617021276599, 244.56382978723406, 89.93617021276599, 322.56382978723406, 116.93617021276599, 367.56382978723406, 158.936170212766, 368.56382978723406, 165.936170212766, 337.56382978723406, 347.936170212766, 335.56382978723406, 349.936170212766, 369.56382978723406, 391.936170212766, 373.56382978723406, 403.936170212766, 335.56382978723406, 425.936170212766, 332.56382978723406, 421.936170212766, 281.56382978723406, 428.936170212766, 252.56382978723406, 428.936170212766, 236.56382978723406, 409.936170212766, 220.56382978723406, 409.936170212766, 150.56382978723406, 430.936170212766, 143.56382978723406, 433.936170212766, 112.56382978723406, 431.936170212766, 96.56382978723406, 408.936170212766, 90.56382978723406, 395.936170212766, 50.563829787234056, 338.936170212766, 25.563829787234056]], "area": 102701.0, "iscrowd": null, "image_id": 1, "category_id": 6}, {"id": 4, "segmentation": [[88.93617021276599, 115.56382978723406, 0.9361702127659877, 96.56382978723406, 0.0, 251.968085106388, 0.9361702127659877, 265.56382978723406, 27.936170212765987, 265.56382978723406, 29.936170212765987, 283.56382978723406, 63.93617021276599, 281.56382978723406, 89.93617021276599, 252.56382978723406, 100.93617021276599, 183.56382978723406, 108.93617021276599, 145.56382978723406, 81.93617021276599, 151.56382978723406]], "area": 15781.0, "iscrowd": null, "image_id": 1, "category_id": 6}, {"id": 5, "segmentation": [[413.936170212766, 168.56382978723406, 497.936170212766, 168.56382978723406, 497.936170212766, 256.56382978723406, 431.936170212766, 258.56382978723406, 430.936170212766, 236.56382978723406, 408.936170212766, 218.56382978723406]], "area": 7256.0, "iscrowd": null, "image_id": 1, "category_id": 7}, {"id": 6, "segmentation": [[204.936170212766, 108.56382978723406, 183.936170212766, 141.56382978723406, 166.936170212766, 150.56382978723406, 108.93617021276599, 203.56382978723406, 92.93617021276599, 228.56382978723406, 95.93617021276599, 244.56382978723406, 105.93617021276599, 244.56382978723406, 116.93617021276599, 223.56382978723406, 163.936170212766, 187.56382978723406, 147.936170212766, 212.56382978723406, 117.93617021276599, 222.56382978723406, 108.93617021276599, 243.56382978723406, 100.93617021276599, 325.56382978723406, 135.936170212766, 329.56382978723406, 148.936170212766, 319.56382978723406, 150.936170212766, 295.56382978723406, 169.936170212766, 272.56382978723406, 171.936170212766, 249.56382978723406, 178.936170212766, 246.56382978723406, 186.936170212766, 225.56382978723406, 214.936170212766, 219.56382978723406, 242.936170212766, 157.56382978723406, 228.936170212766, 146.56382978723406, 228.936170212766, 125.56382978723406, 216.936170212766, 112.56382978723406]], "area": 15203.0, "iscrowd": null, "image_id": 2, "category_id": 15}, {"id": 7, "segmentation": [[271.936170212766, 109.56382978723406, 249.936170212766, 110.56382978723406, 244.936170212766, 150.56382978723406, 215.936170212766, 219.56382978723406, 208.936170212766, 245.56382978723406, 214.936170212766, 220.56382978723406, 188.936170212766, 227.56382978723406, 170.936170212766, 246.56382978723406, 170.936170212766, 275.56382978723406, 221.936170212766, 278.56382978723406, 233.936170212766, 259.56382978723406, 246.936170212766, 253.56382978723406, 245.936170212766, 256.56382978723406, 242.936170212766, 251.56382978723406, 262.936170212766, 256.56382978723406, 304.936170212766, 226.56382978723406, 297.936170212766, 199.56382978723406, 308.936170212766, 164.56382978723406, 296.936170212766, 148.56382978723406]], "area": 11735.0, "iscrowd": null, "image_id": 2, "category_id": 15}, {"id": 8, "segmentation": [[308.936170212766, 115.56382978723406, 298.936170212766, 145.56382978723406, 309.936170212766, 166.56382978723406, 297.936170212766, 200.56382978723406, 305.936170212766, 228.56382978723406, 262.936170212766, 258.56382978723406, 252.936170212766, 284.56382978723406, 272.936170212766, 291.56382978723406, 281.936170212766, 250.56382978723406, 326.936170212766, 235.56382978723406, 351.936170212766, 239.56382978723406, 365.936170212766, 223.56382978723406, 371.936170212766, 187.56382978723406, 353.936170212766, 168.56382978723406, 344.936170212766, 143.56382978723406, 336.936170212766, 115.56382978723406]], "area": 7597.0, "iscrowd": null, "image_id": 2, "category_id": 15}, {"id": 9, "segmentation": [[308.936170212766, 242.56382978723406, 281.936170212766, 251.56382978723406, 270.936170212766, 287.56382978723406, 174.936170212766, 275.56382978723406, 148.936170212766, 296.56382978723406, 150.936170212766, 319.56382978723406, 159.936170212766, 328.56382978723406, 164.77327127659578, 375.0, 485.936170212766, 373.56382978723406, 497.936170212766, 336.56382978723406, 497.936170212766, 202.56382978723406, 453.936170212766, 193.56382978723406, 434.936170212766, 212.56382978723406, 367.936170212766, 224.56382978723406, 350.936170212766, 241.56382978723406]], "area": 44532.0, "iscrowd": null, "image_id": 2, "category_id": 9}, {"id": 10, "segmentation": [[425.936170212766, 82.56382978723406, 404.936170212766, 109.56382978723406, 400.936170212766, 114.56382978723406, 437.936170212766, 114.56382978723406, 448.936170212766, 102.56382978723406, 446.936170212766, 91.56382978723406]], "area": 996.0, "iscrowd": null, "image_id": 2, "category_id": 15}, {"id": 11, "segmentation": [[183.936170212766, 140.56382978723406, 125.93617021276599, 140.56382978723406, 110.93617021276599, 187.56382978723406, 22.936170212765987, 199.56382978723406, 18.936170212765987, 218.56382978723406, 22.936170212765987, 234.56382978723406, 93.93617021276599, 239.56382978723406, 91.93617021276599, 229.56382978723406, 110.93617021276599, 203.56382978723406], [103.93617021276599, 290.56382978723406, 58.93617021276599, 303.56382978723406, 97.93617021276599, 311.56382978723406], [348.936170212766, 146.56382978723406, 472.936170212766, 149.56382978723406, 477.936170212766, 162.56382978723406, 471.936170212766, 196.56382978723406, 453.936170212766, 192.56382978723406, 434.936170212766, 213.56382978723406, 368.936170212766, 226.56382978723406, 375.936170212766, 187.56382978723406, 353.936170212766, 164.56382978723406], [246.936170212766, 252.56382978723406, 219.936170212766, 277.56382978723406, 254.936170212766, 287.56382978723406, 261.936170212766, 256.56382978723406]], "area": 14001.0, "iscrowd": null, "image_id": 2, "category_id": 18}], "categories": [{"supercategory": null, "id": 0, "name": "_background_"}, {"supercategory": null, "id": 1, "name": "aeroplane"}, {"supercategory": null, "id": 2, "name": "bicycle"}, {"supercategory": null, "id": 3, "name": "bird"}, {"supercategory": null, "id": 4, "name": "boat"}, {"supercategory": null, "id": 5, "name": "bottle"}, {"supercategory": null, "id": 6, "name": "bus"}, {"supercategory": null, "id": 7, "name": "car"}, {"supercategory": null, "id": 8, "name": "cat"}, {"supercategory": null, "id": 9, "name": "chair"}, {"supercategory": null, "id": 10, "name": "cow"}, {"supercategory": null, "id": 11, "name": "diningtable"}, {"supercategory": null, "id": 12, "name": "dog"}, {"supercategory": null, "id": 13, "name": "horse"}, {"supercategory": null, "id": 14, "name": "motorbike"}, {"supercategory": null, "id": 15, "name": "person"}, {"supercategory": null, "id": 16, "name": "potted plant"}, {"supercategory": null, "id": 17, "name": "sheep"}, {"supercategory": null, "id": 18, "name": "sofa"}, {"supercategory": null, "id": 19, "name": "train"}, {"supercategory": null, "id": 20, "name": "tv/monitor"}]}
\ No newline at end of file
_background_
aeroplane
bicycle
bird
boat
bottle
bus
car
cat
chair
cow
diningtable
dog
horse
motorbike
person
potted plant
sheep
sofa
train
tv/monitor
\ No newline at end of file
#!/usr/bin/env python
import argparse
import collections
import datetime
import glob
import json
import os
import os.path as osp
import sys
import numpy as np
import PIL.Image
import labelme
try:
import pycocotools.mask
except ImportError:
print('Please install pycocotools:\n\n pip install pycocotools\n')
sys.exit(1)
def main():
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter
)
parser.add_argument('input_dir', help='input annotated directory')
parser.add_argument('output_dir', help='output dataset directory')
parser.add_argument('--labels', help='labels file', required=True)
args = parser.parse_args()
if osp.exists(args.output_dir):
print('Output directory already exists:', args.output_dir)
sys.exit(1)
os.makedirs(args.output_dir)
os.makedirs(osp.join(args.output_dir, 'JPEGImages'))
print('Creating dataset:', args.output_dir)
now = datetime.datetime.now()
data = dict(
info=dict(
description=None,
url=None,
version=None,
year=now.year,
contributor=None,
date_created=now.strftime('%Y-%m-%d %H:%M:%S.%f'),
),
licenses=[dict(
url=None,
id=0,
name=None,
)],
images=[
# license, url, file_name, height, width, date_captured, id
],
type='instances',
annotations=[
# segmentation, area, iscrowd, image_id, bbox, category_id, id
],
categories=[
# supercategory, id, name
],
)
class_name_to_id = {}
for i, line in enumerate(open(args.labels).readlines()):
class_id = i - 1 # starts with -1
class_name = line.strip()
if class_id == -1:
assert class_name == '__ignore__'
continue
class_name_to_id[class_name] = class_id
data['categories'].append(dict(
supercategory=None,
id=class_id,
name=class_name,
))
out_ann_file = osp.join(args.output_dir, 'annotations.json')
label_files = glob.glob(osp.join(args.input_dir, '*.json'))
for image_id, label_file in enumerate(label_files):
print('Generating dataset from:', label_file)
with open(label_file) as f:
label_data = json.load(f)
base = osp.splitext(osp.basename(label_file))[0]
out_img_file = osp.join(
args.output_dir, 'JPEGImages', base + '.jpg'
)
img_file = osp.join(
osp.dirname(label_file), label_data['imagePath']
)
img = np.asarray(PIL.Image.open(img_file))
PIL.Image.fromarray(img).save(out_img_file)
data['images'].append(dict(
license=0,
url=None,
file_name=osp.relpath(out_img_file, osp.dirname(out_ann_file)),
height=img.shape[0],
width=img.shape[1],
date_captured=None,
id=image_id,
))
masks = {} # for area
segmentations = collections.defaultdict(list) # for segmentation
for shape in label_data['shapes']:
points = shape['points']
label = shape['label']
shape_type = shape.get('shape_type', None)
mask = labelme.utils.shape_to_mask(
img.shape[:2], points, shape_type
)
if label in masks:
masks[label] = masks[label] | mask
else:
masks[label] = mask
points = np.asarray(points).flatten().tolist()
segmentations[label].append(points)
for label, mask in masks.items():
cls_name = label.split('-')[0]
if cls_name not in class_name_to_id:
continue
cls_id = class_name_to_id[cls_name]
mask = np.asfortranarray(mask.astype(np.uint8))
mask = pycocotools.mask.encode(mask)
area = float(pycocotools.mask.area(mask))
bbox = pycocotools.mask.toBbox(mask).flatten().tolist()
data['annotations'].append(dict(
id=len(data['annotations']),
image_id=image_id,
category_id=cls_id,
segmentation=segmentations[label],
area=area,
bbox=bbox,
iscrowd=0,
))
with open(out_ann_file, 'w') as f:
json.dump(data, f)
if __name__ == '__main__':
main()
#!/usr/bin/env python
from __future__ import print_function
import argparse
import glob
import json
import os
import os.path as osp
import sys
import numpy as np
import PIL.Image
import labelme
def main():
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter
)
parser.add_argument('input_dir', help='input annotated directory')
parser.add_argument('output_dir', help='output dataset directory')
parser.add_argument('--labels', help='labels file', required=True)
args = parser.parse_args()
if osp.exists(args.output_dir):
print('Output directory already exists:', args.output_dir)
sys.exit(1)
os.makedirs(args.output_dir)
os.makedirs(osp.join(args.output_dir, 'JPEGImages'))
os.makedirs(osp.join(args.output_dir, 'SegmentationClass'))
os.makedirs(osp.join(args.output_dir, 'SegmentationClassPNG'))
os.makedirs(osp.join(args.output_dir, 'SegmentationClassVisualization'))
os.makedirs(osp.join(args.output_dir, 'SegmentationObject'))
os.makedirs(osp.join(args.output_dir, 'SegmentationObjectPNG'))
os.makedirs(osp.join(args.output_dir, 'SegmentationObjectVisualization'))
print('Creating dataset:', args.output_dir)
class_names = []
class_name_to_id = {}
for i, line in enumerate(open(args.labels).readlines()):
class_id = i - 1 # starts with -1
class_name = line.strip()
class_name_to_id[class_name] = class_id
if class_id == -1:
assert class_name == '__ignore__'
continue
elif class_id == 0:
assert class_name == '_background_'
class_names.append(class_name)
class_names = tuple(class_names)
print('class_names:', class_names)
out_class_names_file = osp.join(args.output_dir, 'class_names.txt')
with open(out_class_names_file, 'w') as f:
f.writelines('\n'.join(class_names))
print('Saved class_names:', out_class_names_file)
colormap = labelme.utils.label_colormap(255)
for label_file in glob.glob(osp.join(args.input_dir, '*.json')):
print('Generating dataset from:', label_file)
with open(label_file) as f:
base = osp.splitext(osp.basename(label_file))[0]
out_img_file = osp.join(
args.output_dir, 'JPEGImages', base + '.jpg')
out_cls_file = osp.join(
args.output_dir, 'SegmentationClass', base + '.npy')
out_clsp_file = osp.join(
args.output_dir, 'SegmentationClassPNG', base + '.png')
out_clsv_file = osp.join(
args.output_dir,
'SegmentationClassVisualization',
base + '.jpg',
)
out_ins_file = osp.join(
args.output_dir, 'SegmentationObject', base + '.npy')
out_insp_file = osp.join(
args.output_dir, 'SegmentationObjectPNG', base + '.png')
out_insv_file = osp.join(
args.output_dir,
'SegmentationObjectVisualization',
base + '.jpg',
)
data = json.load(f)
img_file = osp.join(osp.dirname(label_file), data['imagePath'])
img = np.asarray(PIL.Image.open(img_file))
PIL.Image.fromarray(img).save(out_img_file)
cls, ins = labelme.utils.shapes_to_label(
img_shape=img.shape,
shapes=data['shapes'],
label_name_to_value=class_name_to_id,
type='instance',
)
ins[cls == -1] = 0 # ignore it.
# class label
labelme.utils.lblsave(out_clsp_file, cls)
np.save(out_cls_file, cls)
clsv = labelme.utils.draw_label(
cls, img, class_names, colormap=colormap)
PIL.Image.fromarray(clsv).save(out_clsv_file)
# instance label
labelme.utils.lblsave(out_insp_file, ins)
np.save(out_ins_file, ins)
instance_ids = np.unique(ins)
instance_names = [str(i) for i in range(max(instance_ids) + 1)]
insv = labelme.utils.draw_label(ins, img, instance_names)
PIL.Image.fromarray(insv).save(out_insv_file)
if __name__ == '__main__':
main()
__ignore__
_background_
aeroplane
bicycle
bird
boat
bottle
bus
car
cat
chair
cow
diningtable
dog
horse
motorbike
person
potted plant
sheep
sofa
train
tv/monitor
\ No newline at end of file
{
"version": "3.5.0",
"flags": {},
"shapes": [
{
"label": "rectangle",
"line_color": null,
"fill_color": null,
"points": [
[
32,
35
],
[
132,
135
]
],
"shape_type": "rectangle"
},
{
"label": "circle",
"line_color": null,
"fill_color": null,
"points": [
[
195,
84
],
[
225,
125
]
],
"shape_type": "circle"
},
{
"label": "rectangle",
"line_color": null,
"fill_color": null,
"points": [
[
391,
33
],
[
542,
135
]
],
"shape_type": "rectangle"
},
{
"label": "polygon",
"line_color": null,
"fill_color": null,
"points": [
[
69,
318
],
[
45,
403
],
[
173,
406
],
[
198,
321
]
],
"shape_type": "polygon"
},
{
"label": "line",
"line_color": null,
"fill_color": null,
"points": [
[
188,
178
],
[
160,
224
]
],
"shape_type": "line"
},
{
"label": "point",
"line_color": null,
"fill_color": null,
"points": [
[
345,
174
]
],
"shape_type": "point"
},
{
"label": "line_strip",
"line_color": null,
"fill_color": null,
"points": [
[
441,
181
],
[
403,
274
],
[
545,
275
]
],
"shape_type": "linestrip"
}
],
"lineColor": [
0,
255,
0,
128
],
"fillColor": [
255,
0,
0,
128
],
"imagePath": "primitives.jpg",
"imageData": null
}
\ No newline at end of file
# Semantic Segmentation Example
## Annotation
```bash
labelme data_annotated --labels labels.txt --nodata
```
![](.readme/annotation.jpg)
## Convert to VOC-format Dataset
```bash
# It generates:
# - data_dataset_voc/JPEGImages
# - data_dataset_voc/SegmentationClass
# - data_dataset_voc/SegmentationClassVisualization
./labelme2voc.py data_annotated data_dataset_voc --labels labels.txt
```
<img src="data_dataset_voc/JPEGImages/2011_000003.jpg" width="33%" /> <img src="data_dataset_voc/SegmentationClassPNG/2011_000003.png" width="33%" /> <img src="data_dataset_voc/SegmentationClassVisualization/2011_000003.jpg" width="33%" />
Fig 1. JPEG image (left), PNG label (center), JPEG label visualization (right)
Note that the label file contains only very low label values (ex. `0, 4, 14`), and
`255` indicates the `__ignore__` label value (`-1` in the npy file).
You can see the label PNG file by following.
```bash
labelme_draw_label_png data_dataset_voc/SegmentationClassPNG/2011_000003.png
```
<img src=".readme/draw_label_png.jpg" width="33%" />
{
"shapes": [
{
"label": "person",
"line_color": null,
"fill_color": null,
"points": [
[
250.8142292490119,
107.33596837944665
],
[
229.8142292490119,
119.33596837944665
],
[
221.8142292490119,
135.33596837944665
],
[
223.8142292490119,
148.33596837944665
],
[
217.8142292490119,
161.33596837944665
],
[
202.8142292490119,
168.33596837944665
],
[
192.8142292490119,
200.33596837944665
],
[
194.8142292490119,
222.33596837944665
],
[
199.8142292490119,
227.33596837944665
],
[
191.8142292490119,
234.33596837944665
],
[
197.8142292490119,
264.3359683794467
],
[
213.8142292490119,
295.3359683794467
],
[
214.8142292490119,
320.3359683794467
],
[
221.8142292490119,
327.3359683794467
],
[
235.8142292490119,
326.3359683794467
],
[
240.8142292490119,
323.3359683794467
],
[
235.8142292490119,
298.3359683794467
],
[
238.8142292490119,
287.3359683794467
],
[
234.8142292490119,
268.3359683794467
],
[
257.81422924901193,
258.3359683794467
],
[
264.81422924901193,
264.3359683794467
],
[
256.81422924901193,
273.3359683794467
],
[
259.81422924901193,
282.3359683794467
],
[
284.81422924901193,
288.3359683794467
],
[
297.81422924901193,
278.3359683794467
],
[
288.81422924901193,
270.3359683794467
],
[
281.81422924901193,
270.3359683794467
],
[
283.81422924901193,
264.3359683794467
],
[
292.81422924901193,
261.3359683794467
],
[
308.81422924901193,
236.33596837944665
],
[
313.81422924901193,
217.33596837944665
],
[
309.81422924901193,
208.33596837944665
],
[
312.81422924901193,
202.33596837944665
],
[
308.81422924901193,
185.33596837944665
],
[
291.81422924901193,
173.33596837944665
],
[
269.81422924901193,
159.33596837944665
],
[
261.81422924901193,
154.33596837944665
],
[
264.81422924901193,
142.33596837944665
],
[
273.81422924901193,
137.33596837944665
],
[
278.81422924901193,
130.33596837944665
],
[
270.81422924901193,
121.33596837944665
]
]
},
{
"label": "person",
"line_color": null,
"fill_color": null,
"points": [
[
482.81422924901193,
85.33596837944665
],
[
468.81422924901193,
90.33596837944665
],
[
460.81422924901193,
110.33596837944665
],
[
460.81422924901193,
127.33596837944665
],
[
444.81422924901193,
137.33596837944665
],
[
419.81422924901193,
153.33596837944665
],
[
410.81422924901193,
163.33596837944665
],
[
403.81422924901193,
168.33596837944665
],
[
394.81422924901193,
170.33596837944665
],
[
386.81422924901193,
168.33596837944665
],
[
386.81422924901193,
184.33596837944665
],
[
392.81422924901193,
182.33596837944665
],
[
410.81422924901193,
187.33596837944665
],
[
414.81422924901193,
192.33596837944665
],
[
437.81422924901193,
189.33596837944665
],
[
434.81422924901193,
204.33596837944665
],
[
390.81422924901193,
195.33596837944665
],
[
386.81422924901193,
195.33596837944665
],
[
387.81422924901193,
208.33596837944665
],
[
381.81422924901193,
212.33596837944665
],
[
372.81422924901193,
212.33596837944665
],
[
372.81422924901193,
216.33596837944665
],
[
400.81422924901193,
270.3359683794467
],
[
389.81422924901193,
272.3359683794467
],
[
389.81422924901193,
274.3359683794467
],
[
403.81422924901193,
282.3359683794467
],
[
444.81422924901193,
283.3359683794467
],
[
443.81422924901193,
259.3359683794467
],
[
426.81422924901193,
244.33596837944665
],
[
462.81422924901193,
256.3359683794467
],
[
474.81422924901193,
270.3359683794467
],
[
477.81422924901193,
280.3359683794467
],
[
473.81422924901193,
289.3359683794467
],
[
471.81422924901193,
296.3359683794467
],
[
472.81422924901193,
317.3359683794467
],
[
480.81422924901193,
332.3359683794467
],
[
494.81422924901193,
335.3359683794467
],
[
498.81422924901193,
329.3359683794467
],
[
494.81422924901193,
308.3359683794467
],
[
499.81422924901193,
297.3359683794467
],
[
499.81422924901193,
90.33596837944665
]
]
},
{
"label": "bottle",
"line_color": null,
"fill_color": null,
"points": [
[
374.81422924901193,
159.33596837944665
],
[
369.81422924901193,
170.33596837944665
],
[
369.81422924901193,
210.33596837944665
],
[
375.81422924901193,
212.33596837944665
],
[
387.81422924901193,
209.33596837944665
],
[
385.81422924901193,
185.33596837944665
],
[
385.81422924901193,
168.33596837944665
],
[
385.81422924901193,
165.33596837944665
],
[
382.81422924901193,
159.33596837944665
]
]
},
{
"label": "person",
"line_color": null,
"fill_color": null,
"points": [
[
370.81422924901193,
170.33596837944665
],
[
366.81422924901193,
173.33596837944665
],
[
365.81422924901193,
182.33596837944665
],
[
368.81422924901193,
185.33596837944665
]
]
},
{
"label": "__ignore__",
"line_color": null,
"fill_color": null,
"points": [
[
338.81422924901193,
266.3359683794467
],
[
313.81422924901193,
269.3359683794467
],
[
297.81422924901193,
277.3359683794467
],
[
282.81422924901193,
288.3359683794467
],
[
273.81422924901193,
302.3359683794467
],
[
272.81422924901193,
320.3359683794467
],
[
279.81422924901193,
337.3359683794467
],
[
428.81422924901193,
337.3359683794467
],
[
432.81422924901193,
316.3359683794467
],
[
423.81422924901193,
296.3359683794467
],
[
403.81422924901193,
283.3359683794467
],
[
370.81422924901193,
270.3359683794467
]
]
}
],
"lineColor": [
0,
255,
0,
128
],
"fillColor": [
255,
0,
0,
128
],
"imagePath": "2011_000003.jpg",
"imageData": null
}
\ No newline at end of file
{
"shapes": [
{
"label": "person",
"line_color": null,
"fill_color": null,
"points": [
[
204.936170212766,
108.56382978723406
],
[
183.936170212766,
141.56382978723406
],
[
166.936170212766,
150.56382978723406
],
[
108.93617021276599,
203.56382978723406
],
[
92.93617021276599,
228.56382978723406
],
[
95.93617021276599,
244.56382978723406
],
[
105.93617021276599,
244.56382978723406
],
[
116.93617021276599,
223.56382978723406
],
[
163.936170212766,
187.56382978723406
],
[
147.936170212766,
212.56382978723406
],
[
117.93617021276599,
222.56382978723406
],
[
108.93617021276599,
243.56382978723406
],
[
100.93617021276599,
325.56382978723406
],
[
135.936170212766,
329.56382978723406
],
[
148.936170212766,
319.56382978723406
],
[
150.936170212766,
295.56382978723406
],
[
169.936170212766,
272.56382978723406
],
[
171.936170212766,
249.56382978723406
],
[
178.936170212766,
246.56382978723406
],
[
186.936170212766,
225.56382978723406
],
[
214.936170212766,
219.56382978723406
],
[
242.936170212766,
157.56382978723406
],
[
228.936170212766,
146.56382978723406
],
[
228.936170212766,
125.56382978723406
],
[
216.936170212766,
112.56382978723406
]
]
},
{
"label": "person",
"line_color": null,
"fill_color": null,
"points": [
[
271.936170212766,
109.56382978723406
],
[
249.936170212766,
110.56382978723406
],
[
244.936170212766,
150.56382978723406
],
[
215.936170212766,
219.56382978723406
],
[
208.936170212766,
245.56382978723406
],
[
214.936170212766,
220.56382978723406
],
[
188.936170212766,
227.56382978723406
],
[
170.936170212766,
246.56382978723406
],
[
170.936170212766,
275.56382978723406
],
[
221.936170212766,
278.56382978723406
],
[
233.936170212766,
259.56382978723406
],
[
246.936170212766,
253.56382978723406
],
[
245.936170212766,
256.56382978723406
],
[
242.936170212766,
251.56382978723406
],
[
262.936170212766,
256.56382978723406
],
[
304.936170212766,
226.56382978723406
],
[
297.936170212766,
199.56382978723406
],
[
308.936170212766,
164.56382978723406
],
[
296.936170212766,
148.56382978723406
]
]
},
{
"label": "person",
"line_color": null,
"fill_color": null,
"points": [
[
308.936170212766,
115.56382978723406
],
[
298.936170212766,
145.56382978723406
],
[
309.936170212766,
166.56382978723406
],
[
297.936170212766,
200.56382978723406
],
[
305.936170212766,
228.56382978723406
],
[
262.936170212766,
258.56382978723406
],
[
252.936170212766,
284.56382978723406
],
[
272.936170212766,
291.56382978723406
],
[
281.936170212766,
250.56382978723406
],
[
326.936170212766,
235.56382978723406
],
[
351.936170212766,
239.56382978723406
],
[
365.936170212766,
223.56382978723406
],
[
371.936170212766,
187.56382978723406
],
[
353.936170212766,
168.56382978723406
],
[
344.936170212766,
143.56382978723406
],
[
336.936170212766,
115.56382978723406
]
]
},
{
"label": "chair",
"line_color": null,
"fill_color": null,
"points": [
[
308.936170212766,
242.56382978723406
],
[
281.936170212766,
251.56382978723406
],
[
270.936170212766,
287.56382978723406
],
[
174.936170212766,
275.56382978723406
],
[
148.936170212766,
296.56382978723406
],
[
150.936170212766,
319.56382978723406
],
[
159.936170212766,
328.56382978723406
],
[
164.77327127659578,
375.0
],
[
485.936170212766,
373.56382978723406
],
[
497.936170212766,
336.56382978723406
],
[
497.936170212766,
202.56382978723406
],
[
453.936170212766,
193.56382978723406
],
[
434.936170212766,
212.56382978723406
],
[
367.936170212766,
224.56382978723406
],
[
350.936170212766,
241.56382978723406
]
]
},
{
"label": "person",
"line_color": null,
"fill_color": null,
"points": [
[
425.936170212766,
82.56382978723406
],
[
404.936170212766,
109.56382978723406
],
[
400.936170212766,
114.56382978723406
],
[
437.936170212766,
114.56382978723406
],
[
448.936170212766,
102.56382978723406
],
[
446.936170212766,
91.56382978723406
]
]
},
{
"label": "__ignore__",
"line_color": null,
"fill_color": null,
"points": [
[
457.936170212766,
85.56382978723406
],
[
439.936170212766,
117.56382978723406
],
[
477.936170212766,
117.56382978723406
],
[
474.936170212766,
87.56382978723406
]
]
},
{
"label": "sofa",
"line_color": null,
"fill_color": null,
"points": [
[
183.936170212766,
140.56382978723406
],
[
125.93617021276599,
140.56382978723406
],
[
110.93617021276599,
187.56382978723406
],
[
22.936170212765987,
199.56382978723406
],
[
18.936170212765987,
218.56382978723406
],
[
22.936170212765987,
234.56382978723406
],
[
93.93617021276599,
239.56382978723406
],
[
91.93617021276599,
229.56382978723406
],
[
110.93617021276599,
203.56382978723406
]
]
},
{
"label": "sofa",
"line_color": null,
"fill_color": null,
"points": [
[
103.93617021276599,
290.56382978723406
],
[
58.93617021276599,
303.56382978723406
],
[
97.93617021276599,
311.56382978723406
]
]
},
{
"label": "sofa",
"line_color": null,
"fill_color": null,
"points": [
[
348.936170212766,
146.56382978723406
],
[
472.936170212766,
149.56382978723406
],
[
477.936170212766,
162.56382978723406
],
[
471.936170212766,
196.56382978723406
],
[
453.936170212766,
192.56382978723406
],
[
434.936170212766,
213.56382978723406
],
[
368.936170212766,
226.56382978723406
],
[
375.936170212766,
187.56382978723406
],
[
353.936170212766,
164.56382978723406
]
]
},
{
"label": "sofa",
"line_color": null,
"fill_color": null,
"points": [
[
246.936170212766,
252.56382978723406
],
[
219.936170212766,
277.56382978723406
],
[
254.936170212766,
287.56382978723406
],
[
261.936170212766,
256.56382978723406
]
]
}
],
"lineColor": [
0,
255,
0,
128
],
"fillColor": [
255,
0,
0,
128
],
"imagePath": "2011_000006.jpg",
"imageData": null
}
\ No newline at end of file
{
"shapes": [
{
"label": "bus",
"line_color": null,
"fill_color": null,
"points": [
[
260.936170212766,
22.563829787234056
],
[
193.936170212766,
19.563829787234056
],
[
124.93617021276599,
39.563829787234056
],
[
89.93617021276599,
101.56382978723406
],
[
81.93617021276599,
150.56382978723406
],
[
108.93617021276599,
145.56382978723406
],
[
88.93617021276599,
244.56382978723406
],
[
89.93617021276599,
322.56382978723406
],
[
116.93617021276599,
367.56382978723406
],
[
158.936170212766,
368.56382978723406
],
[
165.936170212766,
337.56382978723406
],
[
347.936170212766,
335.56382978723406
],
[
349.936170212766,
369.56382978723406
],
[
391.936170212766,
373.56382978723406
],
[
403.936170212766,
335.56382978723406
],
[
425.936170212766,
332.56382978723406
],
[
421.936170212766,
281.56382978723406
],
[
428.936170212766,
252.56382978723406
],
[
428.936170212766,
236.56382978723406
],
[
409.936170212766,
220.56382978723406
],
[
409.936170212766,
150.56382978723406
],
[
430.936170212766,
143.56382978723406
],
[
433.936170212766,
112.56382978723406
],
[
431.936170212766,
96.56382978723406
],
[
408.936170212766,
90.56382978723406
],
[
395.936170212766,
50.563829787234056
],
[
338.936170212766,
25.563829787234056
]
]
},
{
"label": "bus",
"line_color": null,
"fill_color": null,
"points": [
[
88.93617021276599,
115.56382978723406
],
[
0.9361702127659877,
96.56382978723406
],
[
0.0,
251.968085106388
],
[
0.9361702127659877,
265.56382978723406
],
[
27.936170212765987,
265.56382978723406
],
[
29.936170212765987,
283.56382978723406
],
[
63.93617021276599,
281.56382978723406
],
[
89.93617021276599,
252.56382978723406
],
[
100.93617021276599,
183.56382978723406
],
[
108.93617021276599,
145.56382978723406
],
[
81.93617021276599,
151.56382978723406
]
]
},
{
"label": "car",
"line_color": null,
"fill_color": null,
"points": [
[
413.936170212766,
168.56382978723406
],
[
497.936170212766,
168.56382978723406
],
[
497.936170212766,
256.56382978723406
],
[
431.936170212766,
258.56382978723406
],
[
430.936170212766,
236.56382978723406
],
[
408.936170212766,
218.56382978723406
]
]
}
],
"lineColor": [
0,
255,
0,
128
],
"fillColor": [
255,
0,
0,
128
],
"imagePath": "2011_000025.jpg",
"imageData": null
}
\ No newline at end of file
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册