DeepDanbooru
DeepDanbooru is anime-style girl image tag estimation system. You can estimate your images on my live demo site, DeepDanbooru Web.
Requirements
DeepDanbooru is written by Python 3.11. Following packages are need to be installed.
- Click>=8.1.7
- numpy>=1.26.4
- requests>=2.32.3
- scikit-image>=0.24.0
- six>=1.16.0
- tensorflow>=2.17.0
- tensorflow-io>=0.31.0
Or just use requirements.txt.
> pip install -r requirements.txt
alternatively you can install it with pip. Note that by default, tensorflow is not included.
To install it with tensorflow, add tensorflow extra package.
> # default installation
> pip install .
> # with tensorflow package
> pip install .[tensorflow]
Usage
- Prepare dataset. If you don't have, you can use DanbooruDownloader for download the dataset of Danbooru. If you want to make your own dataset, see Dataset Structure section.
- Create training project folder.
> deepdanbooru create-project [your_project_folder]
- Prepare tag list. If you want to use latest tags, use following command. It downloads tag from Danbooru server. (Need Danbooru account and API key)
> deepdanbooru download-tags [your_project_folder] --username [your_danbooru_account] --api-key [your_danbooru_api_key]
- (Option) Filtering dataset. If you want to train with optional tags (rating and score), you should convert it as system tags.
> deepdanbooru make-training-database [your_dataset_sqlite_path] [your_filtered_sqlite_path]
- Modify
project.jsonin the project folder. You should changedatabase_pathsetting to your actual sqlite file path. - Start training.
> deepdanbooru train-project [your_project_folder]
- Enjoy it.
> deepdanbooru evaluate [image_file_path or folder]... --project-path [your_project_folder] --allow-folder
Running on Docker
In the container, the dataset is located on the folder /app/model. You can always mount a volume to use a dataset in your local disk.
You'll also need to mount a volume using the folder containing your images, eg:
docker run --rm -it -v /home/kamuri/images/:/app/data kamuri/deepdanbooru evaluate --project-path "/app/model" "/app/data/" --allow-folder
If you do not want to use the dataset included with the image, you can use the image without it. The image is kamuri/deepdanbooru:nomodel
Dataset Structure
DeepDanbooru uses following folder structure for input dataset. SQLite file can be any name, but must be located in same folder to images folder. All of image files are located in sub-folder which named first 2 characters of its filename.
MyDataset/
├── images/
│ ├── 00/
│ │ ├── 00000000000000000000000000000000.jpg
│ │ ├── ...
│ ├── 01/
│ │ ├── 01000000000000000000000000000000.jpg
│ │ ├── ...
│ └── ff/
│ ├── ff000000000000000000000000000000.jpg
│ ├── ...
└── my-dataset.sqlite
The core is SQLite database file. That file must be contains following table structure.
posts
├── id (INTEGER)
├── md5 (TEXT)
├── file_ext (TEXT)
├── tag_string (TEXT)
└── tag_count_general (INTEGER)
The filename of image must be [md5].[file_ext]. If you use your own images, md5 don't have to be actual MD5 hash value.
tag_string is space splitted tag list, like 1girl ahoge long_hair.
tag_count_general is used for the project setting, minimum_tag_count. Images which has equal or larger value of tag_count_general are used for training.
Project Structure
Project is minimal unit for training on DeepDanbooru. You can modify various parameters for training.
MyProject/
├── project.json
└── tags.txt
tags.txt contains all tags for estimating. You can make your own list or download latest tags from Danbooru server. It is simple newline-separated file like this:
1girl
ahoge
...
Metadata
Release files for deepdanbooru 1.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| deepdanbooru-1.0.4.tar.gz | 22.9 kB | Without provenance | Details for deepdanbooru-1.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| deepdanbooru-1.0.4-py3-none-any.whl | Python 3 | none | any | Details for deepdanbooru-1.0.4-py3-none-any.whl |
Total release size: 50.0 kB
Release files / deepdanbooru-1.0.4.tar.gz
| Download URL | deepdanbooru-1.0.4.tar.gz |
|---|---|
| Size | 22.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6f023dc3a2fb3b7f612979b5acb5264c2ddcf5720b4769a45f91ebfc6efe047c
|
|
BLAKE2b-256 checksum How to use checksums |
890daf54a40ed38d60e6a6e8f9384d01fea518ac29ae98e9cb416fb496e405b5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / deepdanbooru-1.0.4-py3-none-any.whl
| Download URL | deepdanbooru-1.0.4-py3-none-any.whl |
|---|---|
| Size | 27.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
062ca6388e74380e5b8fb3a4b8fb60b5da4949f52c7c993444df8685e42b8e37
|
|
BLAKE2b-256 checksum How to use checksums |
7fea8343ac79a32c8792cdd88254195d3d13647e23fe5d5497cd77f2433e29cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Security for deepdanbooru 1.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.