{"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_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import numpy as np \nimport pandas as pd\nfrom tqdm.auto import tqdm\nimport glob\nimport os\nimport cv2","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-03-26T03:48:48.676857Z","iopub.execute_input":"2022-03-26T03:48:48.677206Z","iopub.status.idle":"2022-03-26T03:48:49.17096Z","shell.execute_reply.started":"2022-03-26T03:48:48.677112Z","shell.execute_reply":"2022-03-26T03:48:49.170012Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dim = (512, 512)","metadata":{"execution":{"iopub.status.busy":"2022-03-26T03:48:49.172874Z","iopub.execute_input":"2022-03-26T03:48:49.173136Z","iopub.status.idle":"2022-03-26T03:48:49.177144Z","shell.execute_reply.started":"2022-03-26T03:48:49.173104Z","shell.execute_reply":"2022-03-26T03:48:49.176365Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Train data","metadata":{}},{"cell_type":"code","source":"! mkdir train_images","metadata":{"execution":{"iopub.status.busy":"2022-03-26T03:48:49.178434Z","iopub.execute_input":"2022-03-26T03:48:49.178738Z","iopub.status.idle":"2022-03-26T03:48:49.943729Z","shell.execute_reply.started":"2022-03-26T03:48:49.178697Z","shell.execute_reply":"2022-03-26T03:48:49.942759Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"files = glob.glob(\"../input/sorghum-id-fgvc-9/train_images/*.png\")","metadata":{"execution":{"iopub.status.busy":"2022-03-26T03:48:49.946524Z","iopub.execute_input":"2022-03-26T03:48:49.947554Z","iopub.status.idle":"2022-03-26T03:48:50.544061Z","shell.execute_reply.started":"2022-03-26T03:48:49.947487Z","shell.execute_reply":"2022-03-26T03:48:50.543379Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for file in tqdm(files):\n    image = cv2.imread(file)\n    image = cv2.resize(image, dim, interpolation = cv2.INTER_AREA)\n    name = os.path.basename(file)[:-3]\n    cv2.imwrite(f'train_images/{name}jpg', image, [int(cv2.IMWRITE_JPEG_QUALITY), 100])","metadata":{"execution":{"iopub.status.busy":"2022-03-26T03:48:50.545452Z","iopub.execute_input":"2022-03-26T03:48:50.545978Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Test data","metadata":{}},{"cell_type":"code","source":"! mkdir test","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"files = glob.glob(\"../input/sorghum-id-fgvc-9/test/*.png\")","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for file in tqdm(files):\n    image = cv2.imread(file)\n    image = cv2.resize(image, dim, interpolation = cv2.INTER_AREA)\n    name = os.path.basename(file)[:-3]\n    cv2.imwrite(f'test/{name}jpg', image, [int(cv2.IMWRITE_JPEG_QUALITY), 100])","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"The link to the dataset is : https://www.kaggle.com/tchaye59/sorghum100cultivarjpgimages512x512","metadata":{}}]}