{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":6799,"databundleVersionId":4225553,"sourceType":"competition"}],"dockerImageVersionId":30635,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"p1 = '/kaggle/input/imagenet-object-localization-challenge/ILSVRC/Data/CLS-LOC/train/n01440764/n01440764_10026.JPEG'\np2 = '/kaggle/input/imagenet-object-localization-challenge/ILSVRC/Data/CLS-LOC/train/n01440764/n01440764_10040.JPEG'\np3 = '/kaggle/input/imagenet-object-localization-challenge/ILSVRC/Data/CLS-LOC/train/n01440764/n01440764_10095.JPEG'","metadata":{"execution":{"iopub.status.busy":"2024-01-18T19:45:12.053633Z","iopub.execute_input":"2024-01-18T19:45:12.054061Z","iopub.status.idle":"2024-01-18T19:45:12.059488Z","shell.execute_reply.started":"2024-01-18T19:45:12.054026Z","shell.execute_reply":"2024-01-18T19:45:12.058332Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from PIL import Image\nimport glob\nimport os\nfrom collections import Counter\nfrom distutils.dir_util import copy_tree\nimport shutil","metadata":{"execution":{"iopub.status.busy":"2024-01-18T20:04:40.868636Z","iopub.execute_input":"2024-01-18T20:04:40.869012Z","iopub.status.idle":"2024-01-18T20:04:40.874752Z","shell.execute_reply.started":"2024-01-18T20:04:40.868981Z","shell.execute_reply":"2024-01-18T20:04:40.873525Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_folders = glob.glob('/kaggle/input/imagenet-object-localization-challenge/ILSVRC/Data/CLS-LOC/train/*')\ntest_folders = glob.glob('/kaggle/input/imagenet-object-localization-challenge/ILSVRC/Data/CLS-LOC/test/*')\nval_folders = glob.glob('/kaggle/input/imagenet-object-localization-challenge/ILSVRC/Data/CLS-LOC/val/*')","metadata":{"execution":{"iopub.status.busy":"2024-01-18T19:49:01.232114Z","iopub.execute_input":"2024-01-18T19:49:01.232601Z","iopub.status.idle":"2024-01-18T19:49:05.601974Z","shell.execute_reply.started":"2024-01-18T19:49:01.232557Z","shell.execute_reply":"2024-01-18T19:49:05.600793Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_folders[:10]","metadata":{"execution":{"iopub.status.busy":"2024-01-18T19:48:19.723885Z","iopub.execute_input":"2024-01-18T19:48:19.725109Z","iopub.status.idle":"2024-01-18T19:48:19.732082Z","shell.execute_reply.started":"2024-01-18T19:48:19.725058Z","shell.execute_reply":"2024-01-18T19:48:19.731026Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_class_frequencies = Counter()\nfor folder_path in train_folders[:10]:\n    folder_name = folder_path.split('/')[-1]\n    train_class_frequencies[folder_name] = len(os.listdir(folder_path))","metadata":{"execution":{"iopub.status.busy":"2024-01-18T19:54:40.683664Z","iopub.execute_input":"2024-01-18T19:54:40.684158Z","iopub.status.idle":"2024-01-18T19:54:40.699077Z","shell.execute_reply.started":"2024-01-18T19:54:40.684116Z","shell.execute_reply":"2024-01-18T19:54:40.698069Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_class_frequencies","metadata":{"execution":{"iopub.status.busy":"2024-01-18T19:54:48.906376Z","iopub.execute_input":"2024-01-18T19:54:48.90684Z","iopub.status.idle":"2024-01-18T19:54:48.914892Z","shell.execute_reply.started":"2024-01-18T19:54:48.906801Z","shell.execute_reply":"2024-01-18T19:54:48.913496Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(train_folders)","metadata":{"execution":{"iopub.status.busy":"2024-01-18T19:55:17.402236Z","iopub.execute_input":"2024-01-18T19:55:17.402731Z","iopub.status.idle":"2024-01-18T19:55:17.410489Z","shell.execute_reply.started":"2024-01-18T19:55:17.402688Z","shell.execute_reply":"2024-01-18T19:55:17.409241Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!mkdir /kaggle/working/samples/","metadata":{"execution":{"iopub.status.busy":"2024-01-18T19:58:50.468304Z","iopub.execute_input":"2024-01-18T19:58:50.469474Z","iopub.status.idle":"2024-01-18T19:58:51.487077Z","shell.execute_reply.started":"2024-01-18T19:58:50.469421Z","shell.execute_reply":"2024-01-18T19:58:51.485373Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for folder_path in train_folders[:10]:\n    folder_name = folder_path.split('/')[-1]\n    copy_tree(folder_path, '/kaggle/working/samples/'+folder_name)","metadata":{"execution":{"iopub.status.busy":"2024-01-18T20:02:55.622288Z","iopub.execute_input":"2024-01-18T20:02:55.622799Z","iopub.status.idle":"2024-01-18T20:04:40.866433Z","shell.execute_reply.started":"2024-01-18T20:02:55.622755Z","shell.execute_reply":"2024-01-18T20:04:40.86503Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"shutil.make_archive('/kaggle/working/sample-images', 'zip', '/kaggle/working/samples/')","metadata":{"execution":{"iopub.status.busy":"2024-01-18T20:04:45.329697Z","iopub.execute_input":"2024-01-18T20:04:45.330658Z"},"trusted":true},"execution_count":null,"outputs":[]}]}