{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.12.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"nvidiaTeslaT4","dataSources":[{"sourceId":16880,"databundleVersionId":858837,"sourceType":"competition"},{"sourceId":3134515,"sourceType":"datasetVersion","datasetId":1909705},{"sourceId":9146200,"sourceType":"datasetVersion","datasetId":5524489}],"dockerImageVersionId":31236,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":true}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"!pip install datasets\n!pip install -U -q evaluate transformers datasets>=2.14.5 accelerate>=0.27 2>/dev/null\n!pip install huggingface_hub","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-22T04:10:45.761612Z","iopub.execute_input":"2025-12-22T04:10:45.762254Z","iopub.status.idle":"2025-12-22T04:10:55.714191Z","shell.execute_reply.started":"2025-12-22T04:10:45.762226Z","shell.execute_reply":"2025-12-22T04:10:55.713282Z"},"collapsed":true,"jupyter":{"outputs_hidden":true}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!apt-get install git-lfs\n!git lfs install\n!git clone https://huggingface.co/datasets/yashduhan/DeepFakeDetection\n!GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/datasets/yashduhan/DeepFakeDetection","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-22T04:11:00.298394Z","iopub.execute_input":"2025-12-22T04:11:00.299115Z","iopub.status.idle":"2025-12-22T04:11:02.998421Z","shell.execute_reply.started":"2025-12-22T04:11:00.299079Z","shell.execute_reply":"2025-12-22T04:11:02.997566Z"},"collapsed":true,"jupyter":{"outputs_hidden":true}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!cd DeepFakeDetection && git lfs pull\n!ls DeepFakeDetection","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-22T04:11:08.961433Z","iopub.execute_input":"2025-12-22T04:11:08.962297Z","iopub.status.idle":"2025-12-22T04:11:09.217650Z","shell.execute_reply.started":"2025-12-22T04:11:08.962262Z","shell.execute_reply":"2025-12-22T04:11:09.216779Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import zipfile\n\nwith zipfile.ZipFile(\"/kaggle/working/DeepFakeDetection/DeepFakeDetection.zip\", 'r') as zip_ref:\n    zip_ref.extractall(\"/kaggle/working/dataset_extracted\")\n    \n!ls /kaggle/working/dataset_extracted","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-22T04:11:11.852038Z","iopub.execute_input":"2025-12-22T04:11:11.852327Z","iopub.status.idle":"2025-12-22T04:11:47.751187Z","shell.execute_reply.started":"2025-12-22T04:11:11.852299Z","shell.execute_reply":"2025-12-22T04:11:47.750474Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from torchvision import datasets\nfrom torchvision.transforms import ToTensor\nfrom torch.utils.data import DataLoader\n\ndata_dir = \"/kaggle/working/dataset_extracted\"\n\ndataset = datasets.ImageFolder(root=data_dir, transform=ToTensor())\nloader = DataLoader(dataset, batch_size=16, shuffle=True)\n\nprint(len(dataset))\nprint(dataset.classes)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-22T04:12:00.047605Z","iopub.execute_input":"2025-12-22T04:12:00.048364Z","iopub.status.idle":"2025-12-22T04:12:05.218928Z","shell.execute_reply.started":"2025-12-22T04:12:00.048333Z","shell.execute_reply":"2025-12-22T04:12:05.218246Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!ls /kaggle/working/dataset_extracted/DeepFakeDetection | head\n!ls /kaggle/working/dataset_extracted/DeepFakeDetection | wc -l\n","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2025-12-22T04:12:08.589685Z","iopub.execute_input":"2025-12-22T04:12:08.590391Z","iopub.status.idle":"2025-12-22T04:12:08.843779Z","shell.execute_reply.started":"2025-12-22T04:12:08.590355Z","shell.execute_reply":"2025-12-22T04:12:08.842913Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import os\nimport shutil\n\nsrc = \"/kaggle/working/dataset_extracted/DeepFakeDetection\"\ndst_real = \"/kaggle/working/data/real\"\ndst_fake = \"/kaggle/working/data/fake\"\n\nos.makedirs(dst_real, exist_ok=True)\nos.makedirs(dst_fake, exist_ok=True)\n\nfor file in os.listdir(src):\n    if \"real\" in file.lower():\n        shutil.move(os.path.join(src, file), os.path.join(dst_real, file))\n    elif \"fake\" in file.lower():\n        shutil.move(os.path.join(src, file), os.path.join(dst_fake, file))\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-22T04:12:17.943385Z","iopub.execute_input":"2025-12-22T04:12:17.943975Z","iopub.status.idle":"2025-12-22T04:12:17.949089Z","shell.execute_reply.started":"2025-12-22T04:12:17.943946Z","shell.execute_reply":"2025-12-22T04:12:17.948442Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!ls /kaggle/working/data/real | head\n!ls /kaggle/working/data/fake | head","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-22T04:12:24.535624Z","iopub.execute_input":"2025-12-22T04:12:24.536221Z","iopub.status.idle":"2025-12-22T04:12:24.786780Z","shell.execute_reply.started":"2025-12-22T04:12:24.536194Z","shell.execute_reply":"2025-12-22T04:12:24.786093Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_dir = \"/kaggle/working/data\"\n\ndataset = datasets.ImageFolder(root=data_dir, transform=ToTensor())\nloader = DataLoader(dataset, batch_size=16, shuffle=True)\n\nprint(dataset.classes)\nprint(len(dataset))\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-22T04:12:33.961765Z","iopub.execute_input":"2025-12-22T04:12:33.962578Z","iopub.status.idle":"2025-12-22T04:12:34.575328Z","shell.execute_reply.started":"2025-12-22T04:12:33.962542Z","shell.execute_reply":"2025-12-22T04:12:34.574691Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import os\n\npath1 = \"/kaggle/input/deepfake-detection-challenge\"\nprint(os.listdir(path1))\n\npath2 = \"/kaggle/input/deep-fake-detection-dfd-entire-original-dataset\"\nprint(os.listdir(path2))\n\npath3 = \"/kaggle/input/deepfake-and-real-images\"\nprint(os.listdir(path3))\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-22T04:12:46.322926Z","iopub.execute_input":"2025-12-22T04:12:46.323560Z","iopub.status.idle":"2025-12-22T04:12:46.330810Z","shell.execute_reply.started":"2025-12-22T04:12:46.323496Z","shell.execute_reply":"2025-12-22T04:12:46.330098Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_dir = \"/kaggle/input/deepfake-detection-challenge/train_sample_videos\"\n\nprint(len(os.listdir(train_dir)))\nprint(os.listdir(train_dir)[:10])\n\ntest_dir = \"/kaggle/input/deepfake-detection-challenge/test_videos\"\n\nprint(len(os.listdir(test_dir)))\nprint(os.listdir(test_dir)[:10])\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-22T04:12:49.362641Z","iopub.execute_input":"2025-12-22T04:12:49.363333Z","iopub.status.idle":"2025-12-22T04:12:49.370127Z","shell.execute_reply.started":"2025-12-22T04:12:49.363300Z","shell.execute_reply":"2025-12-22T04:12:49.369425Z"}},"outputs":[],"execution_count":null}]}