{"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":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\n# for dirname, _, filenames in os.walk('/kaggle/input'):\n#     for filename in filenames:\n#         print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2021-07-16T09:25:53.153885Z","iopub.execute_input":"2021-07-16T09:25:53.154279Z","iopub.status.idle":"2021-07-16T09:25:53.164242Z","shell.execute_reply.started":"2021-07-16T09:25:53.154188Z","shell.execute_reply":"2021-07-16T09:25:53.163449Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# import efficientnet.keras as efn\nimport os\nimport shutil\nimport random\nimport tensorflow as tf\nfrom tensorflow.keras.layers import Dense , Conv2D , Dropout , MaxPooling2D , Flatten, Activation , BatchNormalization\nfrom tensorflow.keras.models import Sequential\nfrom tensorflow.keras.applications import EfficientNetB7\nfrom tensorflow.keras.optimizers import Adam\nimport numpy as np\nimport cv2\nimport matplotlib.pyplot as plt\nimport pandas as pd\nfrom tensorflow.keras.preprocessing.image import ImageDataGenerator","metadata":{"execution":{"iopub.status.busy":"2021-07-16T09:25:53.643864Z","iopub.execute_input":"2021-07-16T09:25:53.644167Z","iopub.status.idle":"2021-07-16T09:25:58.030161Z","shell.execute_reply.started":"2021-07-16T09:25:53.644138Z","shell.execute_reply":"2021-07-16T09:25:58.02929Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import tensorflow as tf\n\nimport os\ntry:\n    tpu = tf.distribute.cluster_resolver.TPUClusterResolver()  # TPU detection\n    print(\"Running on TPU \", tpu.cluster_spec().as_dict()[\"worker\"])\n    tf.config.experimental_connect_to_cluster(tpu)\n    tf.tpu.experimental.initialize_tpu_system(tpu)\n    strategy = tf.distribute.experimental.TPUStrategy(tpu)\nexcept ValueError:\n    print(\"Not connected to a TPU runtime. Using CPU/GPU strategy\")\n    strategy = tf.distribute.MirroredStrategy()","metadata":{"execution":{"iopub.status.busy":"2021-07-16T09:25:58.031674Z","iopub.execute_input":"2021-07-16T09:25:58.032035Z","iopub.status.idle":"2021-07-16T09:25:59.672287Z","shell.execute_reply.started":"2021-07-16T09:25:58.031997Z","shell.execute_reply":"2021-07-16T09:25:59.671212Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"%mkdir NewPreprocessed","metadata":{"execution":{"iopub.status.busy":"2021-07-16T09:26:08.718477Z","iopub.execute_input":"2021-07-16T09:26:08.718833Z","iopub.status.idle":"2021-07-16T09:26:09.36929Z","shell.execute_reply.started":"2021-07-16T09:26:08.718802Z","shell.execute_reply":"2021-07-16T09:26:09.368212Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"a = os.listdir('../input/rsna-balenced-dataset/Processed')\na","metadata":{"execution":{"iopub.status.busy":"2021-07-16T09:26:12.958666Z","iopub.execute_input":"2021-07-16T09:26:12.959018Z","iopub.status.idle":"2021-07-16T09:26:12.987823Z","shell.execute_reply.started":"2021-07-16T09:26:12.958983Z","shell.execute_reply":"2021-07-16T09:26:12.987083Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for i in a:\n    os.mkdir('NewPreprocessed/{}'.format(i))","metadata":{"execution":{"iopub.status.busy":"2021-07-16T09:26:19.917983Z","iopub.execute_input":"2021-07-16T09:26:19.91831Z","iopub.status.idle":"2021-07-16T09:26:19.922573Z","shell.execute_reply.started":"2021-07-16T09:26:19.91828Z","shell.execute_reply":"2021-07-16T09:26:19.921513Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from PIL import Image\nimport os, sys\n\n\ndef resize(path,savepath):\n    for item in os.listdir(path):\n        item_path = path+\"/\"+item\n        im = Image.open(item_path)\n        imResize = im.resize((600,600), Image.ANTIALIAS)\n        imResize.save(savepath +\"/\"+item.split('.')[0]+ '_resized.jpg', 'JPEG')\n\nfor i in a:\n    path = \"../input/rsna-balenced-dataset/Processed/\"+i\n    savepath = \"NewPreprocessed/\"+i\n    resize(path,savepath)\n    ","metadata":{"execution":{"iopub.status.busy":"2021-07-16T09:26:28.018633Z","iopub.execute_input":"2021-07-16T09:26:28.018976Z","iopub.status.idle":"2021-07-16T09:31:08.258652Z","shell.execute_reply.started":"2021-07-16T09:26:28.018941Z","shell.execute_reply":"2021-07-16T09:31:08.257727Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}