{"id":13747176,"url":"https://github.com/alyssaq/face_morpher","last_synced_at":"2025-05-15T21:01:44.453Z","repository":{"id":28265523,"uuid":"31775800","full_name":"alyssaq/face_morpher","owner":"alyssaq","description":":angel: Morph faces with Python, Numpy, Scipy","archived":false,"fork":false,"pushed_at":"2021-12-31T18:01:59.000Z","size":77398,"stargazers_count":890,"open_issues_count":40,"forks_count":232,"subscribers_count":42,"default_branch":"dlib","last_synced_at":"2025-04-01T04:54:01.263Z","etag":null,"topics":["numpy","opencv","python","python3"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alyssaq.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-06T15:34:49.000Z","updated_at":"2025-03-20T06:42:26.000Z","dependencies_parsed_at":"2022-07-27T16:33:28.598Z","dependency_job_id":null,"html_url":"https://github.com/alyssaq/face_morpher","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alyssaq%2Fface_morpher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alyssaq%2Fface_morpher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alyssaq%2Fface_morpher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alyssaq%2Fface_morpher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alyssaq","download_url":"https://codeload.github.com/alyssaq/face_morpher/tar.gz/refs/heads/dlib","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247801155,"owners_count":20998338,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["numpy","opencv","python","python3"],"created_at":"2024-08-03T06:01:19.181Z","updated_at":"2025-04-08T08:11:18.095Z","avatar_url":"https://github.com/alyssaq.png","language":"Python","readme":"Face Morpher\n============\n\n| Warp, average and morph human faces!\n| Scripts will automatically detect frontal faces and skip images if\n  none is detected.\n\nBuilt with Python, `dlib`_, Numpy, Scipy, dlib.\n\n| Supported on Python 2.7, Python 3.6+\n| Tested on macOS Mojave and 64bit Linux (dockerized).\n\nRequirements\n--------------\n-  ``pip install -r requirements.txt``\n- Download `http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2` and extract file.\n- Export environment variable ``DLIB_DATA_DIR`` to the folder where ``shape_predictor_68_face_landmarks.dat`` is located. Default ``data``. E.g ``export DLIB_DATA_DIR=/Downloads/data``\n\nEither:\n\n-  `Use as local command-line utility`_\n-  `Use as pip library`_\n-  `Try out in a docker container`_\n\n.. _`Use as local command-line utility`:\n\nUse as local command-line utility\n---------------------------------\n::\n\n    $ git clone https://github.com/alyssaq/face_morpher\n\nMorphing Faces\n--------------\n\nMorph from a source to destination image:\n\n::\n\n    python facemorpher/morpher.py --src=\u003csrc_imgpath\u003e --dest=\u003cdest_imgpath\u003e --plot\n\nMorph through a series of images in a folder:\n\n::\n\n    python facemorpher/morpher.py --images=\u003cfolder\u003e --out_video=out.avi\n\nAll options listed in ``morpher.py`` (pasted below):\n\n::\n\n    Morph from source to destination face or\n    Morph through all images in a folder\n\n    Usage:\n        morpher.py (--src=\u003csrc_path\u003e --dest=\u003cdest_path\u003e | --images=\u003cfolder\u003e)\n                [--width=\u003cwidth\u003e] [--height=\u003cheight\u003e]\n                [--num=\u003cnum_frames\u003e] [--fps=\u003cframes_per_second\u003e]\n                [--out_frames=\u003cfolder\u003e] [--out_video=\u003cfilename\u003e]\n                [--plot] [--background=(black|transparent|average)]\n\n    Options:\n        -h, --help              Show this screen.\n        --src=\u003csrc_imgpath\u003e     Filepath to source image (.jpg, .jpeg, .png)\n        --dest=\u003cdest_imgpath\u003e   Filepath to destination image (.jpg, .jpeg, .png)\n        --images=\u003cfolder\u003e       Folderpath to images\n        --width=\u003cwidth\u003e         Custom width of the images/video [default: 500]\n        --height=\u003cheight\u003e       Custom height of the images/video [default: 600]\n        --num=\u003cnum_frames\u003e      Number of morph frames [default: 20]\n        --fps=\u003cfps\u003e             Number frames per second for the video [default: 10]\n        --out_frames=\u003cfolder\u003e   Folder path to save all image frames\n        --out_video=\u003cfilename\u003e  Filename to save a video\n        --plot                  Flag to plot images to result.png [default: False]\n        --background=\u003cbg\u003e       Background of images to be one of (black|transparent|average) [default: black]\n        --version               Show version.\n\nAveraging Faces\n---------------\n\nAverage faces from all images in a folder:\n\n::\n\n    python facemorpher/averager.py --images=\u003cimages_folder\u003e --out=average.png\n\nAll options listed in ``averager.py`` (pasted below):\n\n::\n\n    Face averager\n\n    Usage:\n        averager.py --images=\u003cimages_folder\u003e [--blur] [--plot]\n                [--background=(black|transparent|average)]\n                [--width=\u003cwidth\u003e] [--height=\u003cheight\u003e]\n                [--out=\u003cfilename\u003e] [--destimg=\u003cfilename\u003e]\n\n    Options:\n        -h, --help             Show this screen.\n        --images=\u003cfolder\u003e      Folder to images (.jpg, .jpeg, .png)\n        --blur                 Flag to blur edges of image [default: False]\n        --width=\u003cwidth\u003e        Custom width of the images/video [default: 500]\n        --height=\u003cheight\u003e      Custom height of the images/video [default: 600]\n        --out=\u003cfilename\u003e       Filename to save the average face [default: result.png]\n        --destimg=\u003cfilename\u003e   Destination face image to overlay average face\n        --plot                 Flag to display the average face [default: False]\n        --background=\u003cbg\u003e      Background of image to be one of (black|transparent|average) [default: black]\n        --version              Show version.\n\nSteps (facemorpher folder)\n--------------------------\n\n1. Locator\n^^^^^^^^^^\n\n-  Locates face points\n-  For a different locator, return an array of (x, y) control face\n   points\n\n2. Aligner\n^^^^^^^^^^\n\n-  Align faces by resizing, centering and cropping to given size\n\n3. Warper\n^^^^^^^^^\n\n-  Given 2 images and its face points, warp one image to the other\n-  Triangulates face points\n-  Affine transforms each triangle with bilinear interpolation\n\n4a. Morpher\n^^^^^^^^^^^\n\n-  Morph between 2 or more images\n\n4b. Averager\n^^^^^^^^^^^^\n\n-  Average faces from 2 or more images\n\nBlender\n^^^^^^^\n\nOptional blending of warped image:\n\n-  Weighted average\n-  Alpha feathering\n-  Poisson blend\n\nExamples - `Being John Malkovich`_\n----------------------------------\n\nCreate a morphing video between the 2 images:\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n| ``\u003e python facemorpher/morpher.py --src=alyssa.jpg --dest=john_malkovich.jpg``\n| ``--out_video=out.avi``\n\n(out.avi played and recorded as gif)\n\n.. figure:: https://raw.github.com/alyssaq/face_morpher/master/examples/being_john_malvokich.gif\n   :alt: gif\n\nSave the frames to a folder:\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n| ``\u003e python facemorpher/morpher.py --src=alyssa.jpg --dest=john_malkovich.jpg``\n| ``--out_frames=out_folder --num=30``\n\nPlot the frames:\n^^^^^^^^^^^^^^^^\n\n| ``\u003e python facemorpher/morpher.py --src=alyssa.jpg --dest=john_malkovich.jpg``\n| ``--num=12 --plot``\n\n.. figure:: https://raw.github.com/alyssaq/face_morpher/master/examples/plot.png\n   :alt: plot\n\nAverage all face images in a folder:\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n85 images used\n\n| ``\u003e python facemorpher/averager.py --images=images --blur --background=transparent``\n| ``--width=220 --height=250``\n\n.. figure:: https://raw.github.com/alyssaq/face_morpher/master/examples/average_faces.png\n   :alt: average\\_faces\n\n.. _`Use as pip library`:\n\nUse as pip library\n---------------------------------\n::\n\n    $ pip install facemorpher\n\nExamples\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nAdditional options are exactly the same as the command line\n\n::\n\n    import facemorpher\n\n    # Get a list of image paths in a folder\n    imgpaths = facemorpher.list_imgpaths('imagefolder')\n\n    # To morph, supply an array of face images:\n    facemorpher.morpher(imgpaths, plot=True)\n\n    # To average, supply an array of face images:\n    facemorpher.averager(['image1.png', 'image2.png'], plot=True)\n\n\nOnce pip installed, 2 binaries are also available as a command line utility:\n\n::\n\n    $ facemorpher --src=\u003csrc_imgpath\u003e --dest=\u003cdest_imgpath\u003e --plot\n    $ faceaverager --images=\u003cimages_folder\u003e --plot\n\nTry out in a docker container\n---------------------------------\nMount local folder to `/images` in docker container, run it and enter a bash session.\n--rm removes the container when you close it.\n::\n\n    $ docker run -v  /Users/alyssa/Desktop/images:/images --name py3 --rm -it jjanzic/docker-python3-opencv bash\n\nOnce you're in the container, install ``facemorpher`` and try the examples listed above\n::\n\n    root@0dad0912ebbe:/# pip install facemorpher\n    root@0dad0912ebbe:/# facemorpher --src=\u003cimg1\u003e --dest=\u003cimg2\u003e --plot\n\nDocumentation\n-------------\n\nhttp://alyssaq.github.io/face_morpher\n\nBuild \u0026 publish Docs\n^^^^^^^^^^^^^^^^^^^^\n\n::\n\n    ./scripts/publish_ghpages.sh\n\nLicense\n-------\n`MIT`_\n\n.. _Being John Malkovich: http://www.rottentomatoes.com/m/being_john_malkovich\n.. _Mac installation steps: https://gist.github.com/alyssaq/f60393545173379e0f3f#file-4-opencv3-with-python3-md\n.. _MIT: http://alyssaq.github.io/mit-license\n.. _OpenCV: http://opencv.org\n.. _Homebrew: https://brew.sh\n.. _source: https://github.com/opencv/opencv\n.. _dlib: http://dlib.net\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falyssaq%2Fface_morpher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falyssaq%2Fface_morpher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falyssaq%2Fface_morpher/lists"}