Skip to content

Commit a2ae99a

Browse files
committed
🎨 json file 수정
1 parent 78b01e7 commit a2ae99a

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

json_annotation_merge.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,25 @@
55
output_file = 'merged_data.json'
66

77
# 빈 리스트를 생성합니다.
8-
merged_data = {"images": [], "annotations": []}
8+
merged_data = {
9+
"info": {
10+
"year": 2021,
11+
"version": "1.0",
12+
"description": "Recycle Trash",
13+
"contributor": "Upstage",
14+
"url": None,
15+
"date_created": "2021-02-02 01:10:00"
16+
},
17+
"licenses": [
18+
{
19+
"id": 0,
20+
"name": "CC BY 4.0",
21+
"url": "https://creativecommons.org/licenses/by/4.0/deed.ast"
22+
}
23+
],
24+
"images": [],
25+
"annotations": []
26+
}
927

1028
# 이미지 및 어노테이션의 ID를 추적하기 위한 변수 초기화
1129
image_id_counter = 0
@@ -21,7 +39,10 @@
2139
# images와 annotations에 대한 ID를 갱신
2240
for img_info in data['images']:
2341
img_info['id'] = image_id_counter
24-
img_info['file_name'] = f"{batch_folder}/{img_info['file_name']}"
42+
43+
file_num = f"{image_id_counter:04d}" if image_id_counter < 1000 else str(image_id_counter)
44+
img_info['file_name'] = f"{file_num}.jpg"
45+
2546
merged_data['images'].append(img_info)
2647
image_id_counter += 1
2748

0 commit comments

Comments
 (0)