Skip to content

Commit 66057d8

Browse files
committed
refactor: check labelme_bbox_json2voc is OK
1 parent c4c3da4 commit 66057d8

File tree

10 files changed

+11
-6
lines changed

10 files changed

+11
-6
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,12 @@
161161
```
162162

163163
- 转换 JSON 文件夹`labelme_jsons_dir` 到 VOC 格式的数据集。 (`labelme_bbox_json2voc.py`)
164-
- 需要标签转换
164+
- 不需要标签转换
165165
```sh
166166
labelme_bbox_json2voc --json_dir=data/sample_jsons \
167167
--output_dir=output/test_voc_output --labels data/label_names.txt
168168
```
169-
- 不需要标签转换
169+
- 需要标签转换
170170
```sh
171171
labelme_bbox_json2voc --json_dir=data/sample_jsons \
172172
--output_dir=output/test_voc_output \

SimSun.ttf

10 MB
Binary file not shown.

labelme2datasets/labelme_bbox_json2voc.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
# coding=utf-8
12
"""
23
desc: gather json files annotated by labelme into a dictionary,
34
and use this script to generate a voc style dataset.
45
56
reference: https://github.com/wkentaro/labelme/blob/main/examples/bbox_detection/labelme2voc.py
67
"""
78

8-
# coding=utf-8
99

1010
from __future__ import print_function
1111

@@ -198,7 +198,7 @@ def process_annotated_json(class_names, filename, output_dir, label_dict):
198198

199199
# save source image
200200
img = labelme.utils.img_data_to_arr(label_file.imageData)
201-
imgviz.io.imsave(out_img_file, img)
201+
imgviz.io.imsave(str(out_img_file), img)
202202

203203
# get xml
204204
(xml, bboxes, labels) = get_xml_with_labelfile(label_file, base, label_dict, class_names)
@@ -215,12 +215,16 @@ def save_visualization_image(img, labels, bboxes, class_names, output_file):
215215
"""save visualized image"""
216216
# caption for visualize drawing
217217
captions = [class_names[label] for label in labels]
218+
# font can display chinese
219+
# MARK: change font path if you need
220+
font_path = "SimSun.ttf"
218221
viz = imgviz.instances2rgb(
219222
image=img,
220223
labels=labels,
221224
bboxes=bboxes,
222225
captions=captions,
223-
font_size=15,
226+
font_size=20,
227+
font_path=font_path,
224228
)
225229
imgviz.io.imsave(output_file, viz)
226230

labelme2datasets/utils.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
# coding=utf-8
12
"""
23
some common functions.
34
"""
45

5-
# coding=utf-8
66

77
import os.path as osp
88

9+
910
def get_label_conversion_dict(dict_file):
1011
"""
1112
自定义标签转换,例如将中文标签转换为英文标签
Loading
Loading
Loading
-113 Bytes
Loading
-145 Bytes
Loading
-122 Bytes
Loading

0 commit comments

Comments
 (0)