{"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":"from PIL import Image\nfrom tqdm import tqdm\nimport os","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-02-08T13:49:10.08618Z","iopub.execute_input":"2022-02-08T13:49:10.086474Z","iopub.status.idle":"2022-02-08T13:49:10.09058Z","shell.execute_reply.started":"2022-02-08T13:49:10.086442Z","shell.execute_reply":"2022-02-08T13:49:10.089876Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"Images_DIR = \"/kaggle/input/h-and-m-personalized-fashion-recommendations/images/\"\nSave_DIR = \"images_resized/\"\n\nos.mkdir(Save_DIR)\ndirectories = os.listdir(Images_DIR)","metadata":{"execution":{"iopub.status.busy":"2022-02-08T13:49:11.757949Z","iopub.execute_input":"2022-02-08T13:49:11.758501Z","iopub.status.idle":"2022-02-08T13:49:11.775284Z","shell.execute_reply.started":"2022-02-08T13:49:11.758446Z","shell.execute_reply":"2022-02-08T13:49:11.774455Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for folder in tqdm(directories, position=0, leave=True):\n    \n    img_files = os.listdir(Images_DIR+folder+'/')\n    \n    for img_file in img_files:\n         \n        image = Image.open(Images_DIR+folder+'/'+img_file)\n        image = image.resize((224, 224))\n        \n        if not os.path.isdir(Save_DIR+folder+'/'):\n            os.mkdir(Save_DIR+folder+'/')\n        \n        image.save(Save_DIR+folder+'/'+img_file)\n        \n    print(f'Folder {folder} ... Next!')","metadata":{"execution":{"iopub.status.busy":"2022-02-08T13:57:30.240906Z","iopub.execute_input":"2022-02-08T13:57:30.241584Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!zip -r images.zip images_resized","metadata":{},"execution_count":null,"outputs":[]}]}