Commit 101b7f49 authored by Oksana Belyaeva's avatar Oksana Belyaeva
Browse files

added coco-api and did refactoring

parent 36500237
,ox,ox-Precision-3630-Tower,02.12.2019 15:47,file:///home/ox/.config/libreoffice/4;
\ No newline at end of file
filename,height,width,class,xmin,ymin,xmax,ymax
23.jpeg,2339,1653,text,699,105,1036,169
23.jpeg,2339,1653,text,179,145,1556,622
23.jpeg,2339,1653,text,479,632,1246,709
23.jpeg,2339,1653,text,149,682,1566,2082
23.jpeg,2339,1653,text,162,2149,402,2205
23.jpeg,2339,1653,text,719,2149,979,2225
23.jpeg,2339,1653,text,1339,2159,1532,2215
14.jpeg,2338,1653,text,212,52,1526,165
14.jpeg,2338,1653,text,122,145,1606,1675
14.jpeg,2338,1653,text,636,1665,1076,1719
14.jpeg,2338,1653,text,126,1709,1609,2132
14.jpeg,2338,1653,text,122,2142,479,2192
14.jpeg,2338,1653,text,1396,2142,1589,2202
19.jpeg,2339,1655,table,183,29,1590,359
19.jpeg,2339,1655,text,180,335,1520,969
19.jpeg,2339,1655,text,193,1032,547,1092
19.jpeg,2339,1655,text,237,1119,1447,1232
19.jpeg,2339,1655,text,290,1269,1480,1379
19.jpeg,2339,1655,text,290,1469,1483,1589
1.jpeg,2339,3309,table,352,209,1604,747
1.jpeg,2339,3309,text,467,132,1489,184
1.jpeg,2339,3309,table,1779,67,3287,1189
1.jpeg,2339,3309,text,332,1899,1654,2022
1.jpeg,2339,3309,text,397,1492,1572,1642
1.jpeg,2339,3309,text,392,1657,834,1717
1.jpeg,2339,3309,text,1772,1717,2429,1829
21.jpeg,2339,1653,table,199,122,1606,1199
21.jpeg,2339,1653,text,192,1195,1539,1512
21.jpeg,2339,1653,text,186,1595,349,1639
21.jpeg,2339,1653,text,182,1709,566,1769
21.jpeg,2339,1653,text,1219,1609,1492,1659
21.jpeg,2339,1653,text,1259,1725,1489,1779
5.jpeg,2339,1653,table,166,152,1602,2179
5.jpeg,2339,1653,text,419,122,1372,185
13.jpeg,2338,1653,text,136,55,396,115
13.jpeg,2338,1653,text,136,142,576,219
13.jpeg,2338,1653,text,132,239,566,309
13.jpeg,2338,1653,figure,112,285,496,625
13.jpeg,2338,1653,text,519,445,652,495
13.jpeg,2338,1653,text,1112,55,1419,119
13.jpeg,2338,1653,text,939,159,1592,399
13.jpeg,2338,1653,text,559,962,1152,1029
13.jpeg,2338,1653,text,192,1035,1486,1152
13.jpeg,2338,1653,text,612,1912,1089,1979
13.jpeg,2338,1653,text,132,2149,482,2199
13.jpeg,2338,1653,text,1392,2145,1586,2199
6.jpeg,2339,1653,text,336,115,1482,235
6.jpeg,2339,1653,text,272,229,1566,312
6.jpeg,2339,1653,table,174,314,1599,839
6.jpeg,2339,1653,text,229,849,1597,904
6.jpeg,2339,1653,text,702,924,1077,984
6.jpeg,2339,1653,text,167,1019,1609,2162
6.jpeg,2339,1653,text,852,2207,1354,2277
18.jpeg,2339,1655,text,1027,55,1527,372
18.jpeg,2339,1655,text,577,329,977,399
18.jpeg,2339,1655,text,200,389,1507,622
18.jpeg,2339,1655,table,180,595,1603,2089
26.jpeg,2339,1653,text,172,89,1556,475
26.jpeg,2339,1653,table,169,482,1542,2152
26.jpeg,2339,1653,text,152,2139,426,2199
26.jpeg,2339,1653,text,726,2139,966,2209
26.jpeg,2339,1653,text,1332,2155,1536,2205
4.jpeg,2325,1653,table,132,330,1539,1200
4.jpeg,2325,1653,text,148,235,1522,313
4.jpeg,2325,1653,text,372,173,1302,219
4.jpeg,2325,1653,text,164,1203,1524,1267
4.jpeg,2325,1653,text,194,1321,626,1389
4.jpeg,2325,1653,text,194,1405,658,1479
4.jpeg,2325,1653,text,198,1515,448,1553
4.jpeg,2325,1653,text,1240,1329,1382,1369
4.jpeg,2325,1653,text,1228,1409,1404,1457
3.jpeg,2339,3309,figure,280,159,3037,2229
9.jpeg,2340,1654,figure,664,80,1072,270
9.jpeg,2340,1654,text,127,280,1377,325
9.jpeg,2340,1654,text,153,318,1479,366
9.jpeg,2340,1654,text,487,364,1237,410
9.jpeg,2340,1654,text,743,536,943,576
9.jpeg,2340,1654,text,461,572,1227,626
9.jpeg,2340,1654,text,107,634,1315,760
9.jpeg,2340,1654,text,101,772,439,822
9.jpeg,2340,1654,text,103,814,375,854
9.jpeg,2340,1654,text,103,848,1579,996
9.jpeg,2340,1654,text,103,1020,511,1068
9.jpeg,2340,1654,text,101,1060,1577,1136
9.jpeg,2340,1654,text,101,1158,313,1206
9.jpeg,2340,1654,text,97,1202,1583,1506
9.jpeg,2340,1654,text,97,1514,287,1558
9.jpeg,2340,1654,text,95,1548,1133,1602
9.jpeg,2340,1654,text,95,1618,569,1668
9.jpeg,2340,1654,text,95,1652,327,1698
9.jpeg,2340,1654,text,93,1724,385,1772
9.jpeg,2340,1654,text,93,1788,387,1846
9.jpeg,2340,1654,text,1271,1728,1485,1780
9.jpeg,2340,1654,text,1273,1800,1491,1850
9.jpeg,2340,1654,text,89,1864,819,1922
22.jpeg,2339,1653,text,426,79,1262,139
22.jpeg,2339,1653,text,212,175,1499,372
22.jpeg,2339,1653,text,1106,442,1369,485
22.jpeg,2339,1653,text,959,479,1522,545
22.jpeg,2339,1653,text,1226,565,1542,632
22.jpeg,2339,1653,text,1392,652,1536,702
22.jpeg,2339,1653,text,359,859,1372,939
22.jpeg,2339,1653,text,519,955,1222,1059
22.jpeg,2339,1653,text,339,1352,1422,1502
22.jpeg,2339,1653,text,749,1489,1012,1539
22.jpeg,2339,1653,text,339,1785,1452,1875
22.jpeg,2339,1653,text,496,1885,1296,1925
22.jpeg,2339,1653,text,822,2175,979,2232
7.jpeg,2339,1653,text,162,102,1609,729
7.jpeg,2339,1653,text,162,827,1612,1069
7.jpeg,2339,1653,text,462,1161,926,1225
7.jpeg,2339,1653,text,430,1293,1470,1349
7.jpeg,2339,1653,text,168,1377,1609,2169
7.jpeg,2339,1653,text,866,2213,1360,2271
2.jpeg,2339,3309,figure,244,79,3204,2265
17.jpeg,2338,1653,text,136,49,1592,165
17.jpeg,2338,1653,text,446,149,1279,209
17.jpeg,2338,1653,text,139,195,1459,295
17.jpeg,2338,1653,text,136,292,1576,429
17.jpeg,2338,1653,text,136,419,1599,695
17.jpeg,2338,1653,text,182,682,1576,785
17.jpeg,2338,1653,text,122,772,1602,2102
17.jpeg,2338,1653,text,152,2145,502,2205
17.jpeg,2338,1653,text,1412,2149,1592,2199
12.jpeg,2339,3309,figure,234,59,3224,1122
12.jpeg,2339,3309,table,260,1152,1750,1492
12.jpeg,2339,3309,text,894,1105,1137,1155
12.jpeg,2339,3309,table,667,1522,1410,2282
12.jpeg,2339,3309,text,894,1482,1197,1535
12.jpeg,2339,3309,text,1804,1042,3250,1852
16.jpeg,2338,1653,text,142,52,1592,252
16.jpeg,2338,1653,text,746,245,986,299
16.jpeg,2338,1653,text,129,289,1599,782
16.jpeg,2338,1653,text,136,1052,1599,1235
16.jpeg,2338,1653,text,236,1222,1472,1275
16.jpeg,2338,1653,text,369,1262,1369,1325
16.jpeg,2338,1653,text,136,1312,1599,1412
16.jpeg,2338,1653,text,232,1405,1506,1455
16.jpeg,2338,1653,text,149,1442,1599,1589
16.jpeg,2338,1653,text,182,1592,1579,1809
16.jpeg,2338,1653,text,139,1802,1579,2129
16.jpeg,2338,1653,text,146,2145,489,2192
16.jpeg,2338,1653,text,1406,2139,1589,2199
16.jpeg,2338,1653,text,129,772,1532,1052
10.jpeg,2339,1654,text,865,95,915,139
10.jpeg,2339,1654,text,150,157,1613,1349
10.jpeg,2339,1654,text,633,1341,1145,1391
10.jpeg,2339,1654,text,179,1381,897,2042
10.jpeg,2339,1654,text,891,1385,1561,1963
10.jpeg,2339,1654,text,177,2063,899,2151
10.jpeg,2339,1654,text,897,2057,1561,2153
24.jpeg,2339,1653,text,166,85,1562,1739
24.jpeg,2339,1653,text,416,1759,1289,1822
24.jpeg,2339,1653,text,166,1802,1549,2129
24.jpeg,2339,1653,text,172,2145,416,2202
24.jpeg,2339,1653,text,732,2149,969,2209
24.jpeg,2339,1653,text,1332,2155,1532,2205
20.jpeg,2339,1653,table,192,719,1596,2142
20.jpeg,2339,1653,text,1239,135,1529,195
20.jpeg,2339,1653,text,1229,245,1519,302
20.jpeg,2339,1653,text,1356,322,1532,372
20.jpeg,2339,1653,text,626,422,966,482
20.jpeg,2339,1653,text,216,469,1502,682
20.jpeg,2339,1653,text,186,692,1259,752
15.jpeg,2338,1653,text,119,49,1596,1765
15.jpeg,2338,1653,text,679,1752,1036,1815
15.jpeg,2338,1653,text,126,1799,1589,2079
15.jpeg,2338,1653,text,132,2142,479,2199
15.jpeg,2338,1653,text,1402,2145,1579,2209
11.jpeg,2339,1656,table,148,462,1555,1914
11.jpeg,2339,1656,text,530,217,1183,282
11.jpeg,2339,1656,text,733,342,1265,394
11.jpeg,2339,1656,text,855,384,1148,429
8.jpeg,2339,1653,text,167,119,1607,259
8.jpeg,2339,1653,text,262,289,1559,359
8.jpeg,2339,1653,text,259,389,1164,454
8.jpeg,2339,1653,table,208,481,1576,891
8.jpeg,2339,1653,text,180,875,712,1009
8.jpeg,2339,1653,text,584,1007,1258,1059
8.jpeg,2339,1653,text,168,1079,1608,1201
8.jpeg,2339,1653,text,222,1209,1439,1285
8.jpeg,2339,1653,text,164,1367,1612,2082
8.jpeg,2339,1653,text,868,2213,1342,2273
8.jpeg,2339,1653,text,222,1295,1062,1349
25.jpeg,2339,1653,text,166,79,1542,2129
25.jpeg,2339,1653,text,169,2155,429,2205
25.jpeg,2339,1653,text,722,2149,972,2205
25.jpeg,2339,1653,text,1339,2152,1539,2202
filename,height,width,class,xmin,ymin,xmax,ymax
23.jpeg,2339,1653,text,699,105,1036,169
23.jpeg,2339,1653,text,179,145,1556,622
23.jpeg,2339,1653,text,479,632,1246,709
23.jpeg,2339,1653,text,149,682,1566,2082
23.jpeg,2339,1653,text,162,2149,402,2205
23.jpeg,2339,1653,text,719,2149,979,2225
23.jpeg,2339,1653,text,1339,2159,1532,2215
14.jpeg,2338,1653,text,212,52,1526,165
14.jpeg,2338,1653,text,122,145,1606,1675
14.jpeg,2338,1653,text,636,1665,1076,1719
14.jpeg,2338,1653,text,126,1709,1609,2132
14.jpeg,2338,1653,text,122,2142,479,2192
14.jpeg,2338,1653,text,1396,2142,1589,2202
19.jpeg,2339,1655,table,183,29,1590,359
19.jpeg,2339,1655,text,180,335,1520,969
19.jpeg,2339,1655,text,193,1032,547,1092
19.jpeg,2339,1655,text,237,1119,1447,1232
19.jpeg,2339,1655,text,290,1269,1480,1379
19.jpeg,2339,1655,text,290,1469,1483,1589
1.jpeg,2339,3309,table,352,209,1604,747
1.jpeg,2339,3309,text,467,132,1489,184
1.jpeg,2339,3309,table,1779,67,3287,1189
1.jpeg,2339,3309,text,332,1899,1654,2022
1.jpeg,2339,3309,text,397,1492,1572,1642
1.jpeg,2339,3309,text,392,1657,834,1717
1.jpeg,2339,3309,text,1772,1717,2429,1829
21.jpeg,2339,1653,table,199,122,1606,1199
21.jpeg,2339,1653,text,192,1195,1539,1512
21.jpeg,2339,1653,text,186,1595,349,1639
21.jpeg,2339,1653,text,182,1709,566,1769
21.jpeg,2339,1653,text,1219,1609,1492,1659
21.jpeg,2339,1653,text,1259,1725,1489,1779
5.jpeg,2339,1653,table,166,152,1602,2179
5.jpeg,2339,1653,text,419,122,1372,185
13.jpeg,2338,1653,text,136,55,396,115
13.jpeg,2338,1653,text,136,142,576,219
13.jpeg,2338,1653,text,132,239,566,309
13.jpeg,2338,1653,figure,112,285,496,625
13.jpeg,2338,1653,text,519,445,652,495
13.jpeg,2338,1653,text,1112,55,1419,119
13.jpeg,2338,1653,text,939,159,1592,399
13.jpeg,2338,1653,text,559,962,1152,1029
13.jpeg,2338,1653,text,192,1035,1486,1152
13.jpeg,2338,1653,text,612,1912,1089,1979
13.jpeg,2338,1653,text,132,2149,482,2199
13.jpeg,2338,1653,text,1392,2145,1586,2199
6.jpeg,2339,1653,text,336,115,1482,235
6.jpeg,2339,1653,text,272,229,1566,312
6.jpeg,2339,1653,table,174,314,1599,839
6.jpeg,2339,1653,text,229,849,1597,904
6.jpeg,2339,1653,text,702,924,1077,984
6.jpeg,2339,1653,text,167,1019,1609,2162
6.jpeg,2339,1653,text,852,2207,1354,2277
18.jpeg,2339,1655,text,1027,55,1527,372
18.jpeg,2339,1655,text,577,329,977,399
18.jpeg,2339,1655,text,200,389,1507,622
18.jpeg,2339,1655,table,180,595,1603,2089
26.jpeg,2339,1653,text,172,89,1556,475
26.jpeg,2339,1653,table,169,482,1542,2152
26.jpeg,2339,1653,text,152,2139,426,2199
26.jpeg,2339,1653,text,726,2139,966,2209
26.jpeg,2339,1653,text,1332,2155,1536,2205
4.jpeg,2325,1653,table,132,330,1539,1200
4.jpeg,2325,1653,text,148,235,1522,313
4.jpeg,2325,1653,text,372,173,1302,219
4.jpeg,2325,1653,text,164,1203,1524,1267
4.jpeg,2325,1653,text,194,1321,626,1389
4.jpeg,2325,1653,text,194,1405,658,1479
4.jpeg,2325,1653,text,198,1515,448,1553
4.jpeg,2325,1653,text,1240,1329,1382,1369
4.jpeg,2325,1653,text,1228,1409,1404,1457
3.jpeg,2339,3309,figure,280,159,3037,2229
9.jpeg,2340,1654,figure,664,80,1072,270
9.jpeg,2340,1654,text,127,280,1377,325
9.jpeg,2340,1654,text,153,318,1479,366
9.jpeg,2340,1654,text,487,364,1237,410
9.jpeg,2340,1654,text,743,536,943,576
9.jpeg,2340,1654,text,461,572,1227,626
9.jpeg,2340,1654,text,107,634,1315,760
9.jpeg,2340,1654,text,101,772,439,822
9.jpeg,2340,1654,text,103,814,375,854
9.jpeg,2340,1654,text,103,848,1579,996
9.jpeg,2340,1654,text,103,1020,511,1068
9.jpeg,2340,1654,text,101,1060,1577,1136
9.jpeg,2340,1654,text,101,1158,313,1206
9.jpeg,2340,1654,text,97,1202,1583,1506
9.jpeg,2340,1654,text,97,1514,287,1558
9.jpeg,2340,1654,text,95,1548,1133,1602
9.jpeg,2340,1654,text,95,1618,569,1668
9.jpeg,2340,1654,text,95,1652,327,1698
9.jpeg,2340,1654,text,93,1724,385,1772
9.jpeg,2340,1654,text,93,1788,387,1846
9.jpeg,2340,1654,text,1271,1728,1485,1780
9.jpeg,2340,1654,text,1273,1800,1491,1850
9.jpeg,2340,1654,text,89,1864,819,1922
22.jpeg,2339,1653,text,426,79,1262,139
22.jpeg,2339,1653,text,212,175,1499,372
22.jpeg,2339,1653,text,1106,442,1369,485
22.jpeg,2339,1653,text,959,479,1522,545
22.jpeg,2339,1653,text,1226,565,1542,632
22.jpeg,2339,1653,text,1392,652,1536,702
22.jpeg,2339,1653,text,359,859,1372,939
22.jpeg,2339,1653,text,519,955,1222,1059
22.jpeg,2339,1653,text,339,1352,1422,1502
22.jpeg,2339,1653,text,749,1489,1012,1539
22.jpeg,2339,1653,text,339,1785,1452,1875
22.jpeg,2339,1653,text,496,1885,1296,1925
22.jpeg,2339,1653,text,822,2175,979,2232
7.jpeg,2339,1653,text,162,102,1609,729
7.jpeg,2339,1653,text,162,827,1612,1069
7.jpeg,2339,1653,text,462,1161,926,1225
7.jpeg,2339,1653,text,430,1293,1470,1349
7.jpeg,2339,1653,text,168,1377,1609,2169
7.jpeg,2339,1653,text,866,2213,1360,2271
2.jpeg,2339,3309,figure,244,79,3204,2265
17.jpeg,2338,1653,text,136,49,1592,165
17.jpeg,2338,1653,text,446,149,1279,209
17.jpeg,2338,1653,text,139,195,1459,295
17.jpeg,2338,1653,text,136,292,1576,429
17.jpeg,2338,1653,text,136,419,1599,695
17.jpeg,2338,1653,text,182,682,1576,785
17.jpeg,2338,1653,text,122,772,1602,2102
17.jpeg,2338,1653,text,152,2145,502,2205
17.jpeg,2338,1653,text,1412,2149,1592,2199
12.jpeg,2339,3309,figure,234,59,3224,1122
12.jpeg,2339,3309,table,260,1152,1750,1492
12.jpeg,2339,3309,text,894,1105,1137,1155
12.jpeg,2339,3309,table,667,1522,1410,2282
12.jpeg,2339,3309,text,894,1482,1197,1535
12.jpeg,2339,3309,text,1804,1042,3250,1852
16.jpeg,2338,1653,text,142,52,1592,252
16.jpeg,2338,1653,text,746,245,986,299
16.jpeg,2338,1653,text,129,289,1599,782
16.jpeg,2338,1653,text,136,1052,1599,1235
16.jpeg,2338,1653,text,236,1222,1472,1275
16.jpeg,2338,1653,text,369,1262,1369,1325
16.jpeg,2338,1653,text,136,1312,1599,1412
16.jpeg,2338,1653,text,232,1405,1506,1455
16.jpeg,2338,1653,text,149,1442,1599,1589
16.jpeg,2338,1653,text,182,1592,1579,1809
16.jpeg,2338,1653,text,139,1802,1579,2129
16.jpeg,2338,1653,text,146,2145,489,2192
16.jpeg,2338,1653,text,1406,2139,1589,2199
16.jpeg,2338,1653,text,129,772,1532,1052
10.jpeg,2339,1654,text,865,95,915,139
10.jpeg,2339,1654,text,150,157,1613,1349
10.jpeg,2339,1654,text,633,1341,1145,1391
10.jpeg,2339,1654,text,179,1381,897,2042
10.jpeg,2339,1654,text,891,1385,1561,1963
10.jpeg,2339,1654,text,177,2063,899,2151
10.jpeg,2339,1654,text,897,2057,1561,2153
24.jpeg,2339,1653,text,166,85,1562,1739
24.jpeg,2339,1653,text,416,1759,1289,1822
24.jpeg,2339,1653,text,166,1802,1549,2129
24.jpeg,2339,1653,text,172,2145,416,2202
24.jpeg,2339,1653,text,732,2149,969,2209
24.jpeg,2339,1653,text,1332,2155,1532,2205
20.jpeg,2339,1653,table,192,719,1596,2142
20.jpeg,2339,1653,text,1239,135,1529,195
20.jpeg,2339,1653,text,1229,245,1519,302
20.jpeg,2339,1653,text,1356,322,1532,372
20.jpeg,2339,1653,text,626,422,966,482
20.jpeg,2339,1653,text,216,469,1502,682
20.jpeg,2339,1653,text,186,692,1259,752
15.jpeg,2338,1653,text,119,49,1596,1765
15.jpeg,2338,1653,text,679,1752,1036,1815
15.jpeg,2338,1653,text,126,1799,1589,2079
15.jpeg,2338,1653,text,132,2142,479,2199
15.jpeg,2338,1653,text,1402,2145,1579,2209
11.jpeg,2339,1656,table,148,462,1555,1914
11.jpeg,2339,1656,text,530,217,1183,282
11.jpeg,2339,1656,text,733,342,1265,394
11.jpeg,2339,1656,text,855,384,1148,429
8.jpeg,2339,1653,text,167,119,1607,259
8.jpeg,2339,1653,text,262,289,1559,359
8.jpeg,2339,1653,text,259,389,1164,454
8.jpeg,2339,1653,table,208,481,1576,891
8.jpeg,2339,1653,text,180,875,712,1009
8.jpeg,2339,1653,text,584,1007,1258,1059
8.jpeg,2339,1653,text,168,1079,1608,1201
8.jpeg,2339,1653,text,222,1209,1439,1285
8.jpeg,2339,1653,text,164,1367,1612,2082
8.jpeg,2339,1653,text,868,2213,1342,2273
8.jpeg,2339,1653,text,222,1295,1062,1349
25.jpeg,2339,1653,text,166,79,1542,2129
25.jpeg,2339,1653,text,169,2155,429,2205
25.jpeg,2339,1653,text,722,2149,972,2205
25.jpeg,2339,1653,text,1339,2152,1539,2202
# Adapted from
# https://github.com/datitran/raccoon_dataset/blob/master/generate_tfrecord.py
from __future__ import division
from __future__ import print_function
from __future__ import absolute_import
import os
import io
import pandas as pd
......@@ -14,14 +7,16 @@ from PIL import Image
from object_detection.utils import dataset_util
from collections import namedtuple, OrderedDict
# Add more class labels as needed, make sure to start at 1
def class_text_to_int(row_label):
if row_label == 'wPawn':
def class_text_to_int(row_label: str) -> int:
if row_label == 'text':
return 1
if row_label == 'bPawn':
return 2
if row_label == 'table':
return 2
if row_label == 'figure':
return 3
else:
print("unknown type")
None
def split(df, group):
......@@ -31,14 +26,16 @@ def split(df, group):
def create_tf_example(group, path):
print(group.filename)
with tf.gfile.GFile(os.path.join(path, '{}'.format(group.filename)), 'rb') as fid:
encoded_jpg = fid.read()
encoded_jpg_io = io.BytesIO(encoded_jpg)
image = Image.open(encoded_jpg_io)
width, height = image.size
filename = group.filename.encode('utf8')
image_format = b'jpg'
image_format = b'jpeg'
xmins = []
xmaxs = []
ymins = []
......@@ -47,11 +44,11 @@ def create_tf_example(group, path):
classes = []
for index, row in group.object.iterrows():
xmins.append(row['xmin'] / width)
xmaxs.append(row['xmax'] / width)
ymins.append(row['ymin'] / height)
ymaxs.append(row['ymax'] / height)
classes_text.append(row['class'].encode('utf8'))
xmins.append(max(0.0, row['xmin'] / width))
xmaxs.append(min(1.0, row['xmax'] / width))
ymins.append(max(0.0, row['ymin'] / height))
ymaxs.append(min(1.0, row['ymax'] / height))
classes_text.append('text'.encode('utf8') if row['class'] == 'list' else row['class'].encode('utf8')) # TODO for 4 class
classes.append(class_text_to_int(row['class']))
tf_example = tf.train.Example(features=tf.train.Features(feature={
......@@ -68,21 +65,30 @@ def create_tf_example(group, path):
'image/object/class/text': dataset_util.bytes_list_feature(classes_text),
'image/object/class/label': dataset_util.int64_list_feature(classes),
}))
return tf_example
def create_tf_record(name, writer):
path = os.path.join(os.getcwd(), 'images/' + name)
examples = pd.read_csv('csv/' + name + '.csv')
grouped = split(examples, 'filename')
for group in grouped:
tf_example = create_tf_example(group, path)
writer.write(tf_example.SerializeToString())
def main(_):
for i in ['test', 'train']:
writer = tf.python_io.TFRecordWriter(i+'.record')
path = os.path.join(os.getcwd(), 'images/'+i)
examples = pd.read_csv('data/'+i+'.csv')
grouped = split(examples, 'filename')
for group in grouped:
tf_example = create_tf_example(group, path)
writer.write(tf_example.SerializeToString())
writer.close()
print('Successfully created the '+i+ ' TFRecords')
writer = tf.python_io.TFRecordWriter('train-0_3cl.record')
for name in ['train-0']:
create_tf_record(name, writer)
print("create %s" % name)
writer.close()
print('Successfully created the train TFRecords')
#writer = tf.python_io.TFRecordWriter('test_3cl.record')
#create_tf_record('test', writer)
#writer.close()
#print('Successfully created the test TFRecords')
if __name__ == '__main__':
if __name__ == "__main__":
tf.app.run()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment