Skip to content

Instantly share code, notes, and snippets.

Forked from stormraiser/
Created February 20, 2019 11:31
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save skeeet/7d4e3f81dccbcc0f6ea3584960888d0a to your computer and use it in GitHub Desktop.
Danbooru Faces dataset

Danbooru Faces v0.1


This dataset contains ~443k anime face images of size 256x256 drawn by ~7,000 artists, obtained from Danbooru


We first downloaded JSON files of all existing posts numbered from 1 to 2,800,000 using their API. We filtered the posts by the following criteria:

  • We focus on finished fully colored anime-style 2-d digital still images depicting human (or otherwise fully anthropomorphic). So posts containing any of the following tags are discarded: photo 3d traditional_media monochrome sketch lineart animated flash no_humans

  • The score must be at least 5

We downloaded a total of ~1.2 million images.


We detect faces with AnimeFace 2009. We discarded detected faces with confidence less than 0.8. The detection results include position and size of bounding boxes of eyes, mouth and the whole face. The shape of the face box is always a square. We want the entire head while the face box only contains the visible part of the face. So we get our image patches as follows: We rotate the image such that the center of the eyes lie on the same horizontal line. After we rotate the image, we move the center of the face up by 0.35 times the edge length of the face box, and crop out a square with 1.75 times the edge length of the face box. These patches are only kept if they are no smaller than 256x256 and are resized to 256x256.

This dataset is intended for style classification and conditional GAN, so we classify the resulting image by artists. To avoid ambiguouity, we keep a face patch only if the original post contains exactly one artist tag. Finally, artists with less than 20 faces patches are discarded.


Quality of face detection

The face detector generally works well but does miss some faces and give some weird detection results sometimes. In particular, it often detects text or certain hand gesture or random things in a configuration similar to two eyes plus a mouth as a face. And it often misses faces that are not near upright.

Image contents

We did not exclude posts that dipict sex.

Naming of the files

The number before the underscore is the post id on Danbooru. Use<post_id> to access the page. The number after the underscore is the serial number of detected faces. These may not be continuous since some may have been disarded for various reasons.


Many posts are similar in different ways: they may be the scan of the same digital image printed on different places; they may be digital images with slightly different content, where only the facial expression of a character is changed, etc. We may want to discard duplications of the former type but keep those of the latter type. There does not seem to be a straightforward solution.

Future directions

We will likely need a better face detector. Ideally it can give us the correct head pose, which would be useful way beyond making this dataset. Unfortunately unlike real head pose detectors where training data can be easily synthesized, for these non-physical images we proably need to label a lot of images manually.

Discarded patchs that are too small can be enhanced with e.g. waifu2x and still be useful.

Find a way to solve duplication.

Just for fun

I put 7 face patches from one of my own drawings there. They are obviously not from Danbooru and I put 0 as the post id. Remove stormraiser from the files if you don't want it.


Google Drive link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment