File tree Expand file tree Collapse file tree 1 file changed +23
-2
lines changed Expand file tree Collapse file tree 1 file changed +23
-2
lines changed Original file line number Diff line number Diff line change 5
5
output_file = 'merged_data.json'
6
6
7
7
# 빈 리스트를 생성합니다.
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
+ }
9
27
10
28
# 이미지 및 어노테이션의 ID를 추적하기 위한 변수 초기화
11
29
image_id_counter = 0
21
39
# images와 annotations에 대한 ID를 갱신
22
40
for img_info in data ['images' ]:
23
41
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
+
25
46
merged_data ['images' ].append (img_info )
26
47
image_id_counter += 1
27
48
You can’t perform that action at this time.
0 commit comments