Project Overview
This project introduces a robust dataset exporter specifically designed for online image platforms, particularly those in the booru series.
We addresses a critical issue prevalent in dataset creation - the excessive use of crawlers. As user numbers swell, these crawlers often lead to unintentional "bot spam" or can even escalate to forms of DDoS attacks.
To mitigate these issues, our approach leverages pre-downloaded or previously dumped data to construct datasets, significantly reducing the impact on the original websites.
Key Features
The framework integrates several functionalities, streamlining the creation of custom datasets:
You are also encouraged to develop and integrate your own components to enhance or replace existing stages of this framework. We warmly welcome contributions in the form of pull requests for new built-in processors as well!
The combination of these features not only preserves the integrity of source platforms but also offers users an efficient and customizable tool for dataset creation.
You can install this package through PyPi with pip utilities:
python -m pip install hakubooru
Or build from source:
git clone https://github.com/KohakuBlueleaf/HakuBooru
cd HakuBooru
python -m pip install -e .
This project simplifies the workflow for exporting images from tar files into designated folders, consisting of four main components:
To effectively utilize this project, follow these steps:
Preparation:
DB.db and image tar files in IMAGE_FOLDER/data-xxxx.tar, where DB and IMAGE_FOLDER represent your chosen paths.Initialization:
import logging
from hakubooru.dataset import load_db
from hakubooru.logging import logger
logger.setLevel(logging.INFO)
logger.info("Loading database")
load_db("DB") # Replace "DB" with your database file path.
from hakubooru.dataset import Post
from hakubooru.dataset.utils import select_post_by_tags, get_tag_by_name
logger.info("Querying posts")
choosed_post = list(
select_post_by_tags([
get_tag_by_name(tag)
for tag in [
"rice_shower_(umamusume)",
"mejiro_mcqueen_(umamusume)"
]
]).where(Post.rating < 2, Post.score > 10)
)
logger.info(f"Found {len(choosed_post)} posts")
IMAGE_FOLDER, FileSaver directory, and KohakuCaptioner, and initiate the export process.from hakubooru.export import Exporter, FileSaver
from hakubooru.caption import KohakuCaptioner
from hakubooru.source import TarSource
logger.info("Building exporter")
exporter = Exporter(
source=TarSource("IMAGE_FOLDER"),
saver=FileSaver("./out/example"),
captioner=KohakuCaptioner()
)
logger.info("Exporting images")
exporter.export_posts(choosed_post)
Build from source:
git clone https://github.com/KohakuBlueleaf/HakuBooru
cd HakuBooru
python -m pip install -e .[gui]
python gui/gui.py
Next, you can see the UI:

70 commits
5 commits
Python
89.8%
Jupyter Notebook
10.2%
Project Overview
This project introduces a robust dataset exporter specifically designed for online image platforms, particularly those in the booru series.
We addresses a critical issue prevalent in dataset creation - the excessive use of crawlers. As user numbers swell, these crawlers often lead to unintentional "bot spam" or can even escalate to forms of DDoS attacks.
To mitigate these issues, our approach leverages pre-downloaded or previously dumped data to construct datasets, significantly reducing the impact on the original websites.
Key Features
The framework integrates several functionalities, streamlining the creation of custom datasets:
You are also encouraged to develop and integrate your own components to enhance or replace existing stages of this framework. We warmly welcome contributions in the form of pull requests for new built-in processors as well!
The combination of these features not only preserves the integrity of source platforms but also offers users an efficient and customizable tool for dataset creation.
You can install this package through PyPi with pip utilities:
python -m pip install hakubooru
Or build from source:
git clone https://github.com/KohakuBlueleaf/HakuBooru
cd HakuBooru
python -m pip install -e .
This project simplifies the workflow for exporting images from tar files into designated folders, consisting of four main components:
To effectively utilize this project, follow these steps:
Preparation:
DB.db and image tar files in IMAGE_FOLDER/data-xxxx.tar, where DB and IMAGE_FOLDER represent your chosen paths.Initialization:
import logging
from hakubooru.dataset import load_db
from hakubooru.logging import logger
logger.setLevel(logging.INFO)
logger.info("Loading database")
load_db("DB") # Replace "DB" with your database file path.
from hakubooru.dataset import Post
from hakubooru.dataset.utils import select_post_by_tags, get_tag_by_name
logger.info("Querying posts")
choosed_post = list(
select_post_by_tags([
get_tag_by_name(tag)
for tag in [
"rice_shower_(umamusume)",
"mejiro_mcqueen_(umamusume)"
]
]).where(Post.rating < 2, Post.score > 10)
)
logger.info(f"Found {len(choosed_post)} posts")
IMAGE_FOLDER, FileSaver directory, and KohakuCaptioner, and initiate the export process.from hakubooru.export import Exporter, FileSaver
from hakubooru.caption import KohakuCaptioner
from hakubooru.source import TarSource
logger.info("Building exporter")
exporter = Exporter(
source=TarSource("IMAGE_FOLDER"),
saver=FileSaver("./out/example"),
captioner=KohakuCaptioner()
)
logger.info("Exporting images")
exporter.export_posts(choosed_post)
Build from source:
git clone https://github.com/KohakuBlueleaf/HakuBooru
cd HakuBooru
python -m pip install -e .[gui]
python gui/gui.py
Next, you can see the UI:

70 commits
5 commits
Python
89.8%
Jupyter Notebook
10.2%