1
0
Fork 0
mirror of https://github.com/deepfakes/faceswap synced 2025-06-08 03:26:47 -04:00
faceswap/scripts/extract.py
Édouard WILLISSECK 59d234ae5e Unified CLI (#22)
* Created a single script to call the other ones.

Usage is ./faceswap.py {train|extract|convert}

* Improved the help from the commands.

* Added forgotten faceswap.py file.

* Changed gitignore to add the scripts.

* Updates gitignore.

* Added guarding not to execute code when imported.

* Removed useless script. Display help when no arguments are provided.

* Update README
2017-12-25 02:17:02 +01:00

20 lines
750 B
Python

import cv2
from lib.cli import DirectoryProcessor
from pathlib import Path
class ExtractTrainingData(DirectoryProcessor):
def create_parser(self, subparser, command, description):
self.parser = subparser.add_parser(
command,
help="Extract the faces from a pictures.",
description=description,
epilog="Questions and feedback: \
https://github.com/deepfakes/faceswap-playground"
)
def process_face(self, face, index, filename):
resized_image = cv2.resize(face.image, (256, 256))
output_file = self.output_dir / Path(filename).stem
cv2.imwrite(str(output_file) + str(index) + Path(filename).suffix,
resized_image)