김성주

annotation and dataset text files

import xml.etree.ElementTree as elemTree
import os
CLASSES = ['dog']
def parseFile(path):
result = ""
annotation = elemTree.parse(path)
filename = annotation.find('filename')
size = annotation.find('size')
width = size.find('width')
height = size.find('height')
result += filename.text + ' ' + width.text + ' ' + height.text
for obj in annotation.findall('./object'):
name = obj.find('name')
box = obj.find('bndbox')
label_index = CLASSES.index(name.text)
xmin = box.find('xmin')
ymin = box.find('ymin')
xmax = box.find('xmax')
ymax = box.find('ymax')
result += ' ' + str(label_index) + ' ' + xmin.text + ' ' + ymin.text + ' ' + xmax.text + ' ' + ymax.text
return result
def parseDir(path):
result = ""
for file in os.listdir(path):
if file.split('.')[-1] != 'xml':
continue
result += parseFile(path+'/'+file) + '\n'
return result
directory = input('Input directory, or 0 to exit: ')
if directory != '0':
result = parseDir(directory)
file = open(directory+'/'+'annotation.txt','w')
file.write(result)
file.close()
print("Complete!")
import os
import tensorflow as tf
all_path = '../data/annotation.txt'
train_path = '../data/train.txt'
val_path = '../data/val.txt'
test_path = '../data/test.txt'
allFile = open(all_path, 'r')
allFile_lines = allFile.readlines()
allFile.close()
dataset_size = len(allFile_lines)
train_size = int(0.7 * dataset_size)
val_size = int(0.15 * dataset_size)
test_size = int(0.15 * dataset_size)
full_dataset = tf.data.TextLineDataset(all_path)
full_dataset = full_dataset.shuffle(dataset_size)
train_dataset = full_dataset.take(train_size)
test_dataset = full_dataset.skip(train_size)
val_dataset = test_dataset.skip(test_size)
test_dataset = test_dataset.take(test_size)
train_dataset = list(train_dataset)
val_dataset = list(val_dataset)
test_dataset = list(test_dataset)
writer = open(train_path, 'w')
for data in train_dataset:
writer.write(data.numpy().decode('ascii') + '\n')
writer.close()
writer = open(val_path, 'w')
for data in val_dataset:
writer.write(data.numpy().decode('ascii') + '\n')
writer.close()
writer = open(test_path, 'w')
for data in test_dataset:
writer.write(data.numpy().decode('ascii') + '\n')
writer.close()
print('train dataset counts:', len(train_dataset))
print('validation dataset counts:', len(val_dataset))
print('test dataset counts:', len(test_dataset))
reader = open(train_path, 'r')
train_file = reader.readlines()
reader.close()
train_file.sort()
writer = open(train_path, 'w')
for i in range(len(train_file)):
writer.write(str(i) + ' ' + train_file[i])
writer.close()
reader = open(val_path, 'r')
val_file = reader.readlines()
reader.close()
val_file.sort()
writer = open(val_path, 'w')
for i in range(len(val_file)):
writer.write(str(i) + ' ' + val_file[i])
writer.close()
reader = open(test_path, 'r')
test_file = reader.readlines()
reader.close()
test_file.sort()
writer = open(test_path, 'w')
for i in range(len(test_file)):
writer.write(str(i) + ' ' + test_file[i])
writer.close()
\ No newline at end of file
This diff is collapsed. Click to expand it.
0 1618c8524c67549e809f54f7a0637834ee731d8c5b7818ddd3c5042b325557f3_06960.jpg 1920 1080 0 554 446 1339 1080 0 371 99 637 538 0 582 143 921 521
1 190711_155.jpg 1080 1080 0 97 28 1046 981
2 190711_207.jpg 587 626 0 98 8 506 623
3 190711_24.jpg 888 959 0 15 17 881 959
4 190711_280.jpg 910 1216 0 217 21 748 1216
5 190711_330.jpg 786 831 0 140 5 688 806
6 190711_348.jpg 781 652 0 41 87 773 569
7 190711_375.jpg 811 876 0 187 54 655 849
8 190711_64.jpg 1080 1080 0 5 164 819 1075
9 190711_67.jpg 551 626 0 1 49 512 613
10 190711_706.jpg 225 225 0 26 37 196 225
11 190711_736.jpg 183 169 0 8 5 175 161
12 190711_742.jpg 225 225 0 9 5 219 210
13 190711_8.jpg 635 617 0 47 61 561 585
14 190711_874.jpg 389 355 0 40 6 354 339
15 190723_10.jpg 250 188 0 47 4 184 171
16 190723_120.jpg 275 183 0 36 29 203 160
17 190723_164.jpg 232 217 0 26 17 212 217
18 190723_241.jpg 300 168 0 1 1 170 167
19 190723_279.jpg 220 147 0 66 13 182 141
20 190723_330.jpg 225 225 0 1 93 46 178 0 21 87 124 212 0 110 56 214 131 0 128 30 223 80
21 190723_354.jpg 275 183 0 47 40 234 172
22 190723_431.jpg 253 199 0 54 21 201 188
23 190723_495.jpg 225 225 0 85 79 212 180
24 190723_607.jpg 300 168 0 1 1 235 168
25 190723_612.jpg 275 183 0 94 22 211 178
26 190723_742.jpg 259 194 0 28 1 215 165
27 190723_758.jpg 299 168 0 80 7 229 146
28 190814_37.jpg 244 206 0 29 2 225 203
29 190814_434.jpg 275 183 0 135 60 264 121
30 190814_458.jpg 263 191 0 80 27 218 169 0 208 1 261 59
31 190814_482.jpg 198 255 0 1 56 149 214
32 190814_606.jpg 275 183 0 35 24 158 181
33 190814_654.jpg 206 245 0 40 61 128 228
34 190814_680.jpg 311 162 0 175 23 281 155
35 190814_690.jpg 275 183 0 4 35 273 159
36 190814_736.jpg 275 183 0 109 13 251 180
37 190814_779.jpg 184 274 0 10 17 161 261
38 190814_786.jpg 300 168 0 30 36 111 167
39 190814_798.jpg 225 225 0 3 7 153 225
40 190902_148.jpg 298 169 0 8 43 291 156
41 190902_175.jpg 260 194 0 27 57 235 127
42 190902_198.jpg 303 166 0 1 17 281 155
43 190902_210.jpg 300 168 0 63 20 292 153
44 190902_260.jpg 711 400 0 44 72 668 334
45 190925_171.jpg 3120 3120 0 666 980 2103 2271
46 190927_1048.jpg 1080 810 0 219 4 767 804
47 190927_1135.jpg 1080 1079 0 4 311 262 859 0 212 295 510 528 0 202 451 480 703 0 526 379 990 653
48 190927_1234.jpg 1080 1080 0 304 393 785 865
49 190927_1242.jpg 679 679 0 10 96 648 572
50 190927_1331.jpg 1080 1080 0 282 378 838 821
51 190927_1366.jpg 1080 1350 0 292 117 725 501 0 64 711 856 1344
52 190927_1377.jpg 1080 1080 0 62 361 846 1059 0 296 7 835 306
53 190927_1403.jpg 1080 1080 0 20 173 1051 1034
54 190927_1478.jpg 1080 1080 0 41 293 727 1040
55 190927_284.jpg 1080 1350 0 190 566 454 813
56 190927_322.jpg 1080 1080 0 168 37 812 987
57 190927_325.jpg 1080 1350 0 160 7 851 1350
58 190927_370.jpg 1080 1350 0 256 236 933 1058
59 190927_536.jpg 1080 1080 0 10 229 904 953
60 190927_63.jpg 1080 1081 0 262 66 901 819
61 190927_690.jpg 1080 1080 0 48 89 1029 1059
62 190927_842.jpg 540 540 0 255 130 508 377
63 190927_868.jpg 1080 1080 0 312 82 655 1000
64 190927_869.jpg 1080 1080 0 18 300 940 907
65 24830bc00964f17f9829b0c088856a233c9997f1d919a449709543228d0f4de2_05175.jpg 1920 1080 0 501 279 1234 832
66 2ca29ac644be58d8a23946e575425386d651f9f0612ffa3b7dec11d655336418_09900.jpg 1920 1080 0 696 474 834 643
67 401c9777cb1edad6fddb28ec3daca84abcf99928f22c6ad5b6ada4b03683cc4f_01920.jpg 1920 1080 0 390 185 926 721 0 1584 7 1920 1034
68 401c9777cb1edad6fddb28ec3daca84abcf99928f22c6ad5b6ada4b03683cc4f_02490.jpg 1920 1080 0 482 343 918 960 0 912 290 1920 1077
69 440028124bb2f30c7f1e025010f2a89c1e575061d2d0e5c826cc37ef9806f37a_02460.jpg 1280 720 0 1028 396 1191 514
70 5efc213b50083c042da0aee7e374f83052d8b83d781cd468473e35f5908237f2_05460.jpg 1280 720 0 460 1 1017 720
71 68912cf632d7bc73a845968d54e6e5ada41cd1691297921f9658a4b85d5293ee_06120.jpg 1920 1080 0 32 7 1468 907
72 6b9b420b60cdd5f411a0bd3a73749960db54c57138602c32db57aa5132d57e66_29415.jpg 1920 1080 0 765 268 1540 679
73 6fe6e07ac0f90bb9fce241083dca8671ff2ae18752471f2eec3572059d3c8de0_11400.jpg 1920 1080 0 565 107 971 879
74 6fe6e07ac0f90bb9fce241083dca8671ff2ae18752471f2eec3572059d3c8de0_12135.jpg 1920 1080 0 576 7 1653 1080
75 bfb7f11afc2aa2329aa5b1608ebf0b73064800b0b67a850057364cbae205c4a2_18855.jpg 1920 1080 0 808 258 1373 897
76 c2bafb4bde21aba787f447d1f39365db4949c8bdfd04906d58293c703b9832d7_13920.jpg 1920 1080 0 946 313 1388 849
77 c929ea1f6b228579298782cb55a55471cd398d3d00d0c4bc1022e62b7536278e_00960.jpg 1920 1080 0 8 289 918 974 0 633 581 1093 966 0 908 406 1766 945
78 dee867499ad03c3a009cbf782d2130a21941f00f8b69166ae2ac2c194e9f808f_04725.jpg 1920 1080 0 693 287 1035 941
79 fb7accfff8c6f8ea9b03c91ee5576d0d08080e9ba35918d801aaeb6020dbc88c_04740.jpg 1280 720 0 417 114 758 720
This diff is collapsed. Click to expand it.
0 047b783c16b8b43d7a8034afb6feaaa5ff995a6ffd5b91d63cf24242c3353704_05730.jpg 1920 1080 0 804 246 1271 732
1 184053a95825defe28e5a60f4d62f82841944cb5ffa11b8e1b07402a297fbe43_05670.jpg 1920 1080 0 1207 313 1873 760 0 318 210 1121 907
2 190711_115.jpg 426 458 0 29 18 414 452
3 190711_195.jpg 856 982 0 254 42 645 934
4 190711_276.jpg 772 798 0 101 38 714 778
5 190711_292.jpg 1080 1080 0 335 231 738 1003
6 190711_380.jpg 1080 1349 0 83 397 842 1349
7 190711_75.jpg 1036 901 0 46 89 992 901
8 190711_798.jpg 267 400 0 77 113 260 385
9 190711_806.jpg 600 400 0 185 91 398 366
10 190711_822.jpg 183 175 0 33 24 144 152
11 190711_858.jpg 598 400 0 90 2 398 400
12 190711_884.jpg 351 400 0 37 73 319 354
13 190711_894.jpg 600 400 0 207 14 528 400
14 190723_103.jpg 198 254 0 13 14 191 251
15 190723_126.jpg 284 177 0 6 71 63 160 0 50 44 114 155 0 108 50 172 164 0 155 55 222 160 0 215 82 279 162
16 190723_127.jpg 225 225 0 24 15 212 218
17 190723_151.jpg 251 201 0 68 25 205 175
18 190723_204.jpg 264 191 0 81 10 221 128
19 190723_254.jpg 275 183 0 135 6 245 97
20 190723_28.jpg 225 225 0 18 18 201 178
21 190723_280.jpg 259 194 0 41 93 116 194
22 190723_320.jpg 211 239 0 1 9 211 234
23 190723_367.jpg 284 177 0 151 3 263 177
24 190723_402.jpg 225 225 0 19 4 197 225
25 190723_44.jpg 275 183 0 78 33 214 162
26 190723_473.jpg 300 168 0 94 42 196 136
27 190723_484.jpg 275 183 0 1 1 201 176
28 190814_119.jpg 200 252 0 98 149 122 182
29 190814_184.jpg 272 185 0 59 59 177 119
30 190814_235.jpg 266 189 0 9 1 242 189
31 190814_308.jpg 300 168 0 85 2 267 168
32 190814_32.jpg 183 275 0 5 6 166 275
33 190814_327.jpg 275 183 0 67 10 241 177
34 190814_364.jpg 259 194 0 26 45 213 170
35 190814_411.jpg 258 195 0 9 36 245 184
36 190814_459.jpg 275 183 0 21 55 229 147
37 190814_475.jpg 275 183 0 26 6 234 163
38 190814_525.jpg 275 183 0 87 94 275 183
39 190814_61.jpg 266 189 0 40 55 141 136
40 190814_7.jpg 275 183 0 1 10 272 138
41 190814_809.jpg 225 225 0 7 56 153 184
42 190814_840.jpg 225 224 0 88 95 221 218
43 190902_103.jpg 279 180 0 3 6 264 159
44 190902_136.jpg 220 230 0 68 93 159 154
45 190902_142.jpg 262 193 0 1 25 226 158
46 190902_188.jpg 269 188 0 49 23 263 186
47 190902_220.jpg 308 164 0 32 8 83 93 0 38 68 137 128 0 39 113 132 164 0 222 5 282 107
48 190902_240.jpg 762 400 0 64 150 613 308
49 190902_355.jpg 316 160 0 10 1 147 157 0 161 20 314 150
50 190902_677.jpg 238 212 0 12 32 226 200
51 190902_75.jpg 259 194 0 16 24 131 184 0 104 30 224 186
52 190927_1035.jpg 1080 1080 0 209 387 648 818
53 190927_1110.jpg 1080 1080 0 196 401 515 811
54 190927_114.jpg 1080 810 0 72 3 884 756
55 190927_1206.jpg 1080 1079 0 88 182 823 714
56 190927_1333.jpg 1080 1080 0 162 103 770 778
57 190927_1441.jpg 1080 809 0 6 45 1046 788
58 190927_1457.jpg 1080 1303 0 182 133 947 1146
59 190927_1462.jpg 1079 1080 0 348 42 670 595
60 190927_298.jpg 1080 1080 0 134 115 1080 958
61 190927_344.jpg 1080 1080 0 101 236 884 800
62 190927_466.jpg 1080 1080 0 195 129 1051 1025
63 190927_616.jpg 1080 1080 0 7 161 1080 999
64 190927_660.jpg 1080 1080 0 57 186 916 934
65 190927_708.jpg 1080 1080 0 295 495 855 1029
66 190927_850.jpg 723 903 0 4 273 723 898
67 190927_880.jpg 1080 810 0 283 91 882 761
68 327e75afa16d748aa464f9011ca2bfe7003015ea25e7e43d98ce55661b9daaed_02115.jpg 1920 1080 0 851 196 1223 777
69 55225c5ddb1c54677d4140e9d24d2d1fd228e93c63dd1380c033315635c66412_00180.jpg 1920 1080 0 487 410 1318 926
70 55225c5ddb1c54677d4140e9d24d2d1fd228e93c63dd1380c033315635c66412_00915.jpg 1920 1080 0 1018 307 1368 846
71 5efc213b50083c042da0aee7e374f83052d8b83d781cd468473e35f5908237f2_10980.jpg 1280 720 0 645 447 1280 715 0 686 1 1212 328
72 5efc213b50083c042da0aee7e374f83052d8b83d781cd468473e35f5908237f2_16680.jpg 1280 720 0 274 195 406 327 0 643 166 723 246 0 474 125 540 191
73 5f1bc79f79605a6fc79df4634ea8d4a185f55f57b939109ecb8d52cea069a80a_08760.jpg 1920 1080 0 693 1 1071 285 0 76 49 587 513 0 574 243 1121 627 0 79 665 537 1080 0 532 574 934 993 0 990 435 1290 860 0 709 693 1157 1052 0 1059 882 1832 1080 0 1287 424 1621 1049 0 1582 407 1920 972
74 6b9b420b60cdd5f411a0bd3a73749960db54c57138602c32db57aa5132d57e66_25905.jpg 1920 1080 0 682 43 1168 768
75 6b9b420b60cdd5f411a0bd3a73749960db54c57138602c32db57aa5132d57e66_28815.jpg 1920 1080 0 137 40 1448 746
76 6fe6e07ac0f90bb9fce241083dca8671ff2ae18752471f2eec3572059d3c8de0_14130.jpg 1920 1080 0 687 188 1032 893
77 aae127339c7e733ae5fb9c22cb33ae018d8d03f784df88d5a231924d8c2f7469_02910.jpg 1920 1080 0 721 118 1158 674
78 c2bafb4bde21aba787f447d1f39365db4949c8bdfd04906d58293c703b9832d7_09120.jpg 1920 1080 0 154 120 1126 1080 0 343 160 616 547 0 1173 133 1356 672
79 e4d6ed9893f49041f0cbd21567ab425ef1e4dff1366bc04597d1dc0d45acda17_08535.jpg 1280 720 0 268 66 390 245 0 350 93 438 243 0 476 47 616 214
80 ed5c59e9609087510c5336cede23fbc0e54b3e1787f49024db8cd1a94fb1faa4_26280.jpg 1920 1080 0 602 181 1233 1076 0 989 231 1318 891
81 fb7accfff8c6f8ea9b03c91ee5576d0d08080e9ba35918d801aaeb6020dbc88c_03225.jpg 1920 1080 0 487 328 1056 847 0 1029 97 1275 343