{"cells":[{"metadata":{},"cell_type":"markdown","source":"# Detec face with dlib and recognition offline"},{"metadata":{},"cell_type":"markdown","source":"First import all dataset contain library you need. <br>\n* To install dlib without internet, add the dataset: https://www.kaggle.com/carlossouza/dlibpkg <br>\n* To install ace-recognition without internet, add the dataset: https://www.kaggle.com/minhtam/face-recognition"},{"metadata":{},"cell_type":"markdown","source":"Install dlib library"},{"metadata":{"trusted":true},"cell_type":"code","source":"!pip install '/kaggle/input/dlibpkg/dlib-19.19.0'\n","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Install face-recognition without internet"},{"metadata":{"trusted":true},"cell_type":"code","source":"!pip install '/kaggle/input/face-recognition/face_recognition_models-0.3.0/face_recognition_models-0.3.0'\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"!pip install '/kaggle/input/face-recognition/face_recognition-0.1.5-py2.py3-none-any.whl'\n","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"code","source":"\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\nimport os\nimport face_recognition\nimport cv2\nimport matplotlib.pyplot as plt\n","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","collapsed":true,"_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","trusted":false},"cell_type":"code","source":"v_cap = cv2.VideoCapture('/kaggle/input/deepfake-detection-challenge/test_videos/adohdulfwb.mp4')\nfor j in range(1):\n    success, vframe = v_cap.read()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"vframe = cv2.cvtColor(vframe,cv2.COLOR_BGR2RGB)\nplt.imshow(vframe)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":" \nface_positions = face_recognition.face_locations(vframe)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"for face_position in face_positions:\n    y0,x1,y1,x0 = face_position\n    img = cv2.rectangle(vframe,(x0,y0),(x1,y1),(255,0,0),5)\nplt.imshow(img)\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"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":4,"nbformat_minor":1}