Skip to content

Yet Another Character Face Annotations on Danbooru2020

Pre-release
Pre-release
Compare
Choose a tag to compare
@kosuke1701 kosuke1701 released this 18 Jan 09:37
· 8 commits to master since this release

Description

I applied the pre-trained face detection model in AnimeCV to the SFW 512px downscaled subset of Danbooru2020 dataset.
Applied model is FaceDetector_EfficientDet(coef=2).

It contains 6,412,982 face annotations for 3,227,706 imges.

How to use

Information of extracted face bounding boxes are stored in Sqlite3 database file faces.sql.

Example code

import os
import sqlite3

import matplotlib.pyplot as plt
import numpy as np
from PIL import Image

# Target image
filename = "/data/danbooru2020/512px/512px/0841/2543841.jpg"
name = f"danbooru/{os.path.basename(filename)}"

# Retrieve face position
conn = sqlite3.connect("faces.sql")
c = conn.cursor()
c.execute("SELECT * FROM faces WHERE name=?", (name,))
lst_faces = c.fetchall()

# Crop and show face image
img = Image.open(filename)

for i, (_id, name, xmin, ymin, xmax, ymax) in enumerate(lst_faces):
    ax = plt.subplot(1, len(lst_faces), i+1)

    crop_img = img.crop((xmin, ymin, xmax, ymax))

    ax.imshow(np.asarray(crop_img))
plt.show()

Database schema

table name: faces

column type description
id INTEGER Unique id for each row.
name STRING Name of the image. danbooru/<basename of original image file>. (e.g.) danbooru/4039070.jpg
xmin INTEGER Left coordinate
ymin INTEGER Top coordinate
xmax INTEGER Right coordinate
ymax INTEGER Bottom coordinate