txt_to_csv.ipynb
29 KB
{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"name":"txt_to_csv.ipynb","provenance":[],"collapsed_sections":[],"authorship_tag":"ABX9TyPT1K4IOY1vTMZgFIbmKYN9"},"kernelspec":{"name":"python3","display_name":"Python 3"}},"cells":[{"cell_type":"code","metadata":{"id":"iOpoaOBDB2KO","colab_type":"code","outputId":"078842e2-8d14-4df0-87f4-69ed8db2bfab","executionInfo":{"status":"ok","timestamp":1591987217053,"user_tz":-540,"elapsed":27992,"user":{"displayName":"신아형[학생](소프트웨어융합대학 컴퓨터공학과)","photoUrl":"","userId":"02057930622140727302"}},"colab":{"base_uri":"https://localhost:8080/","height":127}},"source":["from google.colab import drive\n","drive.mount('/content/gdrive')"],"execution_count":1,"outputs":[{"output_type":"stream","text":["Go to this URL in a browser: https://accounts.google.com/o/oauth2/auth?client_id=947318989803-6bn6qk8qdgf4n4g3pfee6491hc0brc4i.apps.googleusercontent.com&redirect_uri=urn%3aietf%3awg%3aoauth%3a2.0%3aoob&response_type=code&scope=email%20https%3a%2f%2fwww.googleapis.com%2fauth%2fdocs.test%20https%3a%2f%2fwww.googleapis.com%2fauth%2fdrive%20https%3a%2f%2fwww.googleapis.com%2fauth%2fdrive.photos.readonly%20https%3a%2f%2fwww.googleapis.com%2fauth%2fpeopleapi.readonly\n","\n","Enter your authorization code:\n","··········\n","Mounted at /content/gdrive\n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"id":"rWXRAhmuB7xt","colab_type":"code","outputId":"a0953d4a-fd4c-425d-ba22-16605774b7a2","executionInfo":{"status":"ok","timestamp":1591987339468,"user_tz":-540,"elapsed":115010,"user":{"displayName":"신아형[학생](소프트웨어융합대학 컴퓨터공학과)","photoUrl":"","userId":"02057930622140727302"}},"colab":{"base_uri":"https://localhost:8080/","height":35}},"source":["# 학습에 사용할 어른 보행자 데이터셋 annotation파일(txt 파일)을 csv파일로 만듦(adult_train_labels.csv)\n","\n","import os\n","import glob\n","import pandas as pd\n","import argparse\n","import xml.etree.ElementTree as ET\n","\n","import csv\n","import re\n","\n","csv_file=open('/content/gdrive/My Drive/capstone/data/annotations/adult_train_labels.csv', \"a\") #저장 디렉토리\n","csv_file.write(\"filename, width, height, class, xmin, ymin, xmax, ymax\\n\")\n","wr = csv.writer(csv_file)\n","\n","csv_lst=[]\n","\n","path_dir='/content/gdrive/My Drive/capstone/data/images/adult_train_annotation/'\n","file_list=os.listdir(path_dir)\n","\n","\n","for file in file_list:\n"," file_dir=path_dir+file\n"," f = open(file_dir, 'r')\n","\n"," xmin=[]\n"," ymin=[]\n"," xmax=[]\n"," ymax=[]\n","\n"," while True:\n"," line=f.readline()\n","\n"," if not line:\n"," break\n","\n"," if 'Image filename' in line:\n"," filename=line.split('/')\n"," filename=filename[-1]\n"," filename=filename[:-5]+'jpg'\n","\n"," if 'Image size' in line:\n"," numbers=re.findall(\"\\d+\", line)\n"," width=numbers[0]\n"," height=numbers[1]\n","\n"," if 'Bounding box for object' in line:\n"," numbers=re.findall(\"\\d+\", line)\n"," xmin.append(numbers[1])\n"," ymin.append(numbers[2])\n"," xmax.append(numbers[3])\n"," ymax.append(numbers[4])\n","\n"," class_name='adult'\n"," \n"," size=len(xmin)\n"," #print(size)\n","\n"," lst=[]\n"," file_lst=[]\n"," for i in range(size):\n"," lst=[filename, width, height, class_name, xmin[i], ymin[i], xmax[i], ymax[i]]\n"," file_lst.append(lst) \n"," csv_lst.append(file_lst) \n"," f.close()\n","\n","for i in csv_lst:\n"," s=len(i)\n"," for j in range(s):\n"," wr.writerow(i[j])\n","\n","csv_file.close()\n","\n","print(\"Successfully converted txt to csv.\")"],"execution_count":2,"outputs":[{"output_type":"stream","text":["Successfully converted txt to csv.\n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"id":"nR67B6FY1Xos","colab_type":"code","colab":{"base_uri":"https://localhost:8080/","height":1000},"outputId":"78a5a73f-e307-4198-dd8d-cc31f222753a","executionInfo":{"status":"ok","timestamp":1591987366780,"user_tz":-540,"elapsed":4194,"user":{"displayName":"신아형[학생](소프트웨어융합대학 컴퓨터공학과)","photoUrl":"","userId":"02057930622140727302"}}},"source":["!cat /content/gdrive/My\\ Drive/capstone/data/annotations/adult_train_labels.csv"],"execution_count":3,"outputs":[{"output_type":"stream","text":["filename, width, height, class, xmin, ymin, xmax, ymax\n","FudanPed00001.jpg,559,536,adult,160,182,302,431\r\n","FudanPed00001.jpg,559,536,adult,420,171,535,486\r\n","FudanPed00002.jpg,455,414,adult,68,93,191,380\r\n","FudanPed00003.jpg,479,445,adult,293,135,447,421\r\n","FudanPed00004.jpg,396,397,adult,168,60,324,338\r\n","FudanPed00004.jpg,396,397,adult,9,61,48,180\r\n","FudanPed00005.jpg,335,344,adult,188,59,320,336\r\n","FudanPed00005.jpg,335,344,adult,2,53,40,158\r\n","FudanPed00006.jpg,385,426,adult,208,108,346,385\r\n","FudanPed00006.jpg,385,426,adult,2,108,87,384\r\n","FudanPed00007.jpg,539,381,adult,112,69,218,346\r\n","FudanPed00007.jpg,539,381,adult,378,76,529,377\r\n","FudanPed00007.jpg,539,381,adult,317,108,347,192\r\n","FudanPed00008.jpg,388,454,adult,228,158,370,436\r\n","FudanPed00008.jpg,388,454,adult,39,179,115,363\r\n","FudanPed00009.jpg,465,441,adult,306,138,453,430\r\n","FudanPed00009.jpg,465,441,adult,157,124,298,398\r\n","FudanPed00010.jpg,411,393,adult,281,90,401,374\r\n","FudanPed00011.jpg,459,420,adult,278,112,438,394\r\n","FudanPed00012.jpg,468,384,adult,159,71,295,361\r\n","FudanPed00012.jpg,468,384,adult,328,58,439,327\r\n","FudanPed00013.jpg,652,498,adult,389,193,554,476\r\n","FudanPed00014.jpg,456,383,adult,234,86,405,367\r\n","FudanPed00015.jpg,336,349,adult,19,43,174,327\r\n","FudanPed00016.jpg,544,425,adult,80,86,205,383\r\n","FudanPed00016.jpg,544,425,adult,279,94,400,361\r\n","FudanPed00016.jpg,544,425,adult,411,101,495,378\r\n","FudanPed00017.jpg,266,342,adult,115,48,244,332\r\n","FudanPed00018.jpg,253,323,adult,20,19,126,304\r\n","FudanPed00019.jpg,497,442,adult,7,135,142,389\r\n","FudanPed00019.jpg,497,442,adult,194,123,339,421\r\n","FudanPed00020.jpg,555,417,adult,339,99,508,381\r\n","FudanPed00021.jpg,490,378,adult,324,76,470,367\r\n","FudanPed00021.jpg,490,378,adult,234,93,268,167\r\n","FudanPed00021.jpg,490,378,adult,47,95,69,160\r\n","FudanPed00022.jpg,536,465,adult,112,169,209,449\r\n","FudanPed00022.jpg,536,465,adult,397,171,514,455\r\n","FudanPed00023.jpg,376,378,adult,202,84,341,366\r\n","FudanPed00024.jpg,479,378,adult,103,84,270,370\r\n","FudanPed00025.jpg,425,369,adult,226,69,396,354\r\n","FudanPed00025.jpg,425,369,adult,44,87,94,256\r\n","FudanPed00025.jpg,425,369,adult,128,74,189,262\r\n","FudanPed00025.jpg,425,369,adult,180,53,228,255\r\n","FudanPed00025.jpg,425,369,adult,213,73,273,262\r\n","FudanPed00025.jpg,425,369,adult,314,62,383,266\r\n","FudanPed00026.jpg,440,427,adult,44,78,150,389\r\n","FudanPed00026.jpg,440,427,adult,185,89,279,373\r\n","FudanPed00027.jpg,302,363,adult,104,45,253,328\r\n","FudanPed00028.jpg,317,345,adult,7,16,149,303\r\n","FudanPed00028.jpg,317,345,adult,186,18,316,321\r\n","FudanPed00029.jpg,435,404,adult,246,72,368,351\r\n","FudanPed00030.jpg,462,387,adult,59,85,208,375\r\n","FudanPed00031.jpg,569,430,adult,298,122,444,408\r\n","FudanPed00032.jpg,608,474,adult,456,162,573,453\r\n","FudanPed00033.jpg,396,357,adult,165,53,304,346\r\n","FudanPed00034.jpg,309,351,adult,111,37,254,330\r\n","FudanPed00035.jpg,292,349,adult,64,39,195,331\r\n","FudanPed00036.jpg,1017,444,adult,131,98,279,394\r\n","FudanPed00036.jpg,1017,444,adult,802,120,937,381\r\n","FudanPed00036.jpg,1017,444,adult,244,133,330,363\r\n","FudanPed00036.jpg,1017,444,adult,726,145,789,345\r\n","FudanPed00037.jpg,423,361,adult,259,63,415,349\r\n","FudanPed00037.jpg,423,361,adult,190,98,209,170\r\n","FudanPed00038.jpg,422,346,adult,219,44,400,331\r\n","FudanPed00039.jpg,493,487,adult,137,137,199,311\r\n","FudanPed00039.jpg,493,487,adult,231,130,331,410\r\n","FudanPed00040.jpg,550,482,adult,201,157,279,437\r\n","FudanPed00040.jpg,550,482,adult,279,172,377,430\r\n","FudanPed00041.jpg,552,507,adult,351,161,439,437\r\n","FudanPed00041.jpg,552,507,adult,284,181,357,439\r\n","FudanPed00041.jpg,552,507,adult,42,186,110,388\r\n","FudanPed00042.jpg,588,547,adult,159,186,250,470\r\n","FudanPed00042.jpg,588,547,adult,288,156,392,449\r\n","FudanPed00043.jpg,493,518,adult,64,139,147,426\r\n","FudanPed00043.jpg,493,518,adult,156,139,248,435\r\n","FudanPed00043.jpg,493,518,adult,261,128,358,431\r\n","FudanPed00044.jpg,521,494,adult,246,170,340,462\r\n","FudanPed00044.jpg,521,494,adult,337,175,426,464\r\n","FudanPed00044.jpg,521,494,adult,37,129,181,492\r\n","FudanPed00044.jpg,521,494,adult,436,157,501,402\r\n","FudanPed00045.jpg,487,538,adult,198,198,294,481\r\n","FudanPed00045.jpg,487,538,adult,319,201,404,499\r\n","FudanPed00045.jpg,487,538,adult,395,212,469,495\r\n","FudanPed00046.jpg,567,438,adult,178,123,271,410\r\n","FudanPed00046.jpg,567,438,adult,299,114,370,335\r\n","FudanPed00046.jpg,567,438,adult,446,104,507,315\r\n","FudanPed00046.jpg,567,438,adult,521,119,565,258\r\n","FudanPed00047.jpg,472,520,adult,272,198,371,482\r\n","FudanPed00047.jpg,472,520,adult,31,195,90,427\r\n","FudanPed00047.jpg,472,520,adult,384,185,430,298\r\n","FudanPed00048.jpg,585,559,adult,6,242,84,535\r\n","FudanPed00048.jpg,585,559,adult,79,231,144,455\r\n","FudanPed00048.jpg,585,559,adult,158,219,251,507\r\n","FudanPed00048.jpg,585,559,adult,460,263,580,544\r\n","FudanPed00049.jpg,447,512,adult,127,123,213,412\r\n","FudanPed00049.jpg,447,512,adult,214,106,317,392\r\n","FudanPed00049.jpg,447,512,adult,315,107,435,387\r\n","FudanPed00050.jpg,580,516,adult,33,203,135,484\r\n","FudanPed00050.jpg,580,516,adult,291,205,369,412\r\n","FudanPed00051.jpg,448,501,adult,126,191,218,476\r\n","FudanPed00052.jpg,461,504,adult,206,189,308,492\r\n","FudanPed00053.jpg,541,580,adult,94,169,195,432\r\n","FudanPed00053.jpg,541,580,adult,389,150,499,453\r\n","FudanPed00054.jpg,533,498,adult,97,135,182,418\r\n","FudanPed00054.jpg,533,498,adult,287,114,358,332\r\n","FudanPed00054.jpg,533,498,adult,364,121,437,329\r\n","FudanPed00055.jpg,390,555,adult,148,178,277,530\r\n","FudanPed00056.jpg,565,581,adult,439,247,537,522\r\n","FudanPed00056.jpg,565,581,adult,200,259,270,529\r\n","FudanPed00056.jpg,565,581,adult,252,256,374,528\r\n","FudanPed00057.jpg,482,519,adult,22,91,143,406\r\n","FudanPed00057.jpg,482,519,adult,131,93,205,358\r\n","FudanPed00057.jpg,482,519,adult,237,83,312,356\r\n","FudanPed00057.jpg,482,519,adult,343,117,388,267\r\n","FudanPed00057.jpg,482,519,adult,386,116,427,250\r\n","FudanPed00058.jpg,522,479,adult,145,92,261,463\r\n","FudanPed00058.jpg,522,479,adult,43,123,64,211\r\n","FudanPed00058.jpg,522,479,adult,289,102,341,280\r\n","FudanPed00058.jpg,522,479,adult,353,97,406,276\r\n","FudanPed00058.jpg,522,479,adult,427,126,446,182\r\n","FudanPed00058.jpg,522,479,adult,462,126,474,171\r\n","FudanPed00058.jpg,522,479,adult,473,133,489,183\r\n","FudanPed00058.jpg,522,479,adult,492,121,517,202\r\n","FudanPed00059.jpg,576,369,adult,35,54,135,330\r\n","FudanPed00059.jpg,576,369,adult,159,36,252,329\r\n","FudanPed00059.jpg,576,369,adult,270,45,380,328\r\n","FudanPed00060.jpg,517,440,adult,188,141,291,427\r\n","FudanPed00060.jpg,517,440,adult,293,130,384,430\r\n","FudanPed00060.jpg,517,440,adult,395,149,498,427\r\n","FudanPed00061.jpg,547,407,adult,165,70,266,353\r\n","FudanPed00061.jpg,547,407,adult,343,86,429,381\r\n","FudanPed00061.jpg,547,407,adult,406,85,531,387\r\n","FudanPed00062.jpg,414,341,adult,175,25,255,321\r\n","FudanPed00062.jpg,414,341,adult,291,34,377,330\r\n","FudanPed00063.jpg,486,359,adult,29,38,114,332\r\n","FudanPed00063.jpg,486,359,adult,156,42,262,329\r\n","FudanPed00063.jpg,486,359,adult,312,54,330,99\r\n","FudanPed00063.jpg,486,359,adult,297,54,303,73\r\n","FudanPed00063.jpg,486,359,adult,305,53,310,73\r\n","FudanPed00064.jpg,546,420,adult,141,98,240,387\r\n","FudanPed00064.jpg,546,420,adult,317,101,400,395\r\n","FudanPed00064.jpg,546,420,adult,400,112,517,407\r\n","FudanPed00065.jpg,504,411,adult,29,69,147,382\r\n","FudanPed00065.jpg,504,411,adult,147,84,242,385\r\n","FudanPed00065.jpg,504,411,adult,234,70,311,393\r\n","FudanPed00065.jpg,504,411,adult,342,88,430,351\r\n","FudanPed00065.jpg,504,411,adult,13,58,64,183\r\n","FudanPed00066.jpg,360,359,adult,248,50,329,351\r\n","FudanPed00067.jpg,453,416,adult,62,79,184,375\r\n","FudanPed00069.jpg,354,379,adult,215,70,315,363\r\n","FudanPed00068.jpg,375,398,adult,249,66,318,361\r\n","FudanPed00070.jpg,390,382,adult,288,70,370,364\r\n","FudanPed00071.jpg,363,353,adult,121,44,246,330\r\n","FudanPed00071.jpg,363,353,adult,256,37,339,348\r\n","FudanPed00071.jpg,363,353,adult,226,52,255,119\r\n","FudanPed00072.jpg,375,349,adult,48,40,139,332\r\n","FudanPed00073.jpg,516,392,adult,56,66,159,360\r\n","FudanPed00073.jpg,516,392,adult,193,59,289,352\r\n","FudanPed00074.jpg,421,370,adult,48,51,126,351\r\n","FudanPed00074.jpg,421,370,adult,178,61,256,345\r\n","PennPed00001.jpg,612,406,adult,83,66,197,353\r\n","PennPed00001.jpg,612,406,adult,265,75,355,338\r\n","PennPed00001.jpg,612,406,adult,403,38,501,348\r\n","PennPed00001.jpg,612,406,adult,514,65,610,318\r\n","PennPed00001.jpg,612,406,adult,206,25,266,196\r\n","PennPed00002.jpg,745,378,adult,9,84,97,304\r\n","PennPed00002.jpg,745,378,adult,83,45,165,298\r\n","PennPed00002.jpg,745,378,adult,268,84,370,298\r\n","PennPed00002.jpg,745,378,adult,363,33,516,335\r\n","PennPed00002.jpg,745,378,adult,576,75,713,362\r\n","PennPed00002.jpg,745,378,adult,517,92,608,300\r\n","PennPed00003.jpg,670,418,adult,8,33,174,365\r\n","PennPed00003.jpg,670,418,adult,452,64,531,353\r\n","PennPed00003.jpg,670,418,adult,531,91,661,381\r\n","PennPed00004.jpg,786,436,adult,67,61,170,410\r\n","PennPed00004.jpg,786,436,adult,155,91,253,385\r\n","PennPed00004.jpg,786,436,adult,228,94,325,391\r\n","PennPed00004.jpg,786,436,adult,417,101,516,391\r\n","PennPed00004.jpg,786,436,adult,595,112,734,397\r\n","PennPed00005.jpg,767,454,adult,68,130,159,405\r\n","PennPed00005.jpg,767,454,adult,165,154,252,410\r\n","PennPed00005.jpg,767,454,adult,263,144,415,439\r\n","PennPed00005.jpg,767,454,adult,540,169,666,440\r\n","PennPed00005.jpg,767,454,adult,602,156,701,396\r\n","PennPed00006.jpg,631,436,adult,111,72,199,412\r\n","PennPed00006.jpg,631,436,adult,231,96,329,388\r\n","PennPed00006.jpg,631,436,adult,443,108,608,435\r\n","PennPed00006.jpg,631,436,adult,3,102,69,397\r\n","PennPed00007.jpg,570,412,adult,42,60,165,350\r\n","PennPed00007.jpg,570,412,adult,127,83,201,359\r\n","PennPed00007.jpg,570,412,adult,187,76,309,369\r\n","PennPed00007.jpg,570,412,adult,299,76,381,400\r\n","PennPed00007.jpg,570,412,adult,426,68,527,343\r\n","PennPed00008.jpg,452,403,adult,47,71,177,366\r\n","PennPed00008.jpg,452,403,adult,199,77,305,329\r\n","PennPed00008.jpg,452,403,adult,256,74,394,345\r\n","PennPed00008.jpg,452,403,adult,343,53,421,278\r\n","PennPed00009.jpg,648,413,adult,47,85,147,292\r\n","PennPed00009.jpg,648,413,adult,163,87,240,348\r\n","PennPed00009.jpg,648,413,adult,225,86,300,307\r\n","PennPed00009.jpg,648,413,adult,316,81,391,369\r\n","PennPed00009.jpg,648,413,adult,375,100,471,351\r\n","PennPed00009.jpg,648,413,adult,470,94,559,395\r\n","PennPed00009.jpg,648,413,adult,533,90,605,376\r\n","PennPed00010.jpg,750,495,adult,18,59,103,340\r\n","PennPed00010.jpg,750,495,adult,186,56,262,337\r\n","PennPed00010.jpg,750,495,adult,309,141,437,493\r\n","PennPed00010.jpg,750,495,adult,475,76,619,451\r\n","PennPed00010.jpg,750,495,adult,392,58,485,421\r\n","PennPed00010.jpg,750,495,adult,563,36,681,394\r\n","PennPed00011.jpg,508,376,adult,92,62,236,344\r\n","PennPed00011.jpg,508,376,adult,242,52,301,355\r\n","PennPed00012.jpg,565,429,adult,114,122,212,403\r\n","PennPed00013.jpg,564,385,adult,98,79,210,359\r\n","PennPed00013.jpg,564,385,adult,259,96,364,359\r\n","PennPed00013.jpg,564,385,adult,384,81,498,355\r\n","PennPed00013.jpg,564,385,adult,215,91,257,193\r\n","PennPed00014.jpg,542,368,adult,127,40,206,229\r\n","PennPed00014.jpg,542,368,adult,209,69,312,337\r\n","PennPed00014.jpg,542,368,adult,354,60,448,337\r\n","PennPed00014.jpg,542,368,adult,286,41,353,225\r\n","PennPed00015.jpg,906,438,adult,123,98,280,414\r\n","PennPed00015.jpg,906,438,adult,286,91,448,378\r\n","PennPed00015.jpg,906,438,adult,749,94,834,382\r\n","PennPed00016.jpg,683,399,adult,86,51,146,362\r\n","PennPed00016.jpg,683,399,adult,236,93,329,382\r\n","PennPed00016.jpg,683,399,adult,468,66,579,367\r\n","PennPed00017.jpg,492,403,adult,115,50,204,387\r\n","PennPed00017.jpg,492,403,adult,259,49,398,336\r\n","PennPed00018.jpg,460,344,adult,65,32,145,327\r\n","PennPed00018.jpg,460,344,adult,181,69,262,308\r\n","PennPed00019.jpg,734,404,adult,17,78,106,356\r\n","PennPed00019.jpg,734,404,adult,160,70,249,361\r\n","PennPed00019.jpg,734,404,adult,315,60,390,364\r\n","PennPed00019.jpg,734,404,adult,368,47,474,370\r\n","PennPed00019.jpg,734,404,adult,464,75,539,362\r\n","PennPed00019.jpg,734,404,adult,525,80,639,375\r\n","PennPed00019.jpg,734,404,adult,600,78,704,375\r\n","PennPed00020.jpg,721,428,adult,142,121,264,379\r\n","PennPed00020.jpg,721,428,adult,387,76,516,365\r\n","PennPed00020.jpg,721,428,adult,445,77,607,369\r\n","PennPed00021.jpg,712,436,adult,68,118,218,407\r\n","PennPed00021.jpg,712,436,adult,464,81,588,382\r\n","PennPed00021.jpg,712,436,adult,559,111,681,381\r\n","PennPed00022.jpg,925,486,adult,30,118,167,413\r\n","PennPed00022.jpg,925,486,adult,120,149,257,413\r\n","PennPed00022.jpg,925,486,adult,216,152,354,416\r\n","PennPed00022.jpg,925,486,adult,705,129,839,390\r\n","PennPed00022.jpg,925,486,adult,345,162,424,342\r\n","PennPed00023.jpg,536,382,adult,107,60,275,363\r\n","PennPed00024.jpg,409,384,adult,71,58,170,350\r\n","PennPed00025.jpg,450,334,adult,72,34,216,310\r\n","PennPed00025.jpg,450,334,adult,189,151,276,304\r\n","PennPed00025.jpg,450,334,adult,390,2,421,71\r\n","PennPed00026.jpg,530,410,adult,303,94,447,382\r\n","PennPed00026.jpg,530,410,adult,200,120,291,373\r\n","PennPed00027.jpg,492,391,adult,126,93,218,363\r\n","PennPed00027.jpg,492,391,adult,204,81,322,367\r\n","PennPed00027.jpg,492,391,adult,347,89,463,342\r\n","PennPed00028.jpg,416,368,adult,211,50,325,334\r\n","PennPed00029.jpg,672,418,adult,114,65,214,370\r\n","PennPed00029.jpg,672,418,adult,274,98,339,391\r\n","PennPed00029.jpg,672,418,adult,363,102,466,388\r\n","PennPed00029.jpg,672,418,adult,509,103,585,392\r\n","PennPed00030.jpg,479,354,adult,139,37,253,339\r\n","PennPed00030.jpg,479,354,adult,3,37,95,342\r\n","PennPed00030.jpg,479,354,adult,316,43,448,339\r\n","PennPed00031.jpg,487,340,adult,244,42,390,329\r\n","PennPed00032.jpg,374,344,adult,98,50,203,329\r\n","PennPed00033.jpg,533,391,adult,32,37,126,370\r\n","PennPed00033.jpg,533,391,adult,110,50,214,376\r\n","PennPed00033.jpg,533,391,adult,392,70,519,368\r\n","PennPed00033.jpg,533,391,adult,274,149,389,333\r\n","PennPed00034.jpg,538,422,adult,108,58,289,391\r\n","PennPed00034.jpg,538,422,adult,302,63,405,344\r\n","PennPed00034.jpg,538,422,adult,369,67,493,353\r\n","PennPed00034.jpg,538,422,adult,181,63,278,374\r\n","PennPed00035.jpg,623,353,adult,169,30,275,331\r\n","PennPed00035.jpg,623,353,adult,367,54,541,333\r\n","PennPed00035.jpg,623,353,adult,121,33,208,322\r\n","PennPed00036.jpg,694,370,adult,56,62,164,330\r\n","PennPed00036.jpg,694,370,adult,514,34,636,328\r\n","PennPed00037.jpg,366,318,adult,229,24,328,307\r\n","PennPed00039.jpg,495,373,adult,326,73,411,360\r\n","PennPed00038.jpg,436,353,adult,232,39,368,316\r\n","PennPed00040.jpg,406,342,adult,203,42,318,330\r\n","PennPed00041.jpg,570,422,adult,353,99,467,380\r\n","PennPed00042.jpg,569,344,adult,273,37,379,312\r\n","PennPed00042.jpg,569,344,adult,403,36,472,310\r\n","PennPed00043.jpg,480,356,adult,189,47,297,334\r\n","PennPed00043.jpg,480,356,adult,332,63,434,328\r\n","PennPed00043.jpg,480,356,adult,142,78,199,254\r\n","PennPed00043.jpg,480,356,adult,282,78,328,253\r\n","PennPed00043.jpg,480,356,adult,430,73,456,154\r\n","PennPed00044.jpg,483,335,adult,71,36,170,329\r\n","PennPed00044.jpg,483,335,adult,253,63,336,282\r\n","PennPed00044.jpg,483,335,adult,332,54,408,276\r\n","PennPed00044.jpg,483,335,adult,181,76,225,193\r\n","PennPed00045.jpg,692,395,adult,70,64,193,365\r\n","PennPed00045.jpg,692,395,adult,226,65,321,360\r\n","PennPed00045.jpg,692,395,adult,324,67,436,347\r\n","PennPed00045.jpg,692,395,adult,526,45,639,348\r\n","PennPed00045.jpg,692,395,adult,425,67,485,217\r\n","PennPed00045.jpg,692,395,adult,494,62,548,214\r\n","PennPed00046.jpg,534,348,adult,21,58,111,323\r\n","PennPed00046.jpg,534,348,adult,318,22,420,319\r\n","PennPed00046.jpg,534,348,adult,421,62,441,119\r\n","PennPed00047.jpg,500,346,adult,116,57,253,336\r\n","PennPed00047.jpg,500,346,adult,246,33,381,320\r\n","PennPed00047.jpg,500,346,adult,362,42,427,194\r\n","PennPed00048.jpg,423,380,adult,27,33,118,326\r\n","PennPed00048.jpg,423,380,adult,116,35,198,321\r\n","PennPed00048.jpg,423,380,adult,263,21,385,369\r\n","PennPed00049.jpg,452,350,adult,82,48,176,346\r\n","PennPed00049.jpg,452,350,adult,175,45,253,337\r\n","PennPed00049.jpg,452,350,adult,252,81,307,237\r\n","PennPed00049.jpg,452,350,adult,310,77,368,240\r\n","PennPed00050.jpg,419,315,adult,91,41,196,291\r\n","PennPed00051.jpg,723,411,adult,38,52,203,326\r\n","PennPed00051.jpg,723,411,adult,314,67,481,365\r\n","PennPed00051.jpg,723,411,adult,459,34,587,373\r\n","PennPed00051.jpg,723,411,adult,554,67,628,339\r\n","PennPed00052.jpg,682,525,adult,77,137,175,428\r\n","PennPed00052.jpg,682,525,adult,169,181,294,491\r\n","PennPed00052.jpg,682,525,adult,403,157,494,400\r\n","PennPed00052.jpg,682,525,adult,524,83,613,393\r\n","PennPed00052.jpg,682,525,adult,279,179,334,314\r\n","PennPed00053.jpg,377,344,adult,15,29,124,325\r\n","PennPed00053.jpg,377,344,adult,169,27,266,329\r\n","PennPed00054.jpg,324,334,adult,43,22,128,317\r\n","PennPed00055.jpg,417,353,adult,96,51,208,341\r\n","PennPed00055.jpg,417,353,adult,29,8,122,283\r\n","PennPed00056.jpg,618,420,adult,175,106,271,398\r\n","PennPed00056.jpg,618,420,adult,140,122,193,384\r\n","PennPed00056.jpg,618,420,adult,257,98,306,386\r\n","PennPed00057.jpg,371,364,adult,158,64,261,352\r\n","PennPed00057.jpg,371,364,adult,198,18,266,294\r\n","PennPed00058.jpg,509,380,adult,167,27,245,316\r\n","PennPed00058.jpg,509,380,adult,228,31,307,291\r\n","PennPed00058.jpg,509,380,adult,321,65,452,351\r\n","PennPed00058.jpg,509,380,adult,295,22,374,274\r\n","PennPed00059.jpg,582,362,adult,80,44,177,337\r\n","PennPed00059.jpg,582,362,adult,381,36,529,323\r\n","PennPed00060.jpg,505,351,adult,43,23,142,326\r\n","PennPed00060.jpg,505,351,adult,189,21,283,230\r\n","PennPed00060.jpg,505,351,adult,117,28,191,226\r\n","PennPed00060.jpg,505,351,adult,273,81,389,327\r\n","PennPed00060.jpg,505,351,adult,378,31,476,330\r\n","PennPed00061.jpg,314,320,adult,34,17,143,307\r\n","PennPed00061.jpg,314,320,adult,250,57,275,146\r\n","PennPed00062.jpg,396,315,adult,86,15,184,301\r\n","PennPed00062.jpg,396,315,adult,176,35,288,305\r\n","PennPed00062.jpg,396,315,adult,2,46,57,223\r\n","PennPed00062.jpg,396,315,adult,321,54,373,234\r\n","PennPed00063.jpg,427,350,adult,88,50,262,339\r\n","PennPed00064.jpg,370,322,adult,226,29,334,314\r\n","PennPed00065.jpg,324,318,adult,24,21,139,304\r\n","PennPed00066.jpg,428,375,adult,11,76,128,365\r\n","PennPed00066.jpg,428,375,adult,265,33,398,312\r\n","PennPed00066.jpg,428,375,adult,76,30,189,345\r\n","PennPed00067.jpg,370,318,adult,37,13,184,298\r\n","PennPed00068.jpg,603,387,adult,43,89,153,364\r\n","PennPed00068.jpg,603,387,adult,189,56,283,349\r\n","PennPed00068.jpg,603,387,adult,430,37,568,349\r\n","PennPed00068.jpg,603,387,adult,384,47,455,223\r\n","PennPed00069.jpg,388,345,adult,59,44,149,330\r\n","PennPed00069.jpg,388,345,adult,169,40,269,310\r\n","PennPed00070.jpg,466,354,adult,15,24,122,341\r\n","PennPed00070.jpg,466,354,adult,185,14,306,312\r\n","PennPed00071.jpg,767,379,adult,49,19,171,361\r\n","PennPed00071.jpg,767,379,adult,292,44,386,305\r\n","PennPed00071.jpg,767,379,adult,476,25,567,302\r\n","PennPed00071.jpg,767,379,adult,600,13,716,306\r\n","PennPed00071.jpg,767,379,adult,567,53,612,180\r\n","PennPed00071.jpg,767,379,adult,709,53,744,174\r\n","PennPed00072.jpg,473,348,adult,134,25,254,337\r\n","PennPed00072.jpg,473,348,adult,280,52,431,330\r\n","PennPed00073.jpg,579,364,adult,98,38,191,326\r\n","PennPed00073.jpg,579,364,adult,182,46,277,340\r\n","PennPed00073.jpg,579,364,adult,316,51,413,331\r\n","PennPed00074.jpg,442,332,adult,259,31,422,317\r\n","PennPed00074.jpg,442,332,adult,198,23,283,303\r\n","PennPed00074.jpg,442,332,adult,117,48,223,295\r\n","PennPed00076.jpg,342,348,adult,187,29,320,319\r\n","PennPed00075.jpg,368,322,adult,194,23,335,308\r\n","PennPed00077.jpg,352,323,adult,65,27,181,317\r\n","PennPed00078.jpg,349,372,adult,216,59,320,355\r\n","PennPed00079.jpg,357,337,adult,206,25,324,320\r\n","PennPed00080.jpg,435,361,adult,72,47,175,339\r\n","PennPed00080.jpg,435,361,adult,198,43,314,339\r\n","PennPed00080.jpg,435,361,adult,320,44,422,332\r\n","PennPed00081.jpg,561,387,adult,148,85,240,366\r\n","PennPed00081.jpg,561,387,adult,233,54,337,360\r\n","PennPed00081.jpg,561,387,adult,330,75,455,366\r\n","PennPed00082.jpg,398,321,adult,80,22,229,312\r\n","PennPed00083.jpg,371,341,adult,108,32,249,327\r\n","PennPed00083.jpg,371,341,adult,38,22,124,299\r\n","PennPed00084.jpg,370,356,adult,142,46,310,342\r\n","PennPed00084.jpg,370,356,adult,274,21,362,334\r\n","PennPed00084.jpg,370,356,adult,161,95,208,258\r\n","PennPed00085.jpg,403,341,adult,89,27,200,302\r\n","PennPed00085.jpg,403,341,adult,245,38,368,329\r\n","PennPed00086.jpg,474,354,adult,8,33,109,253\r\n","PennPed00086.jpg,474,354,adult,208,49,306,318\r\n","PennPed00086.jpg,474,354,adult,345,32,457,325\r\n","PennPed00086.jpg,474,354,adult,73,163,180,353\r\n","PennPed00086.jpg,474,354,adult,113,65,164,197\r\n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"id":"jiJKaYJumjmz","colab_type":"code","colab":{"base_uri":"https://localhost:8080/","height":35},"outputId":"ea75185f-4656-4a20-e4af-29f383958d26","executionInfo":{"status":"ok","timestamp":1591987381251,"user_tz":-540,"elapsed":8710,"user":{"displayName":"신아형[학생](소프트웨어융합대학 컴퓨터공학과)","photoUrl":"","userId":"02057930622140727302"}}},"source":["# 테스트에 사용할 어른 보행자 데이터셋 annotation파일(txt 파일)을 csv파일로 만듦(adult_test_labels.csv)\n","\n","import os\n","import glob\n","import pandas as pd\n","import argparse\n","import xml.etree.ElementTree as ET\n","\n","import csv\n","import re\n","\n","csv_file=open('/content/gdrive/My Drive/capstone/data/annotations/adult_test_labels.csv', \"a\") #저장 디렉토리\n","csv_file.write(\"filename, width, height, class, xmin, ymin, xmax, ymax\\n\")\n","wr = csv.writer(csv_file)\n","\n","csv_lst=[]\n","\n","path_dir='/content/gdrive/My Drive/capstone/data/images/adult_test_annotation/'\n","file_list=os.listdir(path_dir)\n","\n","\n","for file in file_list:\n"," file_dir=path_dir+file\n"," f = open(file_dir, 'r')\n","\n"," xmin=[]\n"," ymin=[]\n"," xmax=[]\n"," ymax=[]\n","\n"," while True:\n"," line=f.readline()\n","\n"," if not line:\n"," break\n","\n"," if 'Image filename' in line:\n"," filename=line.split('/')\n"," filename=filename[-1]\n"," filename=filename[:-5]+'jpg'\n","\n"," if 'Image size' in line:\n"," numbers=re.findall(\"\\d+\", line)\n"," width=numbers[0]\n"," height=numbers[1]\n","\n"," if 'Bounding box for object' in line:\n"," numbers=re.findall(\"\\d+\", line)\n"," xmin.append(numbers[1])\n"," ymin.append(numbers[2])\n"," xmax.append(numbers[3])\n"," ymax.append(numbers[4])\n","\n"," class_name='adult'\n"," \n"," size=len(xmin)\n"," #print(size)\n","\n"," lst=[]\n"," file_lst=[]\n"," for i in range(size):\n"," lst=[filename, width, height, class_name, xmin[i], ymin[i], xmax[i], ymax[i]]\n"," file_lst.append(lst) \n"," csv_lst.append(file_lst) \n"," f.close()\n","\n","for i in csv_lst:\n"," s=len(i)\n"," for j in range(s):\n"," wr.writerow(i[j])\n","\n","csv_file.close()\n","\n","print(\"Successfully converted txt to csv.\")"],"execution_count":4,"outputs":[{"output_type":"stream","text":["Successfully converted txt to csv.\n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"id":"osaQb1Xh1cJh","colab_type":"code","colab":{"base_uri":"https://localhost:8080/","height":325},"outputId":"b3ec60c1-fda7-4b56-9149-973c226cf6b5","executionInfo":{"status":"ok","timestamp":1591987392208,"user_tz":-540,"elapsed":4233,"user":{"displayName":"신아형[학생](소프트웨어융합대학 컴퓨터공학과)","photoUrl":"","userId":"02057930622140727302"}}},"source":["!cat /content/gdrive/My\\ Drive/capstone/data/annotations/adult_test_labels.csv"],"execution_count":5,"outputs":[{"output_type":"stream","text":["filename, width, height, class, xmin, ymin, xmax, ymax\n","PennPed00087.jpg,325,343,adult,23,16,148,322\r\n","PennPed00088.jpg,375,320,adult,73,18,215,312\r\n","PennPed00089.jpg,428,317,adult,85,25,165,294\r\n","PennPed00089.jpg,428,317,adult,140,6,297,309\r\n","PennPed00091.jpg,372,324,adult,212,26,336,321\r\n","PennPed00090.jpg,500,370,adult,80,23,212,358\r\n","PennPed00090.jpg,500,370,adult,43,39,122,346\r\n","PennPed00090.jpg,500,370,adult,206,38,366,326\r\n","PennPed00092.jpg,600,447,adult,106,76,311,434\r\n","PennPed00092.jpg,600,447,adult,288,94,464,390\r\n","PennPed00093.jpg,368,311,adult,51,6,222,302\r\n","PennPed00094.jpg,422,349,adult,122,27,256,322\r\n","PennPed00095.jpg,512,375,adult,193,50,300,337\r\n","PennPed00095.jpg,512,375,adult,320,55,432,335\r\n","PennPed00096.jpg,294,331,adult,6,38,103,324\r\n","PennPed00096.jpg,294,331,adult,101,26,206,323\r\n"],"name":"stdout"}]}]}