{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "provenance": [], "mount_file_id": "https://github.com/shiveshnavin/face-match/blob/main/Face_Match.ipynb", "authorship_tag": "ABX9TyOtcib13s1Sgzm0u1C/LhwW", "include_colab_link": true }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "language_info": { "name": "python" } }, "cells": [ { "cell_type": "markdown", "metadata": { "id": "view-in-github", "colab_type": "text" }, "source": [ "\"Open" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "sKpUFCOofQWa" }, "outputs": [], "source": [ "!pip install deepface" ] }, { "cell_type": "code", "source": [ "from deepface import DeepFace" ], "metadata": { "id": "PFKyr3S3js5g" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "import os" ], "metadata": { "id": "JN2LNi7wlluR" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "dir = '/content/drive/MyDrive/colab/face-match'" ], "metadata": { "id": "P6I4Q5poju2r" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "!cd /content/drive/MyDrive/colab/face-match && wget -O shivesh-hd.jpeg https://miro.medium.com/v2/resize:fit:2400/1*ohF2nXtuZx624xTKwlG9MQ.jpeg" ], "metadata": { "id": "eetSAvDhofhb" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "!ls /content/drive/MyDrive/colab/face-match" ], "metadata": { "id": "4t3-O_5Bni0t" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "hd_train = os.path.join(dir, 'bhat-hd.jpg')\n", "sd_train = os.path.join(dir, 'bhat-sd.jpg')\n", "\n", "hd_test = os.path.join(dir, 'bhat-test-hd.jpeg')\n", "sd_test = os.path.join(dir, 'bhat-test-sd.jpeg')\n", "\n", "hd_unknown = os.path.join(dir, 'shivesh-hd.jpeg')" ], "metadata": { "id": "YayGIZgotAF5" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "result = DeepFace.verify(\n", " img1_path = os.path.join(dir, 'shivesh-hd.jpeg'),\n", " img2_path = os.path.join(dir, 'bhat-hd.jpg'),\n", ")\n", "result" ], "metadata": { "id": "PhPwnGoWop1C" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "result = DeepFace.verify(\n", " img1_path = os.path.join(dir, 'bhat-test-hd.jpeg'),\n", " img2_path = os.path.join(dir, 'bhat-test-hd.jpeg'),\n", ")\n", "result" ], "metadata": { "id": "h6OwutnBlgKe" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "!ls /content/drive/MyDrive/colab/face-match/bhat-test-sd.jpg" ], "metadata": { "id": "hXGLf_Mgn2gV" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "!pip3 install face_recognition" ], "metadata": { "id": "ALwbcczEn8wg" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [], "metadata": { "id": "Wkn4Z44Rs-HY" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "import face_recognition\n", "image = face_recognition.load_image_file(\"your_file.jpg\")\n", "face_locations = face_recognition.face_locations(image)" ], "metadata": { "id": "06ckkNXqsqfF" }, "execution_count": null, "outputs": [] } ] }