{"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":"!pip install -q efficientnet\n!pip install stegano\n#!pip install sklearn\nimport os, gc\nimport numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\nos.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' \nimport tensorflow as tf\nfrom kaggle_datasets import KaggleDatasets\nimport tensorflow.keras.layers as L\nimport efficientnet.tfkeras as efn\nfrom sklearn import metrics\nfrom sklearn.model_selection import train_test_split\nimport glob as glob\n#import cv2\nfrom PIL import Image\nimport matplotlib.image as mpimg\nimport skimage.io as sk\nfrom stegano import lsb\nfrom tqdm import tqdm","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-02-22T18:46:39.371583Z","iopub.execute_input":"2023-02-22T18:46:39.372294Z","iopub.status.idle":"2023-02-22T18:47:16.426765Z","shell.execute_reply.started":"2023-02-22T18:46:39.372197Z","shell.execute_reply":"2023-02-22T18:47:16.425557Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"os.mkdir(\"/kaggle/working/cover\")\nos.mkdir(\"/kaggle/working/ste\")","metadata":{"execution":{"iopub.status.busy":"2023-02-22T18:53:25.530153Z","iopub.execute_input":"2023-02-22T18:53:25.530964Z","iopub.status.idle":"2023-02-22T18:53:25.537772Z","shell.execute_reply.started":"2023-02-22T18:53:25.530923Z","shell.execute_reply":"2023-02-22T18:53:25.536574Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"path1='../input/alaska2-image-steganalysis'","metadata":{"execution":{"iopub.status.busy":"2023-02-22T18:53:29.794158Z","iopub.execute_input":"2023-02-22T18:53:29.794623Z","iopub.status.idle":"2023-02-22T18:53:29.800549Z","shell.execute_reply.started":"2023-02-22T18:53:29.794583Z","shell.execute_reply":"2023-02-22T18:53:29.799079Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def append_path(pre):\n    return np.vectorize(lambda file: os.path.join(path1, pre, file))","metadata":{"execution":{"iopub.status.busy":"2023-02-22T18:53:34.475555Z","iopub.execute_input":"2023-02-22T18:53:34.475988Z","iopub.status.idle":"2023-02-22T18:53:34.481930Z","shell.execute_reply.started":"2023-02-22T18:53:34.475952Z","shell.execute_reply":"2023-02-22T18:53:34.480781Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_filenames = np.array(os.listdir(\"../input/alaska2-image-steganalysis/Cover\"))","metadata":{"execution":{"iopub.status.busy":"2023-02-22T18:53:40.047185Z","iopub.execute_input":"2023-02-22T18:53:40.047607Z","iopub.status.idle":"2023-02-22T18:53:41.127862Z","shell.execute_reply.started":"2023-02-22T18:53:40.047574Z","shell.execute_reply":"2023-02-22T18:53:41.126595Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_filenames=sorted(train_filenames)","metadata":{"execution":{"iopub.status.busy":"2023-02-22T18:53:43.475144Z","iopub.execute_input":"2023-02-22T18:53:43.475581Z","iopub.status.idle":"2023-02-22T18:53:43.554532Z","shell.execute_reply.started":"2023-02-22T18:53:43.475542Z","shell.execute_reply":"2023-02-22T18:53:43.553370Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_filenames","metadata":{"execution":{"iopub.status.busy":"2023-02-22T18:53:47.241326Z","iopub.execute_input":"2023-02-22T18:53:47.242163Z","iopub.status.idle":"2023-02-22T18:53:47.272102Z","shell.execute_reply.started":"2023-02-22T18:53:47.242121Z","shell.execute_reply":"2023-02-22T18:53:47.270478Z"},"collapsed":true,"jupyter":{"outputs_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#np.random.seed(0)\npositives = train_filenames.copy()\nnegatives = train_filenames.copy()\nst = append_path('Cover')(positives[:1000])\npos_paths = st","metadata":{"execution":{"iopub.status.busy":"2023-02-22T18:54:03.243268Z","iopub.execute_input":"2023-02-22T18:54:03.243664Z","iopub.status.idle":"2023-02-22T18:54:03.256305Z","shell.execute_reply.started":"2023-02-22T18:54:03.243632Z","shell.execute_reply":"2023-02-22T18:54:03.254569Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"st","metadata":{"execution":{"iopub.status.busy":"2023-02-22T18:54:06.535191Z","iopub.execute_input":"2023-02-22T18:54:06.535652Z","iopub.status.idle":"2023-02-22T18:54:06.552841Z","shell.execute_reply.started":"2023-02-22T18:54:06.535612Z","shell.execute_reply":"2023-02-22T18:54:06.551518Z"},"collapsed":true,"jupyter":{"outputs_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(st)","metadata":{"execution":{"iopub.status.busy":"2023-02-22T18:54:12.062701Z","iopub.execute_input":"2023-02-22T18:54:12.063150Z","iopub.status.idle":"2023-02-22T18:54:12.072090Z","shell.execute_reply.started":"2023-02-22T18:54:12.063116Z","shell.execute_reply":"2023-02-22T18:54:12.070795Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for i in tqdm(range(len(st))):\n    image = sk.imread(st[i])\n    secret = lsb.hide(st[i], \"I love kai so much that I even got my master's degree here, that's right!!\")\n    secret.save(\"/kaggle/working/ste/\"+f\"{train_filenames[i]}\")","metadata":{"execution":{"iopub.status.busy":"2023-02-22T18:56:37.685598Z","iopub.execute_input":"2023-02-22T18:56:37.686052Z","iopub.status.idle":"2023-02-22T18:57:09.679870Z","shell.execute_reply.started":"2023-02-22T18:56:37.686002Z","shell.execute_reply":"2023-02-22T18:57:09.678690Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"img1 = sk.imread(\"/kaggle/working/ste/00005.jpg\")\n\nfig,ax = plt.subplots(1,2,figsize=(18,8))\n    \nax[0].imshow(img1)","metadata":{"execution":{"iopub.status.busy":"2023-02-22T18:57:24.104053Z","iopub.execute_input":"2023-02-22T18:57:24.104463Z","iopub.status.idle":"2023-02-22T18:57:24.799307Z","shell.execute_reply.started":"2023-02-22T18:57:24.104432Z","shell.execute_reply":"2023-02-22T18:57:24.798095Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#dir = '/kaggle/working/ste1'\n#for f in os.listdir(dir):\n    #os.remove(os.path.join(dir, f))","metadata":{"execution":{"iopub.status.busy":"2023-02-22T14:10:40.565549Z","iopub.execute_input":"2023-02-22T14:10:40.566096Z","iopub.status.idle":"2023-02-22T14:10:40.631596Z","shell.execute_reply.started":"2023-02-22T14:10:40.566050Z","shell.execute_reply":"2023-02-22T14:10:40.629172Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import shutil","metadata":{"execution":{"iopub.status.busy":"2023-02-22T18:57:29.377475Z","iopub.execute_input":"2023-02-22T18:57:29.377852Z","iopub.status.idle":"2023-02-22T18:57:29.383781Z","shell.execute_reply.started":"2023-02-22T18:57:29.377820Z","shell.execute_reply":"2023-02-22T18:57:29.381831Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for i in tqdm(range(len(st))):\n    shutil.copy2(st[i], \"/kaggle/working/cover/\"+f\"{train_filenames[i]}\")","metadata":{"execution":{"iopub.status.busy":"2023-02-22T18:57:34.790231Z","iopub.execute_input":"2023-02-22T18:57:34.790649Z","iopub.status.idle":"2023-02-22T18:57:36.480987Z","shell.execute_reply.started":"2023-02-22T18:57:34.790612Z","shell.execute_reply":"2023-02-22T18:57:36.479891Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"img1 = sk.imread(\"/kaggle/working/cover/00005.jpg\")\n\nfig,ax = plt.subplots(1,2,figsize=(18,8))\n    \nax[0].imshow(img1)","metadata":{"execution":{"iopub.status.busy":"2023-02-22T18:57:41.905354Z","iopub.execute_input":"2023-02-22T18:57:41.905759Z","iopub.status.idle":"2023-02-22T18:57:42.659843Z","shell.execute_reply.started":"2023-02-22T18:57:41.905725Z","shell.execute_reply":"2023-02-22T18:57:42.658459Z"},"trusted":true},"execution_count":null,"outputs":[]}]}