{"cells":[{"metadata":{"trusted":true},"cell_type":"code","source":"import numpy as np \nimport pandas as pd \nimport cv2\nfrom matplotlib import pyplot as plt\nplt.rcParams[\"figure.figsize\"] = (16,9)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"code","source":"import os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","trusted":true},"cell_type":"code","source":"TRAIN_PATH = '/kaggle/input/train.csv'\nTRAIN_IMAGES = '/kaggle/input/train_images/'\nTEST_IMAGES = '/kaggle/input/test_images/'\nUNICODE_PATH = '/kaggle/input/unicode_translation.csv'","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"data = pd.read_csv(TRAIN_PATH)\nuni_trans = pd.read_csv(UNICODE_PATH)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"data.head()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"### Parse and visualize image data"},{"metadata":{"trusted":true},"cell_type":"code","source":"import re","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"sample = data.iloc[500]\n\nlabels = sample.labels\nlabels = re.findall(r\"U\\+.{4} \\d+ \\d+ \\d+ \\d+\",labels)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"img = cv2.imread(TRAIN_IMAGES + f'{sample.image_id}.jpg')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"symbol_idx = 0 \nx_idx = 1\ny_idx = 2\nw_idx = 3\nh_idx = 4\nfor label in labels:\n    values = label.split()\n    x = int(values[x_idx])\n    y = int(values[y_idx])\n    w = int(values[w_idx])\n    h = int(values[h_idx])\n    \n    cv2.rectangle(img,(x,y), (x+w,y+h),(0,0,255), 10)\n    ","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"plt.imshow(img)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"markdown","source":"## Ready to use Darknet..."},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat":4,"nbformat_minor":1}