File size: 3,851 Bytes
7b7527a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
[็ฎ€ไฝ“ไธญๆ–‡](KeyPointAnnoTools.md) | English

# Key Points Detection Annotation Tool

## Concents

[LabelMe](#LabelMe)

- [Instruction](#Instruction)
  - [Installation](#Installation)
  - [Notes of Key Points Data](#Notes-of-Key-Points-Data)
  - [Annotation of LabelMe](#Annotation-of-LabelMe)
- [Annotation Format](#Annotation-Format)
  - [Data Export Format](#Data-Export-Format)
  - [Summary of Format Conversion](#Summary-of-Format-Conversion)
  - [Annotation file(json)โ€”>COCO Dataset](#annotation-filejsoncoco-dataset)



## [LabelMe](https://github.com/wkentaro/labelme)

### Instruction

#### Installation

Please refer to [The github of LabelMe](https://github.com/wkentaro/labelme) for installation details.

<details>
<summary><b> Ubuntu</b></summary>

```
sudo apt-get install labelme

# or
sudo pip3 install labelme

# or install standalone executable from:
# https://github.com/wkentaro/labelme/releases
```

</details>

<details>
<summary><b> macOS</b></summary>

```
brew install pyqt  # maybe pyqt5
pip install labelme

# or
brew install wkentaro/labelme/labelme  # command line interface
# brew install --cask wkentaro/labelme/labelme  # app

# or install standalone executable/app from:
# https://github.com/wkentaro/labelme/releases
```

</details>



We recommend installing by Anoncanda.

```
conda create โ€“name=labelme python=3
conda activate labelme
pip install pyqt5
pip install labelme
```



#### Notes of Key Points Data

COCO dataset needs to collect 17 key points.

```
keypoint indexes:
        0: 'nose',
        1: 'left_eye',
        2: 'right_eye',
        3: 'left_ear',
        4: 'right_ear',
        5: 'left_shoulder',
        6: 'right_shoulder',
        7: 'left_elbow',
        8: 'right_elbow',
        9: 'left_wrist',
        10: 'right_wrist',
        11: 'left_hip',
        12: 'right_hip',
        13: 'left_knee',
        14: 'right_knee',
        15: 'left_ankle',
        16: 'right_ankle'
```





#### Annotation of LabelMe

After starting labelme, select an image or an folder with images.

Select  `create polygons`   in the formula bar. Draw an annotation area as shown in the following  GIF. You can right-click on the image to select different shape. When finished, press the Enter/Return key, then fill the corresponding label in the popup box, such as, people.

Click the save button in the formula bar๏ผŒit will generate an annotation file in json.

![ๆ“ไฝœ่ฏดๆ˜Ž](https://user-images.githubusercontent.com/34162360/178250648-29ee781a-676b-419c-83b1-de1e4e490526.gif)



### Annotation Format

#### Data Export Format

```
#generate an annotation file
png/jpeg/jpg-->labelme-->json
```



#### Summary of Format Conversion

```
#convert annotation file to COCO dataset format
json-->labelme2coco.py-->COCO dataset
```





#### Annotation file(json)โ€”>COCO Dataset

Convert the data annotated by LabelMe to COCO dataset by this script [x2coco.py](https://github.com/PaddlePaddle/PaddleDetection/blob/release/2.6/tools/x2coco.py).

```bash
python tools/x2coco.py \
                --dataset_type labelme \
                --json_input_dir ./labelme_annos/ \
                --image_input_dir ./labelme_imgs/ \
                --output_dir ./cocome/ \
                --train_proportion 0.8 \
                --val_proportion 0.2 \
                --test_proportion 0.0
```

After the user dataset is converted to COCO data, the directory structure is as follows (note that the path name and file name in the dataset should not use Chinese as far as possible to avoid errors caused by Chinese coding problems):

```
dataset/xxx/
โ”œโ”€โ”€ annotations
โ”‚   โ”œโ”€โ”€ train.json  # Annotation file of coco data
โ”‚   โ”œโ”€โ”€ valid.json  # Annotation file of coco data
โ”œโ”€โ”€ images
โ”‚   โ”œโ”€โ”€ xxx1.jpg
โ”‚   โ”œโ”€โ”€ xxx2.jpg
โ”‚   โ”œโ”€โ”€ xxx3.jpg
โ”‚   |   ...
...
```