{"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":"markdown","source":"# Comparison of face detection packages","metadata":{}},{"cell_type":"markdown","source":"This notebook demonstrates the use of four face detection packages:\n\n1. facenet-pytorch: https://pypi.org/project/facenet-pytorch/\n1. mtcnn: https://pypi.org/project/mtcnn/\n1. dlib: https://pypi.org/project/dlib/\n1. haar :https://raw.githubusercontent.com/computationalcore/introduction-to-opencv/master/assets/haarcascade_frontalface_default.xml\n\n\nEach package is tested for its speed in detecting the faces in a set of 300 images (all frames from one video), with GPU support enabled. Detection is performed at 3 different resolutions. Any one-off initialization steps, such as model instantiation, are performed prior to performance testing.\n\nPlease let me know if you know of better/faster ways to use these packages.\n\n## Summary of results\n\n|Package|FPS (1080x1920)|FPS (720x1280)|FPS (540x960)|\n|-|-|-|\n|***facenet-pytorch***|12.97|20.32|25.50|\n|***facenet-pytorch (non-batched)***|9.75|14.81|19.68|\n|***dlib***|3.80|8.39|14.53|\n|***mtcnn***|3.04|5.70|8.23|\n","metadata":{}},{"cell_type":"markdown","source":"## Install packages\n\nNormally, each package can be installed with `pip install <package>`, but this notebook is offline to demonstrate their use in this competition.","metadata":{}},{"cell_type":"code","source":"!pip install /kaggle/input/facenet-pytorch-vggface2/facenet_pytorch-2.2.7-py3-none-any.whl\n!pip install /kaggle/input/dlibpkg/dlib-19.19.0\n!pip install /kaggle/input/mtcnn-package/mtcnn-0.1.0-py3-none-any.whl","metadata":{"execution":{"iopub.status.busy":"2022-02-27T17:31:05.856719Z","iopub.execute_input":"2022-02-27T17:31:05.857072Z","iopub.status.idle":"2022-02-27T17:42:45.778683Z","shell.execute_reply.started":"2022-02-27T17:31:05.857016Z","shell.execute_reply":"2022-02-27T17:42:45.777936Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import cv2\nimport numpy as np\nfrom matplotlib import pyplot as plt\nfrom PIL import Image\nimport torch\nfrom tqdm.notebook import tqdm\nimport time\n","metadata":{"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","execution":{"iopub.status.busy":"2022-02-27T17:42:45.781645Z","iopub.execute_input":"2022-02-27T17:42:45.782141Z","iopub.status.idle":"2022-02-27T17:42:46.976361Z","shell.execute_reply.started":"2022-02-27T17:42:45.782092Z","shell.execute_reply":"2022-02-27T17:42:46.975456Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Read in the frames of a video using cv2's `VideoCapture`.","metadata":{}},{"cell_type":"code","source":"sample = '/kaggle/input/deepfake-detection-challenge/train_sample_videos/aagfhgtpmv.mp4'\n\nreader = cv2.VideoCapture(sample)\nimages_1080_1920 = []\nimages_720_1280 = []\nimages_540_960 = []\nfor i in tqdm(range(int(reader.get(cv2.CAP_PROP_FRAME_COUNT)))):\n    _, image = reader.read()\n    image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)\n    images_1080_1920.append(image)\n    images_720_1280.append(cv2.resize(image, (1280, 720)))\n    images_540_960.append(cv2.resize(image, (960, 540)))\nreader.release()\n\nimages_1080_1920 = np.stack(images_1080_1920)\nimages_720_1280 = np.stack(images_720_1280)\nimages_540_960 = np.stack(images_540_960)\n\nprint('Shapes:')\nprint(images_1080_1920.shape)\nprint(images_720_1280.shape)\nprint(images_540_960.shape)","metadata":{"execution":{"iopub.status.busy":"2022-02-27T17:42:46.977783Z","iopub.execute_input":"2022-02-27T17:42:46.978159Z","iopub.status.idle":"2022-02-27T17:42:55.976869Z","shell.execute_reply.started":"2022-02-27T17:42:46.978102Z","shell.execute_reply":"2022-02-27T17:42:55.976138Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def plot_faces(images, figsize=(10.8/2, 19.2/2)):\n    shape = images[0].shape\n    images = images[np.linspace(0, len(images)-1, 16).astype(int)]\n    im_plot = []\n    for i in range(0, 16, 4):\n        im_plot.append(np.concatenate(images[i:i+4], axis=0))\n    im_plot = np.concatenate(im_plot, axis=1)\n    \n    fig, ax = plt.subplots(1, 1, figsize=figsize)\n    ax.imshow(im_plot)\n    ax.xaxis.set_visible(False)\n    ax.yaxis.set_visible(False)\n\n    ax.grid(False)\n    fig.tight_layout()\n\ndef timer(detector, detect_fn, images, *args):\n    start = time.time()\n    faces = detect_fn(detector, images, *args)\n    elapsed = time.time() - start\n    print(f', {elapsed:.3f} seconds')\n    return faces, elapsed","metadata":{"execution":{"iopub.status.busy":"2022-02-27T17:42:55.978817Z","iopub.execute_input":"2022-02-27T17:42:55.979301Z","iopub.status.idle":"2022-02-27T17:42:55.989534Z","shell.execute_reply.started":"2022-02-27T17:42:55.979248Z","shell.execute_reply":"2022-02-27T17:42:55.988846Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_faces(images_540_960, figsize=(10.8, 19.2))","metadata":{"execution":{"iopub.status.busy":"2022-02-27T17:42:55.994218Z","iopub.execute_input":"2022-02-27T17:42:55.994667Z","iopub.status.idle":"2022-02-27T17:42:56.72933Z","shell.execute_reply.started":"2022-02-27T17:42:55.994613Z","shell.execute_reply":"2022-02-27T17:42:56.725417Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## The facenet-pytorch package","metadata":{}},{"cell_type":"code","source":"device = 'cuda:0' if torch.cuda.is_available() else 'cpu'\n","metadata":{"execution":{"iopub.status.busy":"2022-02-27T17:42:56.730753Z","iopub.execute_input":"2022-02-27T17:42:56.731029Z","iopub.status.idle":"2022-02-27T17:42:56.77642Z","shell.execute_reply.started":"2022-02-27T17:42:56.730988Z","shell.execute_reply":"2022-02-27T17:42:56.775571Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from facenet_pytorch import MTCNN\ndetector = MTCNN(device=device, post_process=False)\n\ndef detect_facenet_pytorch(detector, images, batch_size):\n    faces = []\n    for lb in np.arange(0, len(images), batch_size):\n        imgs = [img for img in images[lb:lb+batch_size]]\n        faces.extend(detector(imgs))\n    return faces\n\ntimes_facenet_pytorch = []    # batched\ntimes_facenet_pytorch_nb = [] # non-batched","metadata":{"execution":{"iopub.status.busy":"2022-02-27T17:42:56.777822Z","iopub.execute_input":"2022-02-27T17:42:56.778263Z","iopub.status.idle":"2022-02-27T17:43:00.482124Z","shell.execute_reply.started":"2022-02-27T17:42:56.778202Z","shell.execute_reply":"2022-02-27T17:43:00.481277Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print('Detecting faces in 540x960 frames', end='')\n_, elapsed = timer(detector, detect_facenet_pytorch, images_540_960, 60)\ntimes_facenet_pytorch.append(elapsed)\n\nprint('Detecting faces in 720x1280 frames', end='')\n_, elapsed = timer(detector, detect_facenet_pytorch, images_720_1280, 40)\ntimes_facenet_pytorch.append(elapsed)\n\nprint('Detecting faces in 1080x1920 frames', end='')\nfaces, elapsed = timer(detector, detect_facenet_pytorch, images_1080_1920, 20)\ntimes_facenet_pytorch.append(elapsed)\n\nplot_faces(torch.stack(faces).permute(0, 2, 3, 1).int().numpy())","metadata":{"execution":{"iopub.status.busy":"2022-02-27T17:43:00.483914Z","iopub.execute_input":"2022-02-27T17:43:00.484235Z","iopub.status.idle":"2022-02-27T17:43:32.909775Z","shell.execute_reply.started":"2022-02-27T17:43:00.484186Z","shell.execute_reply":"2022-02-27T17:43:32.908913Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## The facenet-pytorch package (non-batched)","metadata":{}},{"cell_type":"code","source":"print('Detecting faces in 540x960 frames', end='')\n_, elapsed = timer(detector, detect_facenet_pytorch, images_540_960, 1)\ntimes_facenet_pytorch_nb.append(elapsed)\n\nprint('Detecting faces in 720x1280 frames', end='')\n_, elapsed = timer(detector, detect_facenet_pytorch, images_720_1280, 1)\ntimes_facenet_pytorch_nb.append(elapsed)\n\nprint('Detecting faces in 1080x1920 frames', end='')\nfaces, elapsed = timer(detector, detect_facenet_pytorch, images_1080_1920, 1)\ntimes_facenet_pytorch_nb.append(elapsed)","metadata":{"execution":{"iopub.status.busy":"2022-02-27T17:43:32.911271Z","iopub.execute_input":"2022-02-27T17:43:32.911757Z","iopub.status.idle":"2022-02-27T17:44:19.500933Z","shell.execute_reply.started":"2022-02-27T17:43:32.911709Z","shell.execute_reply":"2022-02-27T17:44:19.500059Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"del detector\ntorch.cuda.empty_cache()","metadata":{"execution":{"iopub.status.busy":"2022-02-27T17:44:19.502269Z","iopub.execute_input":"2022-02-27T17:44:19.502729Z","iopub.status.idle":"2022-02-27T17:44:19.814534Z","shell.execute_reply.started":"2022-02-27T17:44:19.502676Z","shell.execute_reply":"2022-02-27T17:44:19.813583Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## The dlib package","metadata":{}},{"cell_type":"code","source":"from dlib import get_frontal_face_detector\ndetector = get_frontal_face_detector()\n\ndef detect_dlib(detector, images):\n    faces = []\n    for image in images:\n        image_gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)\n        boxes = detector(image_gray)\n        box = boxes[0]\n        face = image[box.top():box.bottom(), box.left():box.right()]\n        faces.append(face)\n    return faces\n\ntimes_dlib = []","metadata":{"execution":{"iopub.status.busy":"2022-02-27T17:44:19.816053Z","iopub.execute_input":"2022-02-27T17:44:19.816384Z","iopub.status.idle":"2022-02-27T17:44:20.373503Z","shell.execute_reply.started":"2022-02-27T17:44:19.816333Z","shell.execute_reply":"2022-02-27T17:44:20.372757Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print('Detecting faces in 540x960 frames', end='')\n_, elapsed = timer(detector, detect_dlib, images_540_960)\ntimes_dlib.append(elapsed)\n\nprint('Detecting faces in 720x1280 frames', end='')\n_, elapsed = timer(detector, detect_dlib, images_720_1280)\ntimes_dlib.append(elapsed)\n\nprint('Detecting faces in 1080x1920 frames', end='')\nfaces, elapsed = timer(detector, detect_dlib, images_1080_1920)\ntimes_dlib.append(elapsed)\n\nplot_faces(np.stack([cv2.resize(f, (160, 160)) for f in faces]))","metadata":{"execution":{"iopub.status.busy":"2022-02-27T17:44:20.375055Z","iopub.execute_input":"2022-02-27T17:44:20.375344Z","iopub.status.idle":"2022-02-27T17:46:15.448617Z","shell.execute_reply.started":"2022-02-27T17:44:20.375297Z","shell.execute_reply":"2022-02-27T17:46:15.447838Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"del detector\ntorch.cuda.empty_cache()","metadata":{"execution":{"iopub.status.busy":"2022-02-27T17:46:15.449985Z","iopub.execute_input":"2022-02-27T17:46:15.45049Z","iopub.status.idle":"2022-02-27T17:46:15.454476Z","shell.execute_reply.started":"2022-02-27T17:46:15.450439Z","shell.execute_reply":"2022-02-27T17:46:15.453698Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## The mtcnn package","metadata":{}},{"cell_type":"code","source":"from mtcnn import MTCNN\ndetector = MTCNN()\n\ndef detect_mtcnn(detector, images):\n    faces = []\n    for image in images:\n        boxes = detector.detect_faces(image)\n        box = boxes[0]['box']\n        face = image[box[1]:box[3]+box[1], box[0]:box[2]+box[0]]\n        faces.append(face)\n    return faces\n\ntimes_mtcnn = []","metadata":{"execution":{"iopub.status.busy":"2022-02-27T17:46:15.455774Z","iopub.execute_input":"2022-02-27T17:46:15.45631Z","iopub.status.idle":"2022-02-27T17:46:21.897805Z","shell.execute_reply.started":"2022-02-27T17:46:15.456259Z","shell.execute_reply":"2022-02-27T17:46:21.897055Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print('Detecting faces in 540x960 frames', end='')\n_, elapsed = timer(detector, detect_mtcnn, images_540_960)\ntimes_mtcnn.append(elapsed)\n\nprint('Detecting faces in 720x1280 frames', end='')\n_, elapsed = timer(detector, detect_mtcnn, images_720_1280)\ntimes_mtcnn.append(elapsed)\n\nprint('Detecting faces in 1080x1920 frames', end='')\nfaces, elapsed = timer(detector, detect_mtcnn, images_1080_1920)\ntimes_mtcnn.append(elapsed)\n\nplot_faces(np.stack([cv2.resize(face, (160, 160)) for face in faces]))","metadata":{"execution":{"iopub.status.busy":"2022-02-27T17:46:21.899199Z","iopub.execute_input":"2022-02-27T17:46:21.899478Z","iopub.status.idle":"2022-02-27T17:49:18.796751Z","shell.execute_reply.started":"2022-02-27T17:46:21.899432Z","shell.execute_reply":"2022-02-27T17:49:18.795952Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"del detector\ntorch.cuda.empty_cache()","metadata":{"execution":{"iopub.status.busy":"2022-02-27T17:49:18.798338Z","iopub.execute_input":"2022-02-27T17:49:18.798903Z","iopub.status.idle":"2022-02-27T17:49:18.80359Z","shell.execute_reply.started":"2022-02-27T17:49:18.798822Z","shell.execute_reply":"2022-02-27T17:49:18.802445Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## The HAAR Cascade","metadata":{}},{"cell_type":"code","source":"detector = cv2.CascadeClassifier('/kaggle/input/haar-cascades-for-face-detection/haarcascade_frontalface_default.xml')\n\ndef detect_haar(detector, images):\n    faces = []\n    for image in images:\n        image_gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)\n        boxes = detector.detectMultiScale(image_gray, 1.3, 5)\n        for (bottom,left,right,top) in boxes:\n            boxes = image[left:left + top , bottom : bottom+right]\n            faces.append(boxes)\n    return faces\n\ntimes_haar = []","metadata":{"execution":{"iopub.status.busy":"2022-02-27T17:49:18.805288Z","iopub.execute_input":"2022-02-27T17:49:18.805921Z","iopub.status.idle":"2022-02-27T17:49:18.859699Z","shell.execute_reply.started":"2022-02-27T17:49:18.805871Z","shell.execute_reply":"2022-02-27T17:49:18.859063Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print('Detecting faces in 540x960 frames', end='')\n_, elapsed = timer(detector, detect_haar, images_540_960)\ntimes_haar.append(elapsed)\n\nprint('Detecting faces in 720x1280 frames', end='')\n_, elapsed = timer(detector, detect_haar, images_720_1280)\ntimes_haar.append(elapsed)\n\nprint('Detecting faces in 1080x1920 frames', end='')\nfaces, elapsed = timer(detector, detect_haar, images_1080_1920)\ntimes_haar.append(elapsed)\n\nplot_faces(np.stack([cv2.resize(f, (160, 160)) for f in faces]))","metadata":{"execution":{"iopub.status.busy":"2022-02-27T17:49:18.86133Z","iopub.execute_input":"2022-02-27T17:49:18.861807Z","iopub.status.idle":"2022-02-27T17:54:27.823691Z","shell.execute_reply.started":"2022-02-27T17:49:18.861621Z","shell.execute_reply":"2022-02-27T17:54:27.822843Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"del detector\ntorch.cuda.empty_cache()","metadata":{"execution":{"iopub.status.busy":"2022-02-27T17:54:27.825104Z","iopub.execute_input":"2022-02-27T17:54:27.825664Z","iopub.status.idle":"2022-02-27T17:54:27.829465Z","shell.execute_reply.started":"2022-02-27T17:54:27.825609Z","shell.execute_reply":"2022-02-27T17:54:27.828807Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Performance comparison","metadata":{}},{"cell_type":"code","source":"fig, ax = plt.subplots(figsize=(10,6))\n\npos = np.arange(3)\nplt.bar(pos, times_facenet_pytorch, 0.1, label='mtcnn')\nplt.bar(pos + 0.1, times_mtcnn, 0.1, label='facenet')\nplt.bar(pos + 0.2, times_dlib, 0.1, label='dlib')\nplt.bar(pos + 0.3, times_haar, 0.1, label='haar_casscade')\n\n\nax.set_ylabel('Elapsed time (seconds)')\nax.set_xlabel('Image resolution (pixels)')\nax.set_xticks(pos + 0.25)\nax.set_xticklabels(['540x960', '720x1280', '1080x1920'])\nplt.legend();","metadata":{"execution":{"iopub.status.busy":"2022-02-27T18:32:54.716151Z","iopub.execute_input":"2022-02-27T18:32:54.716571Z","iopub.status.idle":"2022-02-27T18:32:55.193013Z","shell.execute_reply.started":"2022-02-27T18:32:54.716481Z","shell.execute_reply":"2022-02-27T18:32:55.192227Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig, ax = plt.subplots(figsize=(10,6))\n\npos = np.arange(1)\nplt.bar(pos, times_facenet_pytorch, 0.1, label='facenet-pytorch')\nplt.bar(pos + 0.1, times_facenet_pytorch_nb, 0.1, label='facenet-pytorch (non-batched)')\nplt.bar(pos + 0.2, times_dlib, 0.1, label='dlib')\nplt.bar(pos + 0.3, times_mtcnn, 0.1, label='mtcnn')\nplt.bar(pos + 0.4, times_haar, 0.1, label='haar_casscade')\n\n\nax.set_ylabel('Elapsed time (seconds)')\nax.set_xticks(pos + 0.25)\nax.set_xticklabels(['540x960', '720x1280', '1080x1920'])\nplt.legend();","metadata":{"execution":{"iopub.status.busy":"2022-02-27T18:20:00.186259Z","iopub.execute_input":"2022-02-27T18:20:00.186572Z","iopub.status.idle":"2022-02-27T18:20:00.504448Z","shell.execute_reply.started":"2022-02-27T18:20:00.186518Z","shell.execute_reply":"2022-02-27T18:20:00.503602Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\n# creating the dataset\ndata = {'1 feet':74.7, '2 feet':78.3, '3 feet':84.8,\n        '4 feet':86.4,'5 feet':78.9,'5 feet':74.5,'7 feet':73.8,}\ncourses = list(data.keys())\nvalues = list(data.values())\n  \nfig = plt.figure(figsize = (10, 5))\n \n# creating the bar plot\nplt.bar(courses, values, color ='maroon',\n        width = 0.4)\n \nplt.xlabel(\"Distance of subject from camera\")\nplt.ylabel(\"Accuracy percentage\")\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-02-27T18:31:14.33607Z","iopub.execute_input":"2022-02-27T18:31:14.336371Z","iopub.status.idle":"2022-02-27T18:31:14.54007Z","shell.execute_reply.started":"2022-02-27T18:31:14.336321Z","shell.execute_reply":"2022-02-27T18:31:14.539297Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import numpy as np\nimport matplotlib.pyplot as plt\n# creating the dataset\ndata = {'10':83.4, '15':85.3,\n        '20':86.65,'25':89,'30':89.8}\ncourses = list(data.keys())\nvalues = list(data.values())\n  \nfig = plt.figure(figsize = (10, 5))\n \n# creating the bar plot\nplt.bar(courses, values, color ='maroon',\n        width = 0.2)\n \nplt.xlabel(\"Dataset Size\")\nplt.ylabel(\"Accuracy percentage (images per subject)\")\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:33:05.514962Z","iopub.execute_input":"2022-02-27T20:33:05.515257Z","iopub.status.idle":"2022-02-27T20:33:05.732847Z","shell.execute_reply.started":"2022-02-27T20:33:05.515209Z","shell.execute_reply":"2022-02-27T20:33:05.731935Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x = [1, 2, 3, 4]\nax1 = plt.subplot()\nax1.set_xticks(x)\nax1.set_yticks(x)\n\n# plot bar chart\n\nplt.bar(x,[83.4,85.3,86.65,89,89.8])\n\n# Define tick labels\n\nax1.set_xticklabels([\"10\",\"15\",\"20\",\"25\",\"30\"]) \nax1.set_yticklabels([80,85,90,95])\n\n# Display graph\n\n\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:41:16.060388Z","iopub.execute_input":"2022-02-27T20:41:16.060731Z","iopub.status.idle":"2022-02-27T20:41:16.240828Z","shell.execute_reply.started":"2022-02-27T20:41:16.060669Z","shell.execute_reply":"2022-02-27T20:41:16.237376Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x = [1, 2, 3, 4, 5,6,7]\nax1 = plt.subplot()\nax1.set_xticks(x)\nax1.set_yticks([10,20,30,40,50,60,70,80,90])\n\n# plot bar chart\nplt.bar(x,[75,78,84,86,79,75,73])\n\n# Define tick labels\n\nax1.set_xticklabels([\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\"]) \nax1.set_yticklabels([10,20,30,40,50,60,70,80,90])\nplt.xlabel(\"Distance of subject from camera\")\nplt.ylabel(\"Accuracy percentage\")\n# Display graph\n\n\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:54:05.517216Z","iopub.execute_input":"2022-02-27T20:54:05.517514Z","iopub.status.idle":"2022-02-27T20:54:05.700527Z","shell.execute_reply.started":"2022-02-27T20:54:05.517465Z","shell.execute_reply":"2022-02-27T20:54:05.699689Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}