{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.6.6","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":16880,"databundleVersionId":858837,"sourceType":"competition"},{"sourceId":854304,"sourceType":"datasetVersion","datasetId":452468}],"dockerImageVersionId":29844,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"!pip install seaborn","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2024-02-09T09:11:54.912132Z","iopub.execute_input":"2024-02-09T09:11:54.912536Z","iopub.status.idle":"2024-02-09T09:11:59.859042Z","shell.execute_reply.started":"2024-02-09T09:11:54.912476Z","shell.execute_reply":"2024-02-09T09:11:59.857818Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!pip install opendatasets","metadata":{"execution":{"iopub.status.busy":"2024-02-09T09:11:59.862584Z","iopub.execute_input":"2024-02-09T09:11:59.862919Z","iopub.status.idle":"2024-02-09T09:12:06.229734Z","shell.execute_reply.started":"2024-02-09T09:11:59.862866Z","shell.execute_reply":"2024-02-09T09:12:06.228657Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nimport os\nimport seaborn as sns\nimport matplotlib.pyplot as plt\nfrom tqdm import tqdm_notebook\n%matplotlib inline\nimport cv2 as cv","metadata":{"execution":{"iopub.status.busy":"2024-02-09T09:12:06.232953Z","iopub.execute_input":"2024-02-09T09:12:06.233389Z","iopub.status.idle":"2024-02-09T09:12:06.243024Z","shell.execute_reply.started":"2024-02-09T09:12:06.233320Z","shell.execute_reply":"2024-02-09T09:12:06.241927Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"DATA_FOLDER = '/kaggle/input/deepfake-detection-challenge'\nTRAIN_SAMPLE_FOLDER = 'train_sample_videos'\nTEST_FOLDER = 'test_videos'\n\nprint(f\"Train samples: {len(os.listdir(os.path.join(DATA_FOLDER, TRAIN_SAMPLE_FOLDER)))}\")\nprint(f\"Test samples: {len(os.listdir(os.path.join(DATA_FOLDER, TEST_FOLDER)))}\")","metadata":{"execution":{"iopub.status.busy":"2024-02-09T09:12:06.245094Z","iopub.execute_input":"2024-02-09T09:12:06.245531Z","iopub.status.idle":"2024-02-09T09:12:06.256079Z","shell.execute_reply.started":"2024-02-09T09:12:06.245456Z","shell.execute_reply":"2024-02-09T09:12:06.254972Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"FACE_DETECTION_FOLDER = '/kaggle/input/haar-cascades-for-face-detection'\nprint(f\"Face detection resources: {os.listdir(FACE_DETECTION_FOLDER)}\")","metadata":{"execution":{"iopub.status.busy":"2024-02-09T09:12:06.259045Z","iopub.execute_input":"2024-02-09T09:12:06.259345Z","iopub.status.idle":"2024-02-09T09:12:06.268197Z","shell.execute_reply.started":"2024-02-09T09:12:06.259296Z","shell.execute_reply":"2024-02-09T09:12:06.267387Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_list = list(os.listdir(os.path.join(DATA_FOLDER, TRAIN_SAMPLE_FOLDER)))\next_dict = []\nfor file in train_list:\n  file_ext = file.split('.')[1]\n  if (file_ext not in ext_dict):\n    ext_dict.append(file_ext)\nprint(f\"Extension: {ext_dict}\")","metadata":{"execution":{"iopub.status.busy":"2024-02-09T09:12:06.270681Z","iopub.execute_input":"2024-02-09T09:12:06.270968Z","iopub.status.idle":"2024-02-09T09:12:06.280516Z","shell.execute_reply.started":"2024-02-09T09:12:06.270928Z","shell.execute_reply":"2024-02-09T09:12:06.279757Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for file_ext in ext_dict:\n  print(f\"Files with extension '{file_ext} : {len([file for file in train_list if file.endswith(file_ext)])}\")","metadata":{"execution":{"iopub.status.busy":"2024-02-09T09:12:06.281670Z","iopub.execute_input":"2024-02-09T09:12:06.282181Z","iopub.status.idle":"2024-02-09T09:12:06.290303Z","shell.execute_reply.started":"2024-02-09T09:12:06.282135Z","shell.execute_reply":"2024-02-09T09:12:06.289316Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_list = list(os.listdir(os.path.join(DATA_FOLDER, TEST_FOLDER)))\next_dict = []\nfor file in test_list :\n  file_ext = file.split('.')[1]\n  if (file_ext not in ext_dict):\n    ext_dict.append(file_ext)\nprint(f\"Extension: {ext_dict}\")\nfor file_ext in ext_dict:\n  print(f\"Files with extension '{file_ext}' : {len([file for file in train_list if file.endswith(file_ext)])}\")","metadata":{"execution":{"iopub.status.busy":"2024-02-09T09:12:06.291995Z","iopub.execute_input":"2024-02-09T09:12:06.292529Z","iopub.status.idle":"2024-02-09T09:12:06.310009Z","shell.execute_reply.started":"2024-02-09T09:12:06.292479Z","shell.execute_reply":"2024-02-09T09:12:06.308838Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"json_file = [file for file in train_list if file.endswith('json')][0]\nprint(f\"JSON file : {json_file}\")","metadata":{"execution":{"iopub.status.busy":"2024-02-09T09:12:06.311618Z","iopub.execute_input":"2024-02-09T09:12:06.312127Z","iopub.status.idle":"2024-02-09T09:12:06.318792Z","shell.execute_reply.started":"2024-02-09T09:12:06.312078Z","shell.execute_reply":"2024-02-09T09:12:06.317652Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def get_meta_from_json(path):\n  df = pd.read_json(os.path.join(DATA_FOLDER, path, json_file))\n  df = df.T\n  return df\n\nmeta_train_df = get_meta_from_json(TRAIN_SAMPLE_FOLDER)\nmeta_train_df.head()","metadata":{"execution":{"iopub.status.busy":"2024-02-09T09:12:06.320308Z","iopub.execute_input":"2024-02-09T09:12:06.320855Z","iopub.status.idle":"2024-02-09T09:12:06.505103Z","shell.execute_reply.started":"2024-02-09T09:12:06.320802Z","shell.execute_reply":"2024-02-09T09:12:06.504340Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#missing_data\ndef missing_data(data):\n  total = data.isnull().sum()\n  percent = (data.isnull().sum()/data.isnull().count()*100)\n  tt = pd.concat([total, percent], axis = 1, keys = ['Total', 'Percent'])\n  types = []\n  for col in data.columns:\n    dtype = str(data[col].dtype)\n    types.append(dtype)\n  tt['Types'] = types\n  return(np.transpose(tt))","metadata":{"execution":{"iopub.status.busy":"2024-02-09T09:12:06.506244Z","iopub.execute_input":"2024-02-09T09:12:06.506669Z","iopub.status.idle":"2024-02-09T09:12:06.513170Z","shell.execute_reply.started":"2024-02-09T09:12:06.506624Z","shell.execute_reply":"2024-02-09T09:12:06.512484Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"missing_data(meta_train_df)","metadata":{"execution":{"iopub.status.busy":"2024-02-09T09:12:06.514322Z","iopub.execute_input":"2024-02-09T09:12:06.514698Z","iopub.status.idle":"2024-02-09T09:12:06.540749Z","shell.execute_reply.started":"2024-02-09T09:12:06.514657Z","shell.execute_reply":"2024-02-09T09:12:06.539972Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"missing_data(meta_train_df.loc[meta_train_df.label == 'REAL'])","metadata":{"execution":{"iopub.status.busy":"2024-02-09T09:12:06.542142Z","iopub.execute_input":"2024-02-09T09:12:06.542648Z","iopub.status.idle":"2024-02-09T09:12:06.564773Z","shell.execute_reply.started":"2024-02-09T09:12:06.542599Z","shell.execute_reply":"2024-02-09T09:12:06.563567Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def unique_values(data):\n  total = data.count()\n  tt = pd.DataFrame(total)\n  tt.columns = ['Total']\n  uniques = []\n  for col in data.columns:\n    unique = data[col].nunique()\n    uniques.append(unique)\n  tt['Uniques'] = uniques\n  return(np.transpose(tt))","metadata":{"execution":{"iopub.status.busy":"2024-02-09T09:12:06.566606Z","iopub.execute_input":"2024-02-09T09:12:06.566962Z","iopub.status.idle":"2024-02-09T09:12:06.576976Z","shell.execute_reply.started":"2024-02-09T09:12:06.566901Z","shell.execute_reply":"2024-02-09T09:12:06.576084Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"unique_values(meta_train_df)","metadata":{"execution":{"iopub.status.busy":"2024-02-09T09:12:06.578557Z","iopub.execute_input":"2024-02-09T09:12:06.579117Z","iopub.status.idle":"2024-02-09T09:12:06.603849Z","shell.execute_reply.started":"2024-02-09T09:12:06.579049Z","shell.execute_reply":"2024-02-09T09:12:06.602791Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def most_frequent_values(data):\n  total = data.count()\n  tt = pd.DataFrame(total)\n  tt.columns = ['Total']\n  items = []\n  vals = []\n  for col in data.columns:\n    itm = data[col].value_counts().index[0]\n    val = data[col].value_counts().values[0]\n    items.append(itm)\n    vals.append(val)\n  tt['Most frequent item'] = items\n  tt['Frequence'] = vals\n  tt['Percent from total'] = np.round(vals/ total * 100 ,3)\n  return(np.transpose(tt))","metadata":{"execution":{"iopub.status.busy":"2024-02-09T09:12:06.605833Z","iopub.execute_input":"2024-02-09T09:12:06.606520Z","iopub.status.idle":"2024-02-09T09:12:06.615862Z","shell.execute_reply.started":"2024-02-09T09:12:06.606450Z","shell.execute_reply":"2024-02-09T09:12:06.614746Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"most_frequent_values(meta_train_df)","metadata":{"execution":{"iopub.status.busy":"2024-02-09T09:12:06.618233Z","iopub.execute_input":"2024-02-09T09:12:06.618674Z","iopub.status.idle":"2024-02-09T09:12:06.651021Z","shell.execute_reply.started":"2024-02-09T09:12:06.618591Z","shell.execute_reply":"2024-02-09T09:12:06.649806Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"meta = np.array(list(meta_train_df.index))\nstorage = np.array([file for file in train_list if file.endswith('mp4')])\nprint(f\"Metadata: {meta.shape[0]}, Folder: {storage.shape[0]}\")\nprint(f\"Files in metadata and not in Folder: {np.setdiff1d(meta, storage, assume_unique = False).shape[0]}\")\nprint(f\"Files in folder and not in metadata:{np.setdiff1d(storage, meta, assume_unique = False).shape[0]}\")","metadata":{"execution":{"iopub.status.busy":"2024-02-09T09:12:06.652610Z","iopub.execute_input":"2024-02-09T09:12:06.652928Z","iopub.status.idle":"2024-02-09T09:12:06.662918Z","shell.execute_reply.started":"2024-02-09T09:12:06.652869Z","shell.execute_reply":"2024-02-09T09:12:06.661777Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fake_train_sample_video = list(meta_train_df.loc[meta_train_df.label=='FAKE'].sample(3).index)\nfake_train_sample_video","metadata":{"execution":{"iopub.status.busy":"2024-02-09T09:12:06.664592Z","iopub.execute_input":"2024-02-09T09:12:06.664937Z","iopub.status.idle":"2024-02-09T09:12:06.675347Z","shell.execute_reply.started":"2024-02-09T09:12:06.664887Z","shell.execute_reply":"2024-02-09T09:12:06.674355Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def display_image_from_video(video_path):\n    capture_image = cv.VideoCapture(video_path)\n    ret, frame = capture_image.read()\n    fig = plt.figure(figsize = (10, 10))\n    ax = fig.add_subplot(111)\n    frame = cv.cvtColor(frame, cv.COLOR_BGR2RGB)\n    ax.imshow(frame)","metadata":{"execution":{"iopub.status.busy":"2024-02-09T09:12:06.676442Z","iopub.execute_input":"2024-02-09T09:12:06.676708Z","iopub.status.idle":"2024-02-09T09:12:06.685362Z","shell.execute_reply.started":"2024-02-09T09:12:06.676664Z","shell.execute_reply":"2024-02-09T09:12:06.684010Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for video_file in fake_train_sample_video:\n    display_image_from_video(os.path.join(DATA_FOLDER, TRAIN_SAMPLE_FOLDER, video_file))","metadata":{"execution":{"iopub.status.busy":"2024-02-09T09:12:06.686762Z","iopub.execute_input":"2024-02-09T09:12:06.687018Z","iopub.status.idle":"2024-02-09T09:12:08.567566Z","shell.execute_reply.started":"2024-02-09T09:12:06.686981Z","shell.execute_reply":"2024-02-09T09:12:08.566580Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#for real videos\nreal_train_sample_video = list(meta_train_df.loc[meta_train_df.label == 'REAL'].sample(3).index)\nreal_train_sample_video","metadata":{"execution":{"iopub.status.busy":"2024-02-09T09:12:08.569320Z","iopub.execute_input":"2024-02-09T09:12:08.570060Z","iopub.status.idle":"2024-02-09T09:12:08.581370Z","shell.execute_reply.started":"2024-02-09T09:12:08.569884Z","shell.execute_reply":"2024-02-09T09:12:08.580174Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for video in real_train_sample_video:\n    display_image_from_video(os.path.join(DATA_FOLDER, TRAIN_SAMPLE_FOLDER, video_file))","metadata":{"execution":{"iopub.status.busy":"2024-02-09T09:12:08.583131Z","iopub.execute_input":"2024-02-09T09:12:08.583483Z","iopub.status.idle":"2024-02-09T09:12:10.356179Z","shell.execute_reply.started":"2024-02-09T09:12:08.583430Z","shell.execute_reply":"2024-02-09T09:12:10.355064Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"meta_train_df['original'].value_counts()[0:5]","metadata":{"execution":{"iopub.status.busy":"2024-02-09T09:12:10.357913Z","iopub.execute_input":"2024-02-09T09:12:10.358500Z","iopub.status.idle":"2024-02-09T09:12:10.369983Z","shell.execute_reply.started":"2024-02-09T09:12:10.358431Z","shell.execute_reply":"2024-02-09T09:12:10.368797Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def display_image_from_video_list(video_path_list, video_folder = TRAIN_SAMPLE_FOLDER):\n    plt.figure()\n    fig, ax = plt.subplots(2, 3 , figsize = (16, 8))\n    for i, video_file in enumerate(video_path_list[0:6]):\n        video_path = os.path.join(DATA_FOLDER, video_folder, video_file)\n        capture_image = cv.VideoCapture(video_path)\n        ret, frame = capture_image.read()\n        frame = cv.cvtColor(frame, cv.COLOR_BGR2RGB)\n        ax[i//3, i%3].imshow(frame)\n        ax[i//3, i%3].set_title(f\"Video:{video_file}\")\n        ax[i//3, i%3].axis('on')","metadata":{"execution":{"iopub.status.busy":"2024-02-09T09:12:10.371840Z","iopub.execute_input":"2024-02-09T09:12:10.372254Z","iopub.status.idle":"2024-02-09T09:12:10.382307Z","shell.execute_reply.started":"2024-02-09T09:12:10.372163Z","shell.execute_reply":"2024-02-09T09:12:10.380881Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"same_original_fake_train_sample_video = list(meta_train_df.loc[meta_train_df.original=='meawmsgiti.mp4'].index)\ndisplay_image_from_video_list(same_original_fake_train_sample_video)","metadata":{"execution":{"iopub.status.busy":"2024-02-09T09:12:10.383904Z","iopub.execute_input":"2024-02-09T09:12:10.384223Z","iopub.status.idle":"2024-02-09T09:12:12.435734Z","shell.execute_reply.started":"2024-02-09T09:12:10.384152Z","shell.execute_reply":"2024-02-09T09:12:12.434492Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"same_original_fake_train_sample_video = list(meta_train_df.loc[meta_train_df.original=='atvmxvwyns.mp4'].index)\ndisplay_image_from_video_list(same_original_fake_train_sample_video)","metadata":{"execution":{"iopub.status.busy":"2024-02-09T09:12:12.437420Z","iopub.execute_input":"2024-02-09T09:12:12.437742Z","iopub.status.idle":"2024-02-09T09:12:14.544731Z","shell.execute_reply.started":"2024-02-09T09:12:12.437682Z","shell.execute_reply":"2024-02-09T09:12:14.543241Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#test video file\ntest_videos = pd.DataFrame(list(os.listdir(os.path.join(DATA_FOLDER, TEST_FOLDER))), columns = ['video'])","metadata":{"execution":{"iopub.status.busy":"2024-02-09T09:12:14.546726Z","iopub.execute_input":"2024-02-09T09:12:14.547107Z","iopub.status.idle":"2024-02-09T09:12:14.554570Z","shell.execute_reply.started":"2024-02-09T09:12:14.547046Z","shell.execute_reply":"2024-02-09T09:12:14.553280Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_videos.head()","metadata":{"execution":{"iopub.status.busy":"2024-02-09T09:12:14.556428Z","iopub.execute_input":"2024-02-09T09:12:14.556838Z","iopub.status.idle":"2024-02-09T09:12:14.574796Z","shell.execute_reply.started":"2024-02-09T09:12:14.556762Z","shell.execute_reply":"2024-02-09T09:12:14.573655Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"display_image_from_video(os.path.join(DATA_FOLDER, TEST_FOLDER, test_videos.iloc[0].video))","metadata":{"execution":{"iopub.status.busy":"2024-02-09T09:12:14.576274Z","iopub.execute_input":"2024-02-09T09:12:14.576595Z","iopub.status.idle":"2024-02-09T09:12:15.055275Z","shell.execute_reply.started":"2024-02-09T09:12:14.576539Z","shell.execute_reply":"2024-02-09T09:12:15.054523Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"display_image_from_video_list(test_videos.sample(6).video, TEST_FOLDER)","metadata":{"execution":{"iopub.status.busy":"2024-02-09T09:12:15.056554Z","iopub.execute_input":"2024-02-09T09:12:15.057161Z","iopub.status.idle":"2024-02-09T09:12:17.838959Z","shell.execute_reply.started":"2024-02-09T09:12:15.057091Z","shell.execute_reply":"2024-02-09T09:12:17.837600Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#BUILDING FACE DETECTION\nclass ObjectDetector():\n    def __init__(self, object_cascade_path):\n        self.objectCascade =  cv.CascadeClassifier(object_cascade_path)\n    def detect(self, image, scale_factor = 1.3, min_neighbors = 5, min_size = (20,20)):\n        rects = self.objectCascade.detectMultiScale(image, scaleFactor = scale_factor, minNeighbors = min_neighbors, minSize = min_size)\n        return rects","metadata":{"execution":{"iopub.status.busy":"2024-02-09T09:12:17.842873Z","iopub.execute_input":"2024-02-09T09:12:17.843186Z","iopub.status.idle":"2024-02-09T09:12:17.850133Z","shell.execute_reply.started":"2024-02-09T09:12:17.843137Z","shell.execute_reply":"2024-02-09T09:12:17.849128Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"frontal_cascade_path = os.path.join(FACE_DETECTION_FOLDER, 'haarcascade_frontalface_default.xml')\neye_cascade_path = os.path.join(FACE_DETECTION_FOLDER, 'haarcascade_eye.xml')\nprofile_cascade_path = os.path.join(FACE_DETECTION_FOLDER, 'haarcascade_profileface.xml')\nsmile_cascade_path = os.path.join(FACE_DETECTION_FOLDER, 'haarcascade_smile.xml')\n\nfd = ObjectDetector(frontal_cascade_path)\ned = ObjectDetector(eye_cascade_path)\npdf = ObjectDetector(profile_cascade_path)\nsd = ObjectDetector(smile_cascade_path)","metadata":{"execution":{"iopub.status.busy":"2024-02-09T09:12:17.851869Z","iopub.execute_input":"2024-02-09T09:12:17.852148Z","iopub.status.idle":"2024-02-09T09:12:17.937272Z","shell.execute_reply.started":"2024-02-09T09:12:17.852100Z","shell.execute_reply":"2024-02-09T09:12:17.936365Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def detect_objects(image, scale_factor, min_neighbors, min_size):\n    image_gray = cv.cvtColor(image, cv.COLOR_BGR2GRAY)\n    eyes = ed.detect(image_gray,scale_factor = scale_factor, min_neighbors = min_neighbors, min_size = (int(min_size[0]/2), int(min_size[1]/2)))\n    for x, y, w, h in eyes:\n        cv.circle(image, (int(x*w/2), int(y+h/2)), (int((w+h)/4)), (0,0,255),3)\n    profiles = pdf.detect(image_gray, scale_factor = scale_factor, min_neighbors = min_neighbors, min_size = min_size)\n    for x, y, w, h in profiles:\n        cv.rectangle(image, (x,y),(x+w, y+h), (255,0,0),3)\n    faces = fd.detect(image_gray, scale_factor = scale_factor, min_neighbors = min_neighbors, min_size = min_size)\n    for x, y, w, h in faces:\n        cv.rectangle(image, (x,y), (x+w, y+h), (0,255,0),3)\n    fig = plt.figure(figsize = (10,10))\n    ax = fig.add_subplot(111)\n    image = cv.cvtColor(image, cv.COLOR_BGR2RGB)\n    ax.imshow(image)","metadata":{"execution":{"iopub.status.busy":"2024-02-09T09:45:54.799801Z","iopub.execute_input":"2024-02-09T09:45:54.800218Z","iopub.status.idle":"2024-02-09T09:45:54.813246Z","shell.execute_reply.started":"2024-02-09T09:45:54.800151Z","shell.execute_reply":"2024-02-09T09:45:54.812075Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def extract_image_objects(video_file, video_set_folder = TRAIN_SAMPLE_FOLDER):\n    video_path = os.path.join(DATA_FOLDER, video_set_folder, video_file)\n    capture_image = cv.VideoCapture(video_path)\n    ret, frame = capture_image.read()\n    detect_objects(image = frame, scale_factor = 1.3, min_neighbors = 5, min_size = (50,50))","metadata":{"execution":{"iopub.status.busy":"2024-02-09T09:45:55.960365Z","iopub.execute_input":"2024-02-09T09:45:55.961016Z","iopub.status.idle":"2024-02-09T09:45:55.967412Z","shell.execute_reply.started":"2024-02-09T09:45:55.960929Z","shell.execute_reply":"2024-02-09T09:45:55.966152Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"same_original_fake_train_sample_video = list(meta_train_df.loc[meta_train_df.original == 'kgbkktcjxf.mp4'].index)\nfor video_file in same_original_fake_train_sample_video[1:4]:\n    print(video_file)\n    extract_image_objects(video_file)","metadata":{"execution":{"iopub.status.busy":"2024-02-09T09:45:56.488420Z","iopub.execute_input":"2024-02-09T09:45:56.488786Z","iopub.status.idle":"2024-02-09T09:45:58.946841Z","shell.execute_reply.started":"2024-02-09T09:45:56.488736Z","shell.execute_reply":"2024-02-09T09:45:58.945542Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}