{ "cells": [ { "cell_type": "code", "execution_count": 1, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "WARNING:tensorflow:From C:\\Users\\fatik\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\tf_keras\\src\\losses.py:2976: The name tf.losses.sparse_softmax_cross_entropy is deprecated. Please use tf.compat.v1.losses.sparse_softmax_cross_entropy instead.\n", "\n" ] } ], "source": [ "import cv2\n", "from deepface import DeepFace\n", "import os\n", "from mtcnn import MTCNN" ], "metadata": { "collapsed": false, "ExecuteTime": { "end_time": "2024-03-29T11:51:18.815961100Z", "start_time": "2024-03-29T11:51:14.103338900Z" } } }, { "cell_type": "code", "execution_count": 3, "outputs": [], "source": [ "models = [\n", " \"VGG-Face\",\n", " \"Facenet\",\n", " \"Facenet512\",\n", " \"OpenFace\",\n", " \"DeepFace\",\n", " \"DeepID\",\n", " \"ArcFace\",\n", " \"Dlib\",\n", " \"SFace\",\n", " \"GhostFaceNet\",\n", "]\n", "backends = [\n", " 'opencv',\n", " 'ssd',\n", " 'dlib',\n", " 'mtcnn',\n", " 'retinaface',\n", " 'mediapipe',\n", " 'yolov8',\n", " 'yunet',\n", " 'fastmtcnn',\n", "]" ], "metadata": { "collapsed": false, "ExecuteTime": { "end_time": "2024-03-29T11:51:19.274075400Z", "start_time": "2024-03-29T11:51:19.216042200Z" } } }, { "cell_type": "code", "execution_count": null, "outputs": [ { "data": { "text/plain": " 0%| | 0/419 [00:00 1:\n", " continue\n", " for detection in detections:\n", " confidence = detection[\"confidence\"]\n", " if confidence > 0.9:\n", " x, y, w, h = detection[\"box\"]\n", " detected_face = img[int(y):int(y + h), int(x):int(x + w)]\n", " embedding = DeepFace.represent(detected_face, model_name='Facenet', enforce_detection=False)\n", " dicter3[f'{filename}_{i}'] = embedding[0][\"embedding\"]" ], "metadata": { "collapsed": false, "is_executing": true, "ExecuteTime": { "start_time": "2024-03-29T17:06:57.675570400Z" } } }, { "cell_type": "code", "execution_count": 29, "outputs": [], "source": [ "import pickle\n", "with open('actors_ussr_embeddings.pkl', 'wb') as f:\n", " pickle.dump(dicter3, f)" ], "metadata": { "collapsed": false, "ExecuteTime": { "end_time": "2024-03-29T17:05:49.924417200Z", "start_time": "2024-03-29T17:05:49.760230900Z" } } }, { "cell_type": "code", "execution_count": null, "outputs": [], "source": [], "metadata": { "collapsed": false } }, { "cell_type": "code", "execution_count": null, "outputs": [], "source": [], "metadata": { "collapsed": false } }, { "cell_type": "code", "execution_count": null, "outputs": [], "source": [], "metadata": { "collapsed": false } }, { "cell_type": "code", "execution_count": null, "outputs": [], "source": [], "metadata": { "collapsed": false } }, { "cell_type": "code", "execution_count": null, "outputs": [], "source": [], "metadata": { "collapsed": false } }, { "cell_type": "code", "execution_count": null, "outputs": [], "source": [], "metadata": { "collapsed": false } }, { "cell_type": "code", "execution_count": null, "outputs": [], "source": [], "metadata": { "collapsed": false } }, { "cell_type": "code", "execution_count": null, "outputs": [], "source": [], "metadata": { "collapsed": false } }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.6" } }, "nbformat": 4, "nbformat_minor": 0 }