Answers.Body: <p>I don't know of a tool but you could write a simple script to detect faces and crop it. It's quite simple with the <strong>Haar cascade in openCV</strong> to detect faces and use inbuilt functions to crop your image based on the size of the detected face.</p>
  
  <p>Hope that helps !</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-05-20T10:42:18.933Z
Answers.LastActivityDate: 2019-05-20T10:42:18.933Z
Answers.UserDisplayName: Dishant Sheth
Answers.Body: <p>I developed a python script to crop faces using MTCNN. I found this to be the most accurate of all the face cropping algorithms at the expense of being somewhat slower.
  The function I developed is on the kaggle website at <a href="https://www.kaggle.com/gpiosenka/detect-align-resize-rename-facial-images" rel="nofollow noreferrer">https://www.kaggle.com/gpiosenka/detect-align-resize-rename-facial-images</a>.
  The markup first cell explains how to use it. In a nutshell this function will crop the image files in the input directory and store them in an output directory. If there are multiple faces in an image it selects and crops the largest facial image. It also gives you the option to "align" the cropped images. By align I mean the cropped image is rotated so the eyes are horizontal. You also have the option to resize the cropped image. Finally you also have the option to rename the images in a numerically sequential order and to change the image format to one you specify. This is convenient because if you download images from the internet they have ungodly names and come in a vast variety of image formats. Also the function checks if any images are duplicates of each other. If duplicates are present a listing is provided and you can elect to delete duplicate images. Normally when you build a data set you want to eliminate duplicates so that if you split the data set into train, test and validation sets there is no "leakage" between the sets.
  I have used this function on thousands of images  that have faces in them and it works extremely well. The cropped results are just what you want.On rare occasions a cropping error may occur so it is always wise to review the cropped results. </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-03-06T07:55:23.107Z
Answers.LastActivityDate: 2020-03-06T07:55:23.107Z
Answers.UserDisplayName: Gerry P
Answers.Body: <p>I have found a script that does what i need:
  <a href="https://github.com/leblancfg/autocrop" rel="nofollow noreferrer">https://github.com/leblancfg/autocrop</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-05-20T10:57:31.430Z
Answers.LastActivityDate: 2019-05-20T10:57:31.430Z
Answers.UserDisplayName: AiRookie
Body: <p>I have a fairly large dataset consisting of different images with and without persons that I want to use for a project.</p>
  
  <p>The problem is that I only want the pictures that contain faces, and it is best if there is only a crop of the face.</p>
  
  <p>I already looked at Facenet and Openface, but I thought that there must be a simpler already trained solution just to sort the dataset so I can get started with my own project.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-05-20T10:23:38.757Z
Comments.Text: You could try importing them into a photo management app; they often have face recognition built in to help you identify people in your pictures.
Comments.UserDisplayName: Oliver Mason
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-05-20T10:31:34.010Z
Comments.Text: @OliverMason Thanks, but i have about 30k pictures which probably takes a long time to import :/
Comments.UserDisplayName: AiRookie
Tags: <machine-learning><image-recognition><datasets><data-preprocessing>
Title: Are there tools to help clean a large dataset so that it only contains faces?
UserDisplayName: AiRookie
ThreadText: # Are there tools to help clean a large dataset so that it only contains faces?
  
  (Asked by: username_0 on 2019-05-20)
  
  I have a fairly large dataset consisting of different images with and without persons that I want to use for a project.
  
  The problem is that I only want the pictures that contain faces, and it is best if there is only a crop of the face.
  
  I already looked at Facenet and Openface, but I thought that there must be a simpler already trained solution just to sort the dataset so I can get started with my own project.
  
  **Tags:** machine-learning, image-recognition, datasets, data-preprocessing
  
  > **Comments:**
  > **username_1**: You could try importing them into a photo management app; they often have face recognition built in to help you identify people in your pictures.  
  > **username_0**: @username_1 Thanks, but i have about 30k pictures which probably takes a long time to import :/  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_2 on 2019-05-20. Score: 1
  
  I don't know of a tool but you could write a simple script to detect faces and crop it. It's quite simple with the **Haar cascade in openCV** to detect faces and use inbuilt functions to crop your image based on the size of the detected face.
  
  Hope that helps !
  
  
  ---
  
  ### Answer by username_3 on 2020-03-06. Score: 1
  
  I developed a python script to crop faces using MTCNN. I found this to be the most accurate of all the face cropping algorithms at the expense of being somewhat slower.
  The function I developed is on the kaggle website at <https://www.kaggle.com/gpiosenka/detect-align-resize-rename-facial-images>.
  The markup first cell explains how to use it. In a nutshell this function will crop the image files in the input directory and store them in an output directory. If there are multiple faces in an image it selects and crops the largest facial image. It also gives you the option to "align" the cropped images. By align I mean the cropped image is rotated so the eyes are horizontal. You also have the option to resize the cropped image. Finally you also have the option to rename the images in a numerically sequential order and to change the image format to one you specify. This is convenient because if you download images from the internet they have ungodly names and come in a vast variety of image formats. Also the function checks if any images are duplicates of each other. If duplicates are present a listing is provided and you can elect to delete duplicate images. Normally when you build a data set you want to eliminate duplicates so that if you split the data set into train, test and validation sets there is no "leakage" between the sets.
  I have used this function on thousands of images that have faces in them and it works extremely well. The cropped results are just what you want.On rare occasions a cropping error may occur so it is always wise to review the cropped results.
  
  
  ---
  
  ### Answer by username_0 on 2019-05-20. Score: 1
  
  I have found a script that does what i need:
  <https://github.com/leblancfg/autocrop>
  
  
  ---
  
  