Danbooru2020: A Large-Scale Crowdsourced and Tagged Anime Illustration Dataset

Danbooru2020 is a large-scale anime image database with 4.2m+ images annotated with 130m+ tags; it can be useful for machine learning purposes such as image recognition and generation.
statistics⁠, NN⁠, anime⁠, shell⁠, dataset
2015-12-152021-07-16 finished certainty: likely importance: 6 backlinks / bibliography


Deep learning for computer revision relies on large annotated datasets. Classification/​​​categorization has benefited from the creation of ⁠, which classifies 1m photos into 1000 categories. But classification/​​​categorization is a coarse description of an image which limits application of classifiers, and there is no comparably large dataset of images with many tags or labels which would allow learning and detecting much richer information about images. Such a dataset would ideally be >1m images with at least 10 descriptive tags each which can be publicly distributed to all interested researchers, hobbyists, and organizations. There are currently no such public datasets, as ImageNet, Birds, Flowers, and fall short either on image or tag count or restricted distribution. I suggest that the “image -boorus” be used. The image boorus are longstanding web databases which host large numbers of images which can be ‘tagged’ or labeled with an arbitrary number of textual descriptions; they were developed for and are most popular among fans of anime, who provide detailed annotations.

The best known booru, with a focus on quality, is Danbooru. We provide a torrent/​​​rsync mirror which contains ~3.4TB of 4.22m images with 130m tag instances (of 434k defined tags, ~30/​​​image) covering Danbooru from 2005-05-24–2020-12-31 (final ID: #4,279,845), providing the image files & a JSONL export of the metadata. We also provide a smaller torrent of SFW images downscaled to 512×512px JPGs (0.37TB; 3,227,715 images) for convenience. (Total: 3.7TB.)

Our hope is that the Danbooru2020 dataset can be used for rich large-scale classification/​​​tagging & learned embeddings, test out the transferability of existing computer vision techniques (primarily developed using photographs) to illustration/​​​anime-style images, provide an archival backup for the Danbooru community, feed back metadata improvements & corrections, and serve as a testbed for advanced techniques such as conditional image generation or ⁠.

Image like Danbooru are image hosting websites developed by the anime community for collaborative tagging. Images are uploaded and tagged by users; they can be large, such as Danbooru1⁠, and richly annotated with textual ‘tags’⁠.

Danbooru in particular is old, large, well-tagged, and its operators have always supported uses beyond regular browsing—providing an API and even a database export. With their permission, I have periodically created static snapshots of Danbooru oriented towards ML use patterns.

Image booru description

Screenshot of Danbooru (July 2021) illustrating the grouping of tags into ‘categories’: “Artists, Copyrights, Characters, General, Meta”

Image booru tags typically divided into a few major groups:

  • copyrights (the overall franchise, movie, TV series, manga etc a work is based on; for long-running franchises like or “crossover” images, there can be multiple such tags, or if there is no such associated work, it would be tagged “original”; category group 3)

  • characters (often multiple; category group 4)

  • author/​​artists (usually but not always singular; category group 1)

  • descriptive tags (eg the top 10 tags are 1girl/​​solo/​​long_hair/​​highres/​​breasts/​​blush/​​short_hair/​​smile/​​multiple_girls/​​open_mouth/​​looking_at_viewer, which reflect the expected focus of anime fandom on things like the franchise; category group 0)

    These tags form a “” to describe aspects of images; beyond the expected tags like long_hair or looking_at_the_viewer, there are many strange and unusual tags, including many anime or illustration-specific tags like seiyuu_connection (images where the joke is based on knowing the two characters are voiced in different anime by the same voice actor) or bad_feet (artists frequently accidentally draw two left feet, or just bad_anatomy in general). Tags may also be hierarchical and one tag “imply” another.

    Images with text in them will have tags like translated, comic, or speech_bubble.

  • metadata-about-image tags (multiple, category group 52):

    • image quality/​​​size, eg highres (“>1600 pixels wide or >1200 pixels tall”), translation_request (image has foreign language text in it or its text caption/​​​description), scan (image is not digitally native) etc

Images can have other associated metadata with them, including:

  • explicitness rating (singular)

    Danbooru does not ban sexually suggestive or pornographic content; instead, images are classified into 3 categories: safe, questionable, &explicit. (Represented in the SQL as “s”/​​“q”/​​“e” respectively.)

    safe is for relatively SFW content including swimsuits, while questionable would be more appropriate for highly-revealing swimsuit images or nudity or highly sexually suggestive situations, and explicit denotes anything hard-core pornographic. (8.5% of images are classified as “e”, 15% as “q”, and 77% as “s”; submitters are required to specify the rating when uploaded, and seem to treat “q” as their default if they are not certain whether it’s “e” or “s” instead, so this may underestimate the number of “s” images, but “s” should probably be considered the SFW subset.)

  • Danbooru ID, a unique positive integer

  • MD5 hash⁠.

  • the uploader username

  • the original URL or the name of the work

  • up/​​downvotes

  • sibling images (often an image will exist in many forms, such as sketch or black-white versions in addition to a final color image, edited or larger/​​smaller versions, SFW vs NSFW, or depicting multiple moments in a scene)

  • captions/​​dialogue (many images will have written Japanese captions/​​dialogue, which have been translated into English by users and annotated using HTML )

  • author commentary (also often translated)

  • pools (ordered sequences of images from across Danbooru; often used for comics or image groups, or for disparate images with some unifying theme which is insufficiently objective to be a normal tag)

Image boorus typically support advanced Boolean searches on multiple attributes simultaneously, which in conjunction with the rich tagging, can allow users to discover extremely specific sets of images.

Samples

100 random sample images from the 512px SFW subset of Danbooru in a 10×10 grid.

Download

Danbooru2020 is currently available for download in 2 ways:

  1. BitTorrent
  2. public rsync server

Torrent

The images have been downloaded using a curl script & the Danbooru API, and losslessly optimized using optipng⁠/​jpegoptim3⁠; the metadata has been exported from the Danbooru BigQuery mirror⁠.4

Torrents are the preferred download method as they stress the seed server less, can potentially be faster due to many peers, are resilient to server downtime, and have built-in ECC. (However, Danbooru2020 is approaching the limits of BitTorrent clients, and Danbooru2021 may be forced to drop torrent support.)

Due to the number of files, the torrent has been broken up into 10 separate torrents, each covering a range of IDs modulo 1000. They are available as an XZ-compressed tarball (original images) (25MB) and the SFW 512px downscaled subset torrent (13MB); download & unpack into one’s torrent directory.

The torrents appear to work with on Linux & on Linux/​Windows; it reportedly doesn’t work on Qbittorrent 3.3–4.0.4 (but may on ≥4.0.55), Deluge, or most Windows torrent clients.

Rsync

Due to torrent compatibility & network issues, I provide an alternate download route via a public anonymous server (available for any ⁠; alternative implementations are available for ). To list all available files, a file-list can be downloaded (equivalent to but much faster than rsync --list-only):

rsync rsync://176.9.41.242:873/danbooru2020/filelist.txt.xz ./

To download all available files (test with --dry-run):

rsync --verbose --recursive rsync://176.9.41.242:873/danbooru2020/ ./danbooru2020/

For a single file (eg the historical metadata tarball), one can download like thus:

rsync --verbose rsync://176.9.41.242:873/danbooru2020/metadata.json.tar.xz ./

To download just the current Danbooru2020 metadata files:

rsync --verbose rsync://176.9.41.242:873/danbooru2020/metadata/20200000000000?? ./

For a specific subset, like the SFW 512px subset:

rsync --recursive --verbose rsync://176.9.41.242:873/danbooru2020/512px/ ./danbooru2020/512px/
rsync --recursive --verbose rsync://176.9.41.242:873/danbooru2020/original/ ./danbooru2020/original/

Note that rsync supports a kind of “pattern” in queries (remember to escape globs so they are not interpreted by the shell), and also supports reading a list of filenames from a file:

            --exclude=PATTERN       exclude files matching PATTERN
            --exclude-from=FILE     read exclude patterns from FILE
            --include=PATTERN       don't exclude files matching PATTERN
            --include-from=FILE     read include patterns from FILE
            --files-from=FILE       read list of source-file names from FILE

So one can query the metadata to build up a file listing IDs matching arbitrary criteria, create the corresponding dataset filenames (like for ID #58991, 512px/0991/58991.jpg or, even lazier, just do include matches via a glob pattern like */58991.*). This can require far less time & bandwidth than downloading the full dataset, and is also far faster than doing rsync one file at a time. See the rsync documentation for further details.

I also provide rsync mirrors of a number of models & datasets, such as the cleaned anime portrait dataset⁠; see Projects for a listing of derivative works. (To list all available checkpoints/​datasets/​miscellaneous, rsync --list-only rsync://176.9.41.242:873/biggan/)

Kaggle

A combination of a n = 300k subset of the 512px SFW subset of Danbooru2017 and Nagadomi’s moeimouto face dataset are available as a Kaggle-hosted dataset: “Tagged Anime Illustrations” (36GB).

Kaggle also hosts the metadata of Safebooru up to 2016-11-20: “Safebooru—Anime Image Metadata”⁠.

Model zoo

Currently available:

Useful models would be:

  • perceptual loss model (using DeepDanbooru?)
  • “s”/​​“q”/​​“e” classifier
  • text embedding ⁠, and pre-computed text embeddings for all images’ tags

Updating

If there is interest, the dataset will continue to be updated at regular annual intervals (“Danbooru2020”, “Danbooru2021” etc).

Updates exploit the ECC capability of BitTorrent by updating the images/​metadata and creating a new .torrent file; users download the new .torrent, overwrite the old .torrent, and after rehashing files to discover which ones have changed/​are missing, the new ones are downloaded. (This method has been successfully used by other periodically-updated large torrents, such as the Touhou Lossless Music Torrent⁠, at ~1.75tb after 19 versions.)

Turnover in BitTorrent swarms means that earlier versions of the torrent will quickly disappear, so for easier reproducibility, the metadata files can be archived into subdirectories (images generally will not change, so reproducibility is less of a concern—to reproduce the subset for an earlier release, one simply filters on upload date or takes the file list from the old metadata).

Notification of updates

To receive notification of future updates to the dataset, please subscribe to the notification mailing list⁠.

Possible Uses

Such a dataset would support many possible uses:

  • classification & tagging:

    • image categorization (of major characteristics such as franchise or character or SFW/​​​NSFW detection eg Derpibooru)

    • image multi-label classification (tagging), exploiting the ~20 tags per image (currently there is a prototype, DeepDanbooru)

      • a large-scale testbed for real-world application of active learning / man-machine collaboration
      • testing the scaling limits of existing tagging approaches and motivating zero-shot & one-shot learning techniques
      • bootstrapping video summaries/​​​​descriptions
      • robustness of image classifiers to different illustration styles (eg )
  • image generation:

  • image analysis:

    • facial detection & localization for drawn images (on which normal techniques such as OpenCV’s Harr filters fail, requiring special-purpose approaches like AnimeFace 2009⁠/​​​lbpcascade_animeface)
    • image popularity/​​​upvote prediction
    • image-to-text localization, transcription, and translation of text in images
    • illustration-specialized compression (for better performance than PNG/​​​JPG)
  • image search:

    • collaborative filtering/​​​recommendation, image similarity search (Flickr) of images (useful for users looking for images, for discovering tag mistakes, and for various diagnostics like checking are not memorizing)
    • manga recommendation ()
    • artist similarity and de-anonymization
  • knowledge graph extraction from tags/​​tag-implications and images

    • clustering tags
    • temporal trends in tags (franchise popularity trends)

Advantages

Size and metadata

Datasets are critical limiting resources in deep learning: while algorithms come and go, source code is refined empirically on each specific problem (and the subtlety of many bugs and issues means it’s impossible to write useful code in advance), and computer hardware advances at its own pace, datasets can be usefully created long in advance & applied to countless unforeseen downstream tasks.

Image classification has been supercharged by work on ImageNet (still a standard dataset in 2021, despite creation beginning ~2009!), but ImageNet itself is limited by its small set of classes, many of which are debatable, and which encompass only a limited set. Compounding these limits, tagging/​classification datasets are notoriously undiverse & have imbalance problems or are small:

The external validity of classifiers trained on these datasets is somewhat questionable as the learned discriminative models may collapse or simplify in undesirable ways, and overfit on the datasets’ individual biases (Torralba & Efros 2011). For example, ImageNet classifiers sometimes appear to ‘cheat’ by relying on localized textures in a -style approach and simplistic outlines/​shapes—recognizing leopards only by the color texture of the fur, or believing barbells are extensions of arms. CNNs by default appear to rely almost entirely on texture and ignore shapes/​outlines, unlike human vision, rendering them fragile to transforms; training which emphasizes shape/​outline data augmentation can improve accuracy & robustness (), making anime images a challenging testbed (and this texture-bias possibly explaining poor performance of anime-targeted NNs in the past and the ). The dataset is simply not large enough, or richly annotated enough, to train classifiers or tagger better than that, or, with reaching human parity, reveal differences between the best algorithms and the merely good. (Dataset biases have also been issues on question-answering datasets.) As well, the datasets are static, not accepting any additions, better metadata, or corrections. Like before it, ImageNet is verging on ‘solved’ (the ILSVRC organizers ended it after the 2017 competition) and further progress may simply be overfitting to idiosyncrasies of the datapoints and errors; even if lowered error rates are not overfitting, the low error rates compress the differences between algorithm, giving a misleading view of progress and understating the benefits of better architectures, as improvements become comparable in size to simple chance in initializations/​training/​validation-set choice. As note:

It is an open issue of text-to-image mapping that the distribution of images conditioned on a sentence is highly multi-modal. In the past few years, we’ve witnessed a breakthrough in the application of recurrent neural networks (RNN) to generating textual descriptions conditioned on images [1, 2], with Xu et al. showing that the multi-modality problem can be decomposed sequentially [3]. However, the lack of datasets with diversity descriptions of images limits the performance of text-to-image synthesis on multi-categories dataset like MSCOCO [4]. Therefore, the problem of text-to-image synthesis is still far from being solved

In contrast, the Danbooru dataset is larger than ImageNet as a whole and larger than the most widely-used multi-description dataset, MS COCO, with far richer metadata than the ‘subject verb object’ sentence summary that is dominant in MS COCO or the birds dataset (sentences which could be adequately summarized in perhaps 5 tags, if even that8). While the Danbooru community does focus heavily on female anime characters, they are placed in a wide variety of circumstances with numerous surrounding tagged objects or actions, and the sheer size implies that many more miscellaneous images will be included. It is unlikely that the performance ceiling will be reached anytime soon, and advanced techniques such as attention will likely be required to get anywhere near the ceiling. And Danbooru is constantly expanding and can be easily updated by anyone anywhere, allowing for regular releases of improved annotations.

Danbooru and the image boorus have been only minimally used in previous machine learning work; principally, in (project), which used 1.287m images to train a finetuned VGG-based CNN to detect 1,539 tags (drawn from the 512 most frequent tags of general/​copyright/​character each) with an overall precision of 32.2%, or “Symbolic Understanding of Anime Using Deep Learning”, Li 2018 But the datasets for past research are typically not distributed and there has been little followup.

Non-photographic

Anime images and illustrations, on the other hand, as compared to photographs, differ in many ways—for example, illustrations are frequently black-and-white rather than color, line art rather than photographs, and even color illustrations tend to rely far less on textures and far more on lines (with textures omitted or filled in with standard repetitive patterns), working on a higher level of abstraction—a leopard would not be as trivially recognized by simple pattern-matching on yellow and black dots—with irrelevant details that a discriminator might cheaply classify based on typically suppressed in favor of global gestalt, and often heavily stylized (eg frequent use of “s”). With the exception of MNIST & Omniglot, almost all commonly-used deep learning-related image datasets are photographic.

Humans can still easily perceive a black-white line drawing of a leopard as being a leopard—but can a standard ImageNet classifier? Likewise, the difficulty face detectors encounter on anime images suggests that other detectors like nudity or pornographic detectors may fail; but surely moderation tasks require detection of penises, whether they are drawn or photographed? The attempts to apply CNNs to GANs, image generation, image inpainting, or style transfer have sometimes thrown up artifacts which don’t seem to be issues when using the same architecture on photographic material; for example, in GAN image generation & style transfer, I almost always note, in my own or others’ attempts, what I call the “watercolor effect”, where instead of producing the usual abstracted regions of whitespace, monotone coloring, or simple color gradients, the CNN instead consistently produces noisy transition textures which look like watercolor paintings—which can be beautiful, and an interesting style in its own right (eg the style2paints samples), but means the CNNs are failing to some degree. This watercolor effect appears to not be a problem in photographic applications, but on the other hand, photos are filled with noisy transition textures and watching a GAN train, you can see that the learning process generates textures first and only gradually learns to build edges and regions and transitions from the blurred texts; is this anime-specific problem due to simply insufficient data/​training, or is there something more fundamentally the issue with current convolutions?

Because illustrations are produced by an entirely different process and focus only on salient details while abstracting the rest, they offer a way to test external validity and the extent to which taggers are tapping into higher-level semantic perception. (Line drawings especially may be a valuable test case as they may reflect human perception’s attempts to ⁠; if NNs are unable to interpret line drawings as well as humans can, then they might be falling short in the real world too.)

As well, many ML researchers are anime fans and might enjoy working on such a dataset—training NNs to generate anime images can be amusing. It is, at least, more interesting than photos of street signs or storefronts. (“There are few sources of energy so powerful as a procrastinating grad student.”)

Community value

A full dataset is of immediate value to the Danbooru community as an archival snapshot of Danbooru which can be downloaded in lieu of hammering the main site and downloading terabytes of data; backups are occasionally requested on the Danbooru forum but the need is currently not met.

There is potential for a symbiosis between the Danbooru community & ML researchers: in a virtuous circle, the community provides curation and expansion of a rich dataset, while ML researchers can contribute back tools from their research on it which help improve the dataset. The Danbooru community is relatively large and would likely welcome the development of tools like taggers to support semi-automatic (or eventually, fully automatic) image tagging, as use of a tagger could offer orders of magnitude improvement in speed and accuracy compared to their existing manual methods, as well as being newbie-friendly9 They are also a pre-existing audience which would be interested in new research results.

Format

The goal of the dataset is to be as easy as possible to use immediately, avoiding obscure file formats, while allowing simultaneous research & seeding of the torrent, with easy updates.

Images are provided in the full original form (be that JPG, PNG, GIF or otherwise) for reference/​archival purposes, and a script for converting to JPGS & downscaling (creating a smaller more suitable for ML use).

Images are bucketed into 1000 subdirectories 0–999, which is the Danbooru ID modulo 1000 (ie all images in 0999/ have an ID ending in ‘999’). A single directory would cause pathological filesystem performance, and modulo ID spreads images evenly without requiring additional directories to be made. The ID is not zero-padded and files end in the relevant extension, hence the file layout looks like this:

original/0000/
original/0000/1000.png
original/0000/2000.jpg
original/0000/3000.jpg
original/0000/4000.png
original/0000/5000.jpg
original/0000/6000.jpg
original/0000/7000.jpg
original/0000/8000.jpg
original/0000/9000.jpg
...

Currently represented file extensions are: avi/​bmp/​gif/​html/​jpeg/​jpg/​mp3/​mp4/​mpg/​pdf/​png/​rar/​swf/​webm/​wmv/​zip. (JPG/​PNG files have been losslessly optimized using jpegoptim/​OptiPNG, saving ~100GB.)

Raw original files are treacherous

Be careful if working with the original rather than 512px subset. There are many odd files: truncated, non-sRGB colorspace, wrong file extensions (eg some PNGs have .jpg extensions like original/0146/1525146.jpg/​​original/0558/1422558.jpg), etc.

The SFW torrent follows the same schema but inside the 512px/ directory instead and converted to JPG for the SFW files: 512px/0000/1000.jpg etc.

Image Metadata

The metadata is available as a XZ-compressed tarball of JSONL (JSON Lines: newline-delimited JSON records, one file per line) files as exported from the Danbooru BigQuery database mirror (metadata.json.tar.xz). Each line is an individual JSON object for a single image; ad hoc queries can be run easily by piping into jq⁠, and several are illustrated in the shell query appendix⁠.

Here is an example of a shell script for getting the filenames of all SFW images matching a particular tag:

# print out filenames of all SFW Danbooru images matching a particular tag.
# assumes being in root directory like '/media/gwern/Data2/danbooru2020'
TAG="monochrome"

TEMP=$(mktemp /tmp/matches-XXXX.txt)
cat metadata/* | head -1000 | fgrep -e '"name":"'"$TAG" | fgrep '"rating":"s"' \
    | jq -c '.id' | tr -d '"' >> "$TEMP"

for ID in $(cat "$TEMP"); do
        BUCKET=$(printf "%04d" $(( ID % 1000 )) );
        TARGET=$(ls ./original/"$BUCKET/$ID".*)
        ls "$TARGET"
done

3 example metadata (jq-formatted):

{
  "id": "148112",
  "created_at": "2007-10-25 21:29:41.5877 UTC",
  "uploader_id": "1",
  "score": "2",
  "source": "",
  "md5": "afc6c473332f8372afba07cb597818af",
  "last_commented_at": "1970-01-01 00:00:00 UTC",
  "rating": "s",
  "image_width": "1555",
  "image_height": "1200",
  "is_note_locked": false,
  "file_ext": "jpg",
  "last_noted_at": "1970-01-01 00:00:00 UTC",
  "is_rating_locked": false,
  "parent_id": "0",
  "has_children": false,
  "approver_id": "0",
  "file_size": "390946",
  "is_status_locked": false,
  "up_score": "2",
  "down_score": "0",
  "is_pending": false,
  "is_flagged": false,
  "is_deleted": false,
  "updated_at": "2016-03-26 16:29:45.28726 UTC",
  "is_banned": false,
  "pixiv_id": "0",
  "tags": [
    {
      "id": "567316",
      "name": "6+girls",
      "category": "0"
    },
    {
      "id": "437490",
      "name": "artist_request",
      "category": "5"
    },
    {
      "id": "6059",
      "name": "blazer",
      "category": "0"
    },
    {
      "id": "2378",
      "name": "buruma",
      "category": "0"
    },
    {
      "id": "484628",
      "name": "copyright_request",
      "category": "5"
    },
    {
      "id": "6532",
      "name": "glasses",
      "category": "0"
    },
    {
      "id": "7450",
      "name": "gym_uniform",
      "category": "0"
    },
    {
      "id": "1566",
      "name": "highres",
      "category": "5"
    },
    {
      "id": "3843",
      "name": "jacket",
      "category": "0"
    },
    {
      "id": "566835",
      "name": "multiple_girls",
      "category": "0"
    },
    {
      "id": "391",
      "name": "panties",
      "category": "0"
    },
    {
      "id": "2770",
      "name": "pantyshot",
      "category": "0"
    },
    {
      "id": "16509",
      "name": "school_uniform",
      "category": "0"
    },
    {
      "id": "3477",
      "name": "sweater",
      "category": "0"
    },
    {
      "id": "432529",
      "name": "sweater_vest",
      "category": "0"
    },
    {
      "id": "3291",
      "name": "teacher",
      "category": "0"
    },
    {
      "id": "1882",
      "name": "thighhighs",
      "category": "0"
    },
    {
      "id": "464906",
      "name": "underwear",
      "category": "0"
    },
    {
      "id": "6176",
      "name": "vest",
      "category": "0"
    },
    {
      "id": "230",
      "name": "waitress",
      "category": "0"
    },
    {
      "id": "4123",
      "name": "wind",
      "category": "0"
    },
    {
      "id": "378454",
      "name": "wind_lift",
      "category": "0"
    },
    {
      "id": "10644",
      "name": "zettai_ryouiki",
      "category": "0"
    }
  ],
  "pools": [],
  "favs": [
    "11896",
    "1200",
    "13418",
    "11637",
    "108341"
  ]
}

{
  "id": "251218",
  "created_at": "2008-05-21 00:41:56.83102 UTC",
  "uploader_id": "1",
  "score": "2",
  "source": "http://i2.pixiv.net/img10/img/aki-prism/7956060_p31.jpg",
  "md5": "a3b948d2feab35045201da677adaa925",
  "last_commented_at": "1970-01-01 00:00:00 UTC",
  "rating": "s",
  "image_width": "350",
  "image_height": "700",
  "is_note_locked": false,
  "file_ext": "jpg",
  "last_noted_at": "1970-01-01 00:00:00 UTC",
  "is_rating_locked": false,
  "parent_id": "0",
  "has_children": false,
  "approver_id": "0",
  "file_size": "73187",
  "is_status_locked": false,
  "up_score": "2",
  "down_score": "0",
  "is_pending": false,
  "is_flagged": false,
  "is_deleted": false,
  "updated_at": "2020-05-05 23:42:39.02344 UTC",
  "is_banned": false,
  "pixiv_id": "7956060",
  "tags": [
    {
      "id": "470575",
      "name": "1girl",
      "category": "0"
    },
    {
      "id": "6126",
      "name": "animal_ears",
      "category": "0"
    },
    {
      "id": "401178",
      "name": "aruruw",
      "category": "4"
    },
    {
      "id": "465619",
      "name": "closed_eyes",
      "category": "0"
    },
    {
      "id": "10157",
      "name": "honey",
      "category": "0"
    },
    {
      "id": "412964",
      "name": "honeypot",
      "category": "0"
    },
    {
      "id": "426559",
      "name": "marupeke",
      "category": "1"
    },
    {
      "id": "402239",
      "name": "photoshop_(medium)",
      "category": "5"
    },
    {
      "id": "16509",
      "name": "school_uniform",
      "category": "0"
    },
    {
      "id": "268819",
      "name": "serafuku",
      "category": "0"
    },
    {
      "id": "212816",
      "name": "solo",
      "category": "0"
    },
    {
      "id": "15674",
      "name": "tail",
      "category": "0"
    },
    {
      "id": "575561",
      "name": "utawareru_mono",
      "category": "3"
    }
  ],
  "pools": [],
  "favs": [
    "13392",
    "35380",
    "106523",
    "484488",
    "60223"
  ]
}

{
  "id": "901634",
  "created_at": "2011-04-21 22:18:02.20889 UTC",
  "uploader_id": "37391",
  "score": "7",
  "source": "http://www.sword-girls.com/default.aspx",
  "md5": "2c70ff536e7fc8186b70b6d9023d579f",
  "last_commented_at": "1970-01-01 00:00:00 UTC",
  "rating": "s",
  "image_width": "320",
  "image_height": "480",
  "is_note_locked": false,
  "file_ext": "jpg",
  "last_noted_at": "1970-01-01 00:00:00 UTC",
  "is_rating_locked": false,
  "parent_id": "0",
  "has_children": false,
  "approver_id": "288549",
  "file_size": "162693",
  "is_status_locked": false,
  "up_score": "5",
  "down_score": "0",
  "is_pending": false,
  "is_flagged": false,
  "is_deleted": false,
  "updated_at": "2013-05-25 15:10:19.68411 UTC",
  "is_banned": false,
  "pixiv_id": "0",
  "tags": [
    {
      "id": "470575",
      "name": "1girl",
      "category": "0"
    },
    {
      "id": "89368",
      "name": "aqua_eyes",
      "category": "0"
    },
    {
      "id": "399827",
      "name": "arms_up",
      "category": "0"
    },
    {
      "id": "4011",
      "name": "blade",
      "category": "0"
    },
    {
      "id": "378993",
      "name": "energy_sword",
      "category": "0"
    },
    {
      "id": "2270",
      "name": "eyepatch",
      "category": "0"
    },
    {
      "id": "464559",
      "name": "flower",
      "category": "0"
    },
    {
      "id": "7581",
      "name": "garter_belt",
      "category": "0"
    },
    {
      "id": "197",
      "name": "garters",
      "category": "0"
    },
    {
      "id": "620491",
      "name": "iri_flina",
      "category": "4"
    },
    {
      "id": "495048",
      "name": "lily_(flower)",
      "category": "0"
    },
    {
      "id": "10606",
      "name": "lowres",
      "category": "5"
    },
    {
      "id": "461172",
      "name": "nardack",
      "category": "1"
    },
    {
      "id": "15080",
      "name": "short_hair",
      "category": "0"
    },
    {
      "id": "15425",
      "name": "silver_hair",
      "category": "0"
    },
    {
      "id": "429",
      "name": "skirt",
      "category": "0"
    },
    {
      "id": "212816",
      "name": "solo",
      "category": "0"
    },
    {
      "id": "401228",
      "name": "sword",
      "category": "0"
    },
    {
      "id": "620408",
      "name": "sword_girls",
      "category": "3"
    },
    {
      "id": "1882",
      "name": "thighhighs",
      "category": "0"
    },
    {
      "id": "11449",
      "name": "weapon",
      "category": "0"
    },
    {
      "id": "10644",
      "name": "zettai_ryouiki",
      "category": "0"
    }
  ],
  "pools": [],
  "favs": [
    "23888",
    "115871",
    "342656",
    "332770",
    "95046",
    "324891",
    "20124",
    "149704",
    "34355",
    "290816",
    "228600",
    "55507",
    "338018",
    "134865",
    "72221",
    "256960",
    "104143",
    "85939",
    "386036",
    "450665",
    "497363",
    "550966"
  ]
}

Citing

Please cite this dataset as:

  • Anonymous, The Danbooru Community, & Gwern Branwen; “Danbooru2020: A Large-Scale Crowdsourced and Tagged Anime Illustration Dataset”, 2020-01-12. Web. Accessed [DATE] https://www.gwern.net/Danbooru2020

    @misc{danbooru2020,
        author = {Anonymous and Danbooru community and Gwern Branwen},
        title = {Danbooru2020: A Large-Scale Crowdsourced and Tagged Anime Illustration Dataset},
        howpublished = {\url{https://www.gwern.net/Danbooru2020}},
        url = {https://www.gwern.net/Danbooru2020},
        type = {dataset},
        year = {2021},
        month = {January},
        timestamp = {2020-01-12},
        note = {Accessed: DATE} }

Past releases

Danbooru2017

The first release, Danbooru2017, contained ~1.9tb of 2.94m images with 77.5m tag instances (of 333k defined tags, ~26.3/​image) covering Danbooru from 2005-05-24 through 2017-12-31 (final ID: #2,973,532).

Danbooru2018 added 0.413TB/​392,557 images/​15,208,974 tags/​31,698 new unique tags.

To reconstruct Danbooru2017, download Danbooru2018, and take the image subset ID #1–2973532 as the image dataset, and the JSON metadata in the subdirectory metadata/2017/ as the metadata. That should give you Danbooru2017 bit-identical to as released on 2018-02-13.

Danbooru2018

The second release was a torrent of ~2.5tb of 3.33m images with 92.7m tag instances (of 365k defined tags, ~27.8/​image) covering Danbooru from 2005-05-24 through 2018-12-31 (final ID: #3,368,713), providing the image files & a JSON export of the metadata. We also provided a smaller torrent of SFW images downscaled to 512×512px JPGs (241GB; 2,232,462 images) for convenience.

Danbooru2018 can be reconstructed similarly using metadata/2018/.

Danbooru2019

The third release was 3tb of 3.69m images, 108m tags, through 2019-12-31 (final ID: #3,734,660). Danbooru2019 can be reconstructed likewise.

Applications

Projects

Code and derived datasets:

Publications

Research:

Scraping

This project is not officially affiliated or run by Danbooru, however, the site founder Albert (and his successor, Evazion) has given his permission for scraping. I have registered the accounts gwern and gwern-bot for use in downloading & participating on Danbooru; it is considered good research ethics to try to offset any use of resources when crawling an online community (eg DNM scrapers try to run nodes to pay back the bandwidth), so I have donated $25$202015 to Danbooru via an account upgrade.

Danbooru IDs are sequential positive integers, but the images are stored at their MD5 hashes; so downloading the full images can be done by a query to the JSON API for the metadata for an ID, getting the URL for the full upload, and downloading that to the ID plus extension.

The metadata can be downloaded from BigQuery via BigQuery-API-based tools.

Bugs

Known bugs:

  • Missing translation metadata: the metadata does not include the translations or bounding-boxes of captions/​​translations (“notes”); they were omitted from the BigQuery mirror and technical problems meant they could not be added to BQ before release. The captions/​​translations can be retrieved via the Danbooru API if necessary.

  • 512px SFW subset transparency problem: some images have transparent backgrounds; if they are also black-white, like black line-art drawings, then the conversion to JPG with a default black background will render them almost 100% black and the image will be invisible (eg files with the two tags transparent_background lineart). This affects somewhere in the hundreds of images. Users can either ignore this as affecting a minute percentage of files, filter out images based on the tag-combination, or include data quality checks in their image loading code to drop anomalous images with too-few unique colors or which are too white/​​too black.

    Proposed fix: in Danbooru2019+’s 512px SFW subset, the downscaling has switched to adding white backgrounds rather than black backgrounds; while the same issue can still arise in the case of white line-art drawings with transparent backgrounds, these are much rarer. (It might also be possible to make the conversion shell script query images for use of transparency, average the contents, and pick a background which is most opposite the content.)

Future work

Metadata Quality Improvement via Active Learning

How high quality is the Danbooru metadata quality? As with ImageNet, it is critical that the tags are extremely accurate or else this will lowerbound the error rates and impede the learning of taggers, especially on rarer tags where a low error may still cause false negatives to outweigh the true positives.

I would say that the Danbooru tag data is quite high but imbalanced: almost all tags on images are correct, but the absence of a tag is often wrong—that is, many tags are missing on Danbooru (there are so many possible tags that no user could possibly know them all). So the absence of a tag isn’t as informative as the presence of a tag—eyeballing images and some rarer tags, I would guess that tags are present <10% of the time they should be.

This suggests leveraging an active learning (Settles 2010) form of training: train a tagger, have a human review the errors, update the metadata when it was not an error, and retrain.

More specifically: train the tagger; run the tagger on the entire dataset, recording the outputs and errors; a human examines the errors interactively by comparing the supposed error with the image; and for false negatives, the tag can be added to the Danbooru source using the Danbooru API and added to the local image metadata database, and for false positives, the ‘negative tag’ can be added to the local database; train a new model (possibly initializing from the last checkpoint). Since there will probably be thousands of errors, one would go through them by magnitude of error: for a false positive, start with tagging probabilities of 1.0 and go down, and for false negatives, 0.0 and go up. This would be equivalent to the active learning strategy “uncertainty sampling”, which is simple, easy to implement, and effective (albeit not necessarily optimal for active learning as the worst errors will tend to be highly correlated/​redundant and the set of corrections overkill). Once all errors have been hand-checked, the training weight on absent tags can be increased, as any missing tags should have shown up as false positives.

Over multiple iterations of active learning + retraining, the procedure should be able to ferret out errors in the dataset and boost its quality while also increasing its performance.

Based on my experiences with semi-automatic editing on Wikipedia (using pywikipediabot for solving disambiguation wikilinks), I would estimate that given an appropriate terminal interface, a human should be able to check at least 1 error per second and so checking ~30,000 errors per day is possible (albeit extremely tedious). Fixing the top million errors should offer a noticeable increase in performance.

There are many open questions about how best to optimize tagging performance: is it better to refine tags on the existing set of images or would adding more only-partially-tagged images be more useful?

Appendix

Shell queries for statistics

## count number of images/files in Danbooru2020
find /media/gwern/Data2/danbooru2020/original/ -type f | wc --lines
# 4226544
## count total filesize of original fullsized images in Danbooru2020:
du -sch /media/gwern/Data2/danbooru2020/original/
# 3.4T

# on JSON files concatenated together:
## number of unique tags
cd metadata/; cat * > all.json
cat all.json | jq '.tags | .[] | .name' > tags.txt
sort -u tags.txt  | wc --lines
# 392446
## number of total tags
wc --lines tags.txt
# 108029170
## Average tag count per image:
R
# 108029170 / 3692578
# # [1] 29.2557584
## Most popular tags:
sort tags.txt | uniq -c | sort -g | tac | head -19
# 2617569 "1girl"
# 2162839 "solo"
# 1808646 "long_hair"
# 1470460 "highres"
# 1268611 "breasts"
# 1204519 "blush"
# 1101925 "smile"
# 1009723 "looking_at_viewer"
# 1006628 "short_hair"
#  904246 "open_mouth"
#  802786 "multiple_girls"
#  758690 "blue_eyes"
#  722932 "blonde_hair"
#  686706 "brown_hair"
#  675740 "skirt"
#  630385 "touhou"
#  606550 "large_breasts"
#  592200 "hat"
#  588769 "thighhighs"

## count Danbooru images by rating
cat all.json | jq '.rating' > ratings.txt
sort ratings.txt | uniq -c | sort -g
#  315713 "e"
#  539329 "q"
# 2853721 "s"

wc --lines ratings.txt
## 3708763 ratings.txt
R
# c(315713, 539329, 2853721) / 3708763
# # [1] 0.0851262267 0.1454201846 0.7694535887

# earliest upload:
cat all.json | jq '.created_at' | fgrep '2005' > uploaded.txt
sort -g uploaded.txt | head -1
# "2005-05-24 03:35:31 UTC"

  1. While Danbooru is not the largest anime image booru in existence—TBIB⁠, for example, claimed >4.7m images ~2017 or almost twice as many as Danbooru2017, by mirroring from multiple boorus—but Danbooru is generally considered to focus on higher-quality images & have better tagging; I suspect >4m images is into and the focus then ought to be on improving the metadata. Google finds () that image classification is logarithmic in image count up to n = 300M with noisy labels (likewise other scaling papers), which I interpret as suggesting that for the rest of us with limited hard drives & compute, going past millions is not that helpful; unfortunately that experiment doesn’t examine the impact of the noise in their categories so one can’t guess how many images each additional tag is equivalent to for improving final accuracy. (They do compare training on equally large datasets with small vs large number of categories, but fine vs coarse-grained categories is not directly comparable to a fixed number of images with less or more tags on each image.) The impact of tag noise could be quantified by removing varying numbers of random images/​​tags and comparing the curve of final accuracy. As adding more images is hard but semi-automatically fixing tags with an active-learning approach should be easy, I would bet that the cost-benefit is strongly in favor of improving the existing metadata than in adding more images from recent Danbooru uploads or other -boorus.↩︎

  2. There appears to be no tag category of 2.↩︎

  3. This is done to save >100GB of space/​​bandwidth; it is true that the lossless optimization will invalidate the MD5s, but note that the original MD5 hashes are available in the metadata, and many thousands of them are incorrect even on the original Danbooru server, and the files’ true hashes are inherently validated as part of the download process—so there is little point in anyone either checking them or trying to avoid modifying files, and lossless optimization saves a great deal.↩︎

  4. If one is only interested in the metadata, one could run queries on the BigQuery version of the Danbooru database instead of downloading the torrent. The BigQuery database is also updated daily.↩︎

  5. Apparently a bug due to an anti-DoS mechanism⁠, which should be fixed.↩︎

  6. An author of style2paints, a NN painter for anime images, notes that standard style transfer approaches (typically using an ImageNet-based ) fail abysmally on anime images: “All transferring methods based on Anime Classifier are not good enough because we do not have anime ImageNet”. This is interesting in part because it suggests that ImageNet CNNs are still only capturing a subset of human perception if they only work on photographs & not illustrations.↩︎

  7. Danbooru2020 does not by default provide a “face” dataset of images cropped to just faces like that of Getchu or Nagadomi’s moeimouto; however, the tags can be used to filter down to a large set of face closeups, and Nagadomi’s face-detection code is highly effective at extracting faces from Danbooru2020 images & can be combined with waifu2× for creating large sets of large face images. Several face datasets have been constructed, see elsewhere.↩︎

  8. See for example the pair highlighted in ⁠, motivating them to use human dialogues to provide more descriptions/​​supervision.↩︎

  9. A tagger could be integrated into the site to automatically propose tags for newly-uploaded images to be approved by the uploader; new users, unconfident or unfamiliar with the full breadth, would then have the much easier task of simply checking that all the proposed tags are correct.↩︎