Jannchie commited on
Commit
62a4c39
·
1 Parent(s): f5426d4

feat(scripts): add dataset and statistic processing scripts && restructure project with modular utilities

Browse files
.gitignore CHANGED
@@ -1,3 +1,13 @@
1
  venv
2
  __pycache__
3
- image
 
 
 
 
 
 
 
 
 
 
 
1
  venv
2
  __pycache__
3
+ data
4
+ image
5
+ *.db
6
+ *.csv
7
+ *.json
8
+ *.png
9
+ *.jpg
10
+ *.webp
11
+ *.txt
12
+ *.caption
13
+ *.npz
README.md CHANGED
@@ -8,6 +8,20 @@ I did not include the media_asset field because it is largely redundant with oth
8
 
9
  Compared to the metadata available at <https://huggingface.co/datasets/nyanko7/danbooru2023>, the data here was collected at a later time. This means that many fields may differ, such as score. Some tags and author aliases are also more complete.
10
 
11
- Here, we have attached both the script for updating metadata and the script for downloading images based on the metadata database.
12
-
13
- Typically, the database becomes the bottleneck. On my PC, We can download all metadata in about 3 hours. A better SSD may speed up the process.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
 
9
  Compared to the metadata available at <https://huggingface.co/datasets/nyanko7/danbooru2023>, the data here was collected at a later time. This means that many fields may differ, such as score. Some tags and author aliases are also more complete.
10
 
11
+ Here, we have attached both the script for updating metadata and the script for downloading images based on the metadata database.
12
+
13
+ Typically, the database becomes the bottleneck. On my PC, We can download all metadata in about 3 hours. A better SSD may speed up the process.
14
+
15
+ ## Layout
16
+ - `scripts/`: executable scripts (update, download, statistics, dataset tooling).
17
+ - `data/db/`: SQLite databases.
18
+ - `data/parquet/`: Parquet exports.
19
+ - `data/outputs/tags/`: tag-related outputs.
20
+ - `data/outputs/stats/`: statistics outputs.
21
+ - `data/downloads/`: downloaded images.
22
+ - `data/datasets/`: curated datasets.
23
+
24
+ Example:
25
+ ```
26
+ uv run python scripts/update_danbooru.py --api_key <KEY> --login <USER>
27
+ ```
danbooru/__init__.py ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import concurrent.futures
2
+ import os
3
+ from pathlib import Path
4
+ from threading import Thread
5
+
6
+ import requests
7
+ from rich import get_console
8
+
9
+ console = get_console()
10
+
11
+
12
+ class DanbooruClient:
13
+ def __init__(self, api_key: str, user_id: str, base_url: str = "https://danbooru.donmai.us") -> None:
14
+ self.api_key: str = api_key
15
+ self.user_id: str = user_id
16
+ self.base_url: str = base_url
17
+
18
+ def get_post(self, post_id: int) -> dict[str, object]:
19
+ url: str = f"{self.base_url}/posts/{post_id}.json"
20
+ response: requests.Response = requests.get(url, params={"api_key": self.api_key, "login": self.user_id})
21
+ response.raise_for_status()
22
+ return response.json()
23
+
24
+ def get_posts(
25
+ self,
26
+ key: str | None = None,
27
+ value: str | int | None = None,
28
+ tags: str | None = None,
29
+ limit: int = 10,
30
+ after_id: int | None = None,
31
+ only: str | list[str] | None = None,
32
+ ) -> list[dict[str, object]]:
33
+ url: str = f"{self.base_url}/posts.json"
34
+ only_str: str | None = ",".join(only) if isinstance(only, list) else only
35
+ all_posts: list[dict[str, object]] = []
36
+
37
+ while True:
38
+ current_limit: int = min(limit - len(all_posts), 200)
39
+ if current_limit <= 0:
40
+ break
41
+
42
+ params: dict[str, object] = {
43
+ "limit": current_limit,
44
+ "api_key": self.api_key,
45
+ "login": self.user_id,
46
+ }
47
+ if key is not None:
48
+ params[key] = value
49
+ if after_id is not None:
50
+ params["page"] = f"a{after_id}"
51
+ if tags is not None:
52
+ params["tags"] = tags
53
+ if only_str is not None:
54
+ params["only"] = only_str
55
+
56
+ response: requests.Response = requests.get(url, params=params)
57
+ console.log(response.url)
58
+ response.raise_for_status()
59
+
60
+ posts: list[dict[str, object]] = response.json()
61
+ if not posts:
62
+ break
63
+
64
+ all_posts.extend(posts)
65
+ post_ids = [post["id"] for post in posts if isinstance(post.get("id"), int)]
66
+ if not post_ids:
67
+ break
68
+ after_id = max(post_ids)
69
+ if len(all_posts) >= limit:
70
+ break
71
+ return all_posts
72
+
73
+ def download_image(self, post: dict[str, object], target_dir: str) -> None:
74
+ url = post.get("file_url")
75
+ if not isinstance(url, str):
76
+ return
77
+ post_id = post.get("id")
78
+ if not isinstance(post_id, (int, str)):
79
+ return
80
+ console.log(f"Downloading post {post_id}")
81
+ ext: str = url.split(".")[-1]
82
+ file_path: str = os.path.join(target_dir, f"{post_id}.{ext}")
83
+ response: requests.Response = requests.get(url, stream=True)
84
+ response.raise_for_status()
85
+ with open(file_path, "wb") as f:
86
+ for chunk in response.iter_content(1024):
87
+ f.write(chunk)
88
+
89
+ def download_by_id(self, post_id: int, target_dir: str) -> None:
90
+ post: dict[str, object] = self.get_post(post_id)
91
+ if not post:
92
+ console.log(f"Post {post_id} not found")
93
+ return
94
+ Thread(target=self.download_image, args=(post, target_dir)).start()
95
+
96
+ def download_posts(self, posts: list[dict[str, object]], target_dir: str, n_worker: int = 16) -> None:
97
+ os.makedirs(target_dir, exist_ok=True)
98
+ with concurrent.futures.ThreadPoolExecutor(max_workers=n_worker) as executor:
99
+ for post in posts:
100
+ post_id = post.get("id")
101
+ console.log(f"Downloading post {post_id}")
102
+ executor.submit(self.download_image, post, target_dir)
103
+ console.log("Download complete!")
104
+
105
+
106
+ class Downloader:
107
+ def __init__(self, n_workers: int = 4) -> None:
108
+ self.n_workers: int = n_workers
109
+ self.executor: concurrent.futures.ThreadPoolExecutor | None = None
110
+
111
+ def __enter__(self) -> "Downloader":
112
+ self.executor = concurrent.futures.ThreadPoolExecutor(max_workers=self.n_workers)
113
+ return self
114
+
115
+ def __exit__(
116
+ self,
117
+ exc_type: type[BaseException] | None,
118
+ exc_val: BaseException | None,
119
+ exc_tb: object | None,
120
+ ) -> None:
121
+ if self.executor is not None:
122
+ self.executor.shutdown(wait=True)
123
+
124
+ def download(self, url: str, target_path: os.PathLike[str] | str) -> concurrent.futures.Future[None]:
125
+ if self.executor is None:
126
+ raise RuntimeError("Downloader must be used as a context manager before calling download.")
127
+ target_path = Path(target_path)
128
+ target_path.parent.mkdir(parents=True, exist_ok=True)
129
+ return self.executor.submit(self._download_single, url, target_path)
130
+
131
+ def _download_single(self, url: str, target_path: Path) -> None:
132
+ try:
133
+ response: requests.Response = requests.get(url)
134
+ response.raise_for_status()
135
+ with open(target_path, "wb") as file:
136
+ file.write(response.content)
137
+ print(f"Downloaded: {target_path}")
138
+ except requests.RequestException as e:
139
+ print(f"Failed to download {url}: {e}")
db.py CHANGED
@@ -1,8 +1,17 @@
1
  import sqlite3
2
- from sqlalchemy import Column, Float, Index, Integer, MetaData, Table, Text
3
- from sqlalchemy.ext.declarative import declarative_base
4
- from sqlalchemy.orm import sessionmaker
5
- from sqlalchemy import create_engine
 
 
 
 
 
 
 
 
 
6
 
7
  Base = declarative_base()
8
  metadata = MetaData()
@@ -77,16 +86,15 @@ t_posts = Table(
77
  )
78
 
79
 
80
- def connect_db(db_name):
81
  return sqlite3.connect(db_name)
82
 
83
 
84
- def get_engine(db_name):
85
-
86
  return create_engine(f"sqlite:///{db_name}")
87
 
88
 
89
- def get_session(engine):
90
  Session = sessionmaker(bind=engine)
91
  return Session()
92
 
 
1
  import sqlite3
2
+
3
+ from sqlalchemy import (
4
+ Column,
5
+ Float,
6
+ Index,
7
+ Integer,
8
+ MetaData,
9
+ Table,
10
+ Text,
11
+ create_engine,
12
+ )
13
+ from sqlalchemy.engine import Engine
14
+ from sqlalchemy.orm import Session, declarative_base, sessionmaker
15
 
16
  Base = declarative_base()
17
  metadata = MetaData()
 
86
  )
87
 
88
 
89
+ def connect_db(db_name: str) -> sqlite3.Connection:
90
  return sqlite3.connect(db_name)
91
 
92
 
93
+ def get_engine(db_name: str) -> Engine:
 
94
  return create_engine(f"sqlite:///{db_name}")
95
 
96
 
97
+ def get_session(engine: Engine) -> Session:
98
  Session = sessionmaker(bind=engine)
99
  return Session()
100
 
pyproject.toml ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [project]
2
+ name = "danbooru_metadata"
3
+ version = "0.0.0"
4
+ dependencies = [
5
+ "pyarrow>=18.1.0",
6
+ "requests>=2.32.5",
7
+ "rich>=14.3.1",
8
+ "sqlalchemy>=2.0.46",
9
+ ]
10
+ [tool.black]
11
+ line-length = 1000
requirements.txt CHANGED
Binary files a/requirements.txt and b/requirements.txt differ
 
scripts/_paths.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+ from pathlib import Path
3
+
4
+ SCRIPTS_DIR = Path(__file__).resolve().parent
5
+ ROOT = SCRIPTS_DIR.parent
6
+ if str(ROOT) not in sys.path:
7
+ sys.path.insert(0, str(ROOT))
8
+
9
+ DATA_DIR = ROOT / "data"
10
+ DB_DIR = DATA_DIR / "db"
11
+ PARQUET_DIR = DATA_DIR / "parquet"
12
+ RAW_DIR = DATA_DIR / "raw"
13
+ OUTPUTS_DIR = DATA_DIR / "outputs"
14
+ TAGS_DIR = OUTPUTS_DIR / "tags"
15
+ STATS_DIR = OUTPUTS_DIR / "stats"
16
+ DOWNLOADS_DIR = DATA_DIR / "downloads"
17
+ IMAGE_DIR = DOWNLOADS_DIR / "image"
18
+ GOOD_IMAGE_DIR = DOWNLOADS_DIR / "good_image"
19
+ GOOD_IMAGE_WEBP_DIR = DOWNLOADS_DIR / "good_image_webp"
20
+ DATASETS_DIR = DATA_DIR / "datasets"
21
+ ARCHIVES_DIR = DATA_DIR / "archives"
22
+
23
+ DANBOORU_DB_PATH = DB_DIR / "danbooru_metadata.db"
24
+ SAFE_AIBOORU_DB_PATH = DB_DIR / "safe_aibooru_metadata.db"
25
+ PARQUET_PATH = PARQUET_DIR / "danbooru_metadata.parquet"
26
+
27
+ LEGACY_DANBOORU_DB_PATH = ROOT / "danbooru_metadata.db"
28
+ if not DANBOORU_DB_PATH.exists() and LEGACY_DANBOORU_DB_PATH.exists():
29
+ DANBOORU_DB_PATH = LEGACY_DANBOORU_DB_PATH
download_images.py → scripts/download_images.py RENAMED
@@ -3,25 +3,29 @@ import os
3
  import queue
4
  import sqlite3
5
  import threading
 
6
 
7
  import requests
8
  from rich.progress import BarColumn, Progress, TimeElapsedColumn, TimeRemainingColumn
9
 
 
 
10
  parser = argparse.ArgumentParser()
11
- parser.add_argument("--db_path", type=str, default="danbooru_metadata.db")
12
- parser.add_argument("--out_dir", type=str, default="./image")
13
  parser.add_argument("--num_threads", type=int, default=16)
14
 
15
  args = parser.parse_args()
16
 
17
- DB_PATH = args.db_path
18
- OUT_DIR = args.out_dir
19
- NUM_THREADS = args.num_threads
 
20
 
21
  # Task queue to hold file URLs and IDs
22
- task_queue = queue.Queue(64)
23
 
24
- IMAGE_EXTENSIONS = [
25
  "png",
26
  "jpg",
27
  "jpeg",
@@ -32,15 +36,19 @@ IMAGE_EXTENSIONS = [
32
  "JPEG",
33
  "WEBP",
34
  "BMP",
35
- ]
36
 
37
 
38
- def fetch_posts_to_queue():
39
  """Fetch posts from SQLite database and put them in the task queue."""
40
  conn = sqlite3.connect(DB_PATH)
41
  cursor = conn.cursor()
42
 
43
- count = cursor.execute("SELECT COUNT(*) FROM posts").fetchone()[0]
 
 
 
 
44
  progress = Progress(
45
  "[progress.description]{task.description}",
46
  BarColumn(),
@@ -58,22 +66,20 @@ def fetch_posts_to_queue():
58
  post = cursor.fetchone()
59
  if post is None:
60
  break
61
- (post_id, file_url, file_ext) = post
62
 
63
  # Check if the file already exists
64
- if os.path.exists(
65
- os.path.join(OUT_DIR, f"{post_id % 1000:04d}", f"{post_id}.{file_ext}")
66
- ):
67
  continue
68
 
69
  # Check if the file_ext is an image
70
- if file_url is not None and file_ext in IMAGE_EXTENSIONS:
71
  task_queue.put((post_id, file_url))
72
  print("All posts fetched")
73
  conn.close()
74
 
75
 
76
- def download_image(post_id, url):
77
  """Download image from the given URL and save it to the out_dir."""
78
  try:
79
  response = requests.get(url, stream=True)
@@ -93,7 +99,7 @@ def download_image(post_id, url):
93
  print(f"Failed to download {url}: {e}")
94
 
95
 
96
- def worker():
97
  """Worker thread function to download images."""
98
  while True:
99
  try:
@@ -108,7 +114,7 @@ if __name__ == "__main__":
108
  # Populate the task queue
109
 
110
  # Create and start worker threads
111
- threads = []
112
  for _ in range(NUM_THREADS):
113
  thread = threading.Thread(target=worker)
114
  thread.start()
 
3
  import queue
4
  import sqlite3
5
  import threading
6
+ from pathlib import Path
7
 
8
  import requests
9
  from rich.progress import BarColumn, Progress, TimeElapsedColumn, TimeRemainingColumn
10
 
11
+ from _paths import DANBOORU_DB_PATH, IMAGE_DIR
12
+
13
  parser = argparse.ArgumentParser()
14
+ parser.add_argument("--db_path", type=str, default=str(DANBOORU_DB_PATH))
15
+ parser.add_argument("--out_dir", type=str, default=str(IMAGE_DIR))
16
  parser.add_argument("--num_threads", type=int, default=16)
17
 
18
  args = parser.parse_args()
19
 
20
+ DB_PATH: str = args.db_path
21
+ OUT_DIR: str = args.out_dir
22
+ NUM_THREADS: int = args.num_threads
23
+ Path(OUT_DIR).mkdir(parents=True, exist_ok=True)
24
 
25
  # Task queue to hold file URLs and IDs
26
+ task_queue: queue.Queue[tuple[int, str]] = queue.Queue(64)
27
 
28
+ IMAGE_EXTENSIONS: set[str] = {
29
  "png",
30
  "jpg",
31
  "jpeg",
 
36
  "JPEG",
37
  "WEBP",
38
  "BMP",
39
+ }
40
 
41
 
42
+ def fetch_posts_to_queue() -> None:
43
  """Fetch posts from SQLite database and put them in the task queue."""
44
  conn = sqlite3.connect(DB_PATH)
45
  cursor = conn.cursor()
46
 
47
+ count_row = cursor.execute("SELECT COUNT(*) FROM posts").fetchone()
48
+ if count_row is None:
49
+ conn.close()
50
+ return
51
+ count = count_row[0]
52
  progress = Progress(
53
  "[progress.description]{task.description}",
54
  BarColumn(),
 
66
  post = cursor.fetchone()
67
  if post is None:
68
  break
69
+ post_id, file_url, file_ext = post
70
 
71
  # Check if the file already exists
72
+ if os.path.exists(os.path.join(OUT_DIR, f"{post_id % 1000:04d}", f"{post_id}.{file_ext}")):
 
 
73
  continue
74
 
75
  # Check if the file_ext is an image
76
+ if isinstance(file_url, str) and isinstance(file_ext, str) and file_ext in IMAGE_EXTENSIONS:
77
  task_queue.put((post_id, file_url))
78
  print("All posts fetched")
79
  conn.close()
80
 
81
 
82
+ def download_image(post_id: int, url: str) -> None:
83
  """Download image from the given URL and save it to the out_dir."""
84
  try:
85
  response = requests.get(url, stream=True)
 
99
  print(f"Failed to download {url}: {e}")
100
 
101
 
102
+ def worker() -> None:
103
  """Worker thread function to download images."""
104
  while True:
105
  try:
 
114
  # Populate the task queue
115
 
116
  # Create and start worker threads
117
+ threads: list[threading.Thread] = []
118
  for _ in range(NUM_THREADS):
119
  thread = threading.Thread(target=worker)
120
  thread.start()
scripts/get_image ADDED
File without changes
scripts/make_ds/0.get_meta_from_latents.py ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse
2
+ import json
3
+ from pathlib import Path
4
+
5
+ import numpy as np
6
+
7
+
8
+ def main() -> None:
9
+ parser = argparse.ArgumentParser(
10
+ description="Generate metadata from npz files and write to meta.json."
11
+ )
12
+ parser.add_argument("--npz_base", type=str, required=True)
13
+ parser.add_argument("--reclusive", action="store_true")
14
+ parser.add_argument("--start_id", type=int, default=0)
15
+ parser.add_argument("--end_id", type=int, default=999_999_999_999)
16
+ parser.add_argument("--meta_path", type=str, required=True)
17
+ args = parser.parse_args()
18
+
19
+ npz_base = Path(args.npz_base)
20
+ meta_path = Path(args.meta_path)
21
+ start_id = args.start_id
22
+ end_id = args.end_id
23
+
24
+ npz_files = npz_base.rglob("*.npz") if args.reclusive else npz_base.iterdir()
25
+
26
+ data: dict[str, dict[str, tuple[int, int]]] = {}
27
+ for npz_path in npz_files:
28
+ if npz_path.suffix != ".npz":
29
+ continue
30
+ if not start_id <= int(npz_path.stem) <= end_id:
31
+ continue
32
+ with np.load(npz_path) as npz:
33
+ reso = npz.get("train_resolution")
34
+ if reso is None:
35
+ continue
36
+ reso_tuple = tuple(int(x) for x in reso)
37
+ key = npz_path.relative_to(npz_base).with_suffix("").as_posix()
38
+ data[key] = {"train_resolution": reso_tuple}
39
+
40
+ with open(meta_path, "w", encoding="utf-8") as file:
41
+ json.dump(data, file, ensure_ascii=False)
42
+
43
+
44
+ if __name__ == "__main__":
45
+ main()
scripts/make_ds/1.prepare_latents.py ADDED
@@ -0,0 +1,407 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse
2
+ import json
3
+ import os
4
+ import sys
5
+ import threading
6
+ from pathlib import Path
7
+ from queue import Queue
8
+
9
+ import cv2
10
+ import numpy as np
11
+ import torch
12
+ from diffusers import AutoencoderKL
13
+ from PIL import Image
14
+ from rich.progress import Progress
15
+ from torchvision import transforms
16
+
17
+ ROOT = Path(__file__).resolve().parents[2]
18
+ if str(ROOT) not in sys.path:
19
+ sys.path.insert(0, str(ROOT))
20
+
21
+ from utils import glob_images_pathlib
22
+
23
+
24
+ class ImageProcessor:
25
+ def __init__(self, model_name_or_path: str, device: str = "cuda") -> None:
26
+ self.model_name_or_path = model_name_or_path
27
+ self.device = device
28
+ self.vae = self.load_vae_model()
29
+ self.predefined_resos: list[tuple[int, int]] = [
30
+ (640, 1536),
31
+ (768, 1344),
32
+ (832, 1216),
33
+ (896, 1152),
34
+ (1024, 1024),
35
+ (1152, 896),
36
+ (1216, 832),
37
+ (1344, 768),
38
+ (1536, 640),
39
+ ]
40
+ self.predefined_ars = np.array([w / h for w, h in self.predefined_resos])
41
+
42
+ def load_vae_model(self) -> AutoencoderKL:
43
+ return (
44
+ AutoencoderKL.from_pretrained(
45
+ self.model_name_or_path, torch_dtype=torch.float32
46
+ )
47
+ .to(self.device)
48
+ .eval()
49
+ )
50
+
51
+ def select_reso(
52
+ self, image_width: int, image_height: int
53
+ ) -> tuple[tuple[int, int], tuple[int, int]]:
54
+ aspect_ratio = image_width / image_height
55
+ ar_errors = self.predefined_ars - aspect_ratio
56
+ predefined_bucket_id = np.abs(ar_errors).argmin()
57
+ reso = self.predefined_resos[int(predefined_bucket_id)]
58
+
59
+ scale = (
60
+ reso[1] / image_height
61
+ if aspect_ratio > reso[0] / reso[1]
62
+ else reso[0] / image_width
63
+ )
64
+ resized_size = (int(image_width * scale + 0.5), int(image_height * scale + 0.5))
65
+ return reso, resized_size
66
+
67
+ def get_crop_ltrb(
68
+ self, bucket_reso: tuple[int, int] | np.ndarray, image_size: tuple[int, int]
69
+ ) -> tuple[int, int, int, int]:
70
+ bucket_ar = bucket_reso[0] / bucket_reso[1]
71
+ image_ar = image_size[0] / image_size[1]
72
+ if bucket_ar > image_ar:
73
+ resized_width, resized_height = bucket_reso[1] * image_ar, bucket_reso[1]
74
+ else:
75
+ resized_width, resized_height = bucket_reso[0], bucket_reso[0] / image_ar
76
+ crop_left = (bucket_reso[0] - int(resized_width)) // 2
77
+ crop_top = (bucket_reso[1] - int(resized_height)) // 2
78
+ return (
79
+ crop_left,
80
+ crop_top,
81
+ crop_left + int(resized_width),
82
+ crop_top + int(resized_height),
83
+ )
84
+
85
+ @staticmethod
86
+ def load_image(image_path: str | Path) -> np.ndarray:
87
+ image = Image.open(image_path, "r").convert("RGB")
88
+ return np.array(image)
89
+
90
+ def resize_and_trim_image(
91
+ self, image_np: np.ndarray, reso: tuple[int, int], resized_size: tuple[int, int]
92
+ ) -> np.ndarray:
93
+ image_np = cv2.resize(image_np, resized_size, interpolation=cv2.INTER_AREA)
94
+
95
+ image_height, image_width = image_np.shape[:2]
96
+ if image_width > reso[0]:
97
+ trim_pos = (image_width - reso[0]) // 2
98
+ image_np = image_np[:, trim_pos : trim_pos + reso[0]]
99
+ if image_height > reso[1]:
100
+ trim_pos = (image_height - reso[1]) // 2
101
+ image_np = image_np[trim_pos : trim_pos + reso[1]]
102
+ return image_np
103
+
104
+ @torch.no_grad()
105
+ def prepare_image_tensor(self, image_np: np.ndarray) -> torch.Tensor:
106
+ np_to_tensor = transforms.Compose(
107
+ [transforms.ToTensor(), transforms.Normalize([0.5], [0.5])]
108
+ )
109
+ image_tensor = np_to_tensor(image_np)
110
+ if len(image_tensor.shape) == 3:
111
+ image_tensor = image_tensor.unsqueeze(0)
112
+ image_tensor = image_tensor.to(torch.float32).to(self.device)
113
+ return image_tensor
114
+
115
+ @torch.no_grad()
116
+ def encode_image(self, image_tensor: torch.Tensor) -> torch.Tensor:
117
+ return self.vae.encode(image_tensor).latent_dist.sample()[0]
118
+
119
+ @staticmethod
120
+ def save_encoded_image(
121
+ latents: torch.Tensor,
122
+ crop_ltrb: tuple[int, int, int, int],
123
+ original_size: tuple[int, int],
124
+ train_reso: tuple[int, int] | np.ndarray,
125
+ save_path: str | Path,
126
+ ) -> None:
127
+ new_npz = {
128
+ "latents": latents.cpu().detach().numpy(),
129
+ "crop_ltrb": crop_ltrb,
130
+ "original_size": original_size,
131
+ "train_resolution": train_reso,
132
+ }
133
+ np.savez_compressed(save_path, **new_npz)
134
+
135
+ @torch.no_grad()
136
+ def process_image(self, image_path: str | Path, save_path: str | Path) -> None:
137
+ image_np = ImageProcessor.load_image(image_path)
138
+ original_size = (int(image_np.shape[1]), int(image_np.shape[0]))
139
+ reso, resized_size = self.select_reso(*original_size)
140
+ image_np = self.resize_and_trim_image(image_np, reso, resized_size)
141
+ crop_ltrb = self.get_crop_ltrb(np.array(reso), original_size)
142
+ image_tensor = self.prepare_image_tensor(image_np)
143
+ latents = self.encode_image(image_tensor)
144
+ ImageProcessor.save_encoded_image(latents, crop_ltrb, original_size, reso, save_path)
145
+
146
+ def process_image_and_save_img(self, image_path: str | Path, save_path: str | Path) -> None:
147
+ image_np = ImageProcessor.load_image(image_path)
148
+ original_size = (int(image_np.shape[1]), int(image_np.shape[0]))
149
+ reso, resized_size = self.select_reso(*original_size)
150
+ image_np = self.resize_and_trim_image(image_np, reso, resized_size)
151
+ Image.fromarray(image_np).save(save_path)
152
+
153
+
154
+ def read_image(
155
+ read_queue: Queue[Path | None],
156
+ process_queue: Queue[tuple[Path, np.ndarray, tuple[int, int]] | None],
157
+ lock: threading.Lock,
158
+ progress_counter: list[int],
159
+ path_to_train_resolutions: dict[Path, list[int]],
160
+ ) -> None:
161
+ skip_existing = True
162
+ while True:
163
+ image_path = read_queue.get()
164
+ if image_path is None:
165
+ read_queue.task_done()
166
+ break
167
+ npz_save_path = image_path.with_suffix(".npz")
168
+ if skip_existing and npz_save_path.exists():
169
+ try:
170
+ with np.load(npz_save_path) as npz:
171
+ reso = npz.get("train_resolution")
172
+ if reso is not None:
173
+ reso_list = [int(x) for x in reso.tolist()]
174
+ with lock:
175
+ progress_counter[0] += 1
176
+ path_to_train_resolutions[image_path] = reso_list
177
+ read_queue.task_done()
178
+ continue
179
+ except (OSError, ValueError) as exc:
180
+ print(f"Error: {exc}")
181
+ try:
182
+ image_np = ImageProcessor.load_image(image_path)
183
+ except OSError as exc:
184
+ print(f"Error: {exc}")
185
+ print(f"Failed to load {image_path}")
186
+ with lock:
187
+ progress_counter[0] += 1
188
+ read_queue.task_done()
189
+ continue
190
+ original_size = (int(image_np.shape[1]), int(image_np.shape[0]))
191
+ process_queue.put((image_path, image_np, original_size))
192
+ read_queue.task_done()
193
+
194
+
195
+ @torch.no_grad()
196
+ def process_image(
197
+ process_queue: Queue[tuple[Path, np.ndarray, tuple[int, int]] | None],
198
+ write_queue: Queue[
199
+ tuple[Path, torch.Tensor, tuple[int, int, int, int], tuple[int, int], np.ndarray]
200
+ | None
201
+ ],
202
+ processor: ImageProcessor,
203
+ lock: threading.Lock,
204
+ progress_counter: list[int],
205
+ ) -> None:
206
+ while True:
207
+ task = process_queue.get()
208
+ if task is None:
209
+ process_queue.task_done()
210
+ break
211
+ image_path, image_np, original_size = task
212
+ reso, resized_size = processor.select_reso(*original_size)
213
+ image_np = processor.resize_and_trim_image(image_np, reso, resized_size)
214
+ crop_ltrb = processor.get_crop_ltrb(np.array(reso), original_size)
215
+ image_tensor = processor.prepare_image_tensor(image_np)
216
+ try:
217
+ latents = processor.encode_image(image_tensor)
218
+ write_queue.put((image_path, latents, crop_ltrb, original_size, np.array(reso)))
219
+ except RuntimeError as exc:
220
+ print(f"Error: {exc}, image path: {image_path}")
221
+ print(image_tensor.shape, reso)
222
+ with lock:
223
+ progress_counter[0] += 1
224
+ process_queue.task_done()
225
+
226
+
227
+ def write_image(
228
+ write_queue: Queue[
229
+ tuple[Path, torch.Tensor, tuple[int, int, int, int], tuple[int, int], np.ndarray]
230
+ | None
231
+ ],
232
+ progress_counter: list[int],
233
+ lock: threading.Lock,
234
+ path_to_train_resolutions: dict[Path, list[int]],
235
+ ) -> None:
236
+ while True:
237
+ data = write_queue.get()
238
+ if data is None:
239
+ write_queue.task_done()
240
+ break
241
+ image_path, latents, crop_ltrb, original_size, reso = data
242
+ npz_save_path = image_path.with_suffix(".npz")
243
+ ImageProcessor.save_encoded_image(latents, crop_ltrb, original_size, reso, npz_save_path)
244
+ with lock:
245
+ progress_counter[0] += 1
246
+ path_to_train_resolutions[image_path] = [int(x) for x in reso.tolist()]
247
+ write_queue.task_done()
248
+
249
+
250
+ class ImageProcessingPipeline:
251
+ def __init__(
252
+ self,
253
+ model_name: str,
254
+ path_list: list[Path] | list[str],
255
+ meta_path: str,
256
+ ds_path: str,
257
+ num_reader: int = 12,
258
+ num_writer: int = 12,
259
+ ) -> None:
260
+ self.meta_path = meta_path
261
+ self.ds_path = ds_path
262
+ self.num_reader = num_reader
263
+ self.num_writer = num_writer
264
+ self.path_to_train_resolutions: dict[Path, list[int]] = {}
265
+
266
+ self.reader_threads: list[threading.Thread] = []
267
+ self.process_threads: list[threading.Thread] = []
268
+ self.writer_threads: list[threading.Thread] = []
269
+
270
+ self.read_queue: Queue[Path | None] = Queue(maxsize=num_reader)
271
+ self.process_queue: Queue[tuple[Path, np.ndarray, tuple[int, int]] | None] = Queue(
272
+ maxsize=10
273
+ )
274
+ self.write_queue: Queue[
275
+ tuple[Path, torch.Tensor, tuple[int, int, int, int], tuple[int, int], np.ndarray]
276
+ | None
277
+ ] = Queue(maxsize=num_writer)
278
+
279
+ self.progress_counter = [0]
280
+ self.progress_lock = threading.Lock()
281
+
282
+ self.gpu_count = torch.cuda.device_count()
283
+ self.processor_list = [
284
+ ImageProcessor(model_name_or_path=model_name, device=f"cuda:{i}")
285
+ for i in range(self.gpu_count)
286
+ ]
287
+ self.path_list = [Path(p) for p in path_list]
288
+
289
+ def setup_threads(self) -> None:
290
+ self.reader_threads = [
291
+ threading.Thread(
292
+ target=read_image,
293
+ args=(
294
+ self.read_queue,
295
+ self.process_queue,
296
+ self.progress_lock,
297
+ self.progress_counter,
298
+ self.path_to_train_resolutions,
299
+ ),
300
+ )
301
+ for _ in range(self.num_reader)
302
+ ]
303
+
304
+ self.process_threads = [
305
+ threading.Thread(
306
+ target=process_image,
307
+ args=(
308
+ self.process_queue,
309
+ self.write_queue,
310
+ processor,
311
+ self.progress_lock,
312
+ self.progress_counter,
313
+ ),
314
+ )
315
+ for processor in self.processor_list
316
+ ]
317
+
318
+ self.writer_threads = [
319
+ threading.Thread(
320
+ target=write_image,
321
+ args=(
322
+ self.write_queue,
323
+ self.progress_counter,
324
+ self.progress_lock,
325
+ self.path_to_train_resolutions,
326
+ ),
327
+ )
328
+ for _ in range(self.num_writer)
329
+ ]
330
+
331
+ def start_threads(self) -> None:
332
+ for thread in self.reader_threads:
333
+ thread.start()
334
+ for thread in self.process_threads:
335
+ thread.start()
336
+ for thread in self.writer_threads:
337
+ thread.start()
338
+
339
+ def join_threads(self) -> None:
340
+ for thread in self.reader_threads:
341
+ thread.join()
342
+ for thread in self.process_threads:
343
+ thread.join()
344
+ for thread in self.writer_threads:
345
+ thread.join()
346
+
347
+ def process_metadata(self) -> None:
348
+ metadata: dict[str, dict[str, object]]
349
+ if os.path.exists(self.meta_path):
350
+ try:
351
+ with open(self.meta_path, encoding="utf-8") as file:
352
+ metadata = json.load(file)
353
+ except (OSError, json.JSONDecodeError) as exc:
354
+ print(f"Error: {exc}")
355
+ metadata = {}
356
+ else:
357
+ metadata = {}
358
+ for path, reso in self.path_to_train_resolutions.items():
359
+ relative_path = str(os.path.relpath(path, self.ds_path).replace("\\", "/")).split(
360
+ "."
361
+ )[0]
362
+ metadata.setdefault(relative_path, {})
363
+ metadata[relative_path]["train_resolution"] = reso
364
+ with open(self.meta_path, "w", encoding="utf-8") as file:
365
+ json.dump(metadata, file, indent=2)
366
+
367
+ def run(self) -> None:
368
+ self.setup_threads()
369
+ self.start_threads()
370
+
371
+ total_processes = len(self.path_list)
372
+ with Progress() as progress:
373
+ task = progress.add_task("Processing images...", total=total_processes)
374
+
375
+ for path in self.path_list:
376
+ self.read_queue.put(path)
377
+ progress.update(task, advance=1)
378
+
379
+ while self.progress_counter[0] < total_processes:
380
+ with self.progress_lock:
381
+ progress.update(task, completed=self.progress_counter[0])
382
+
383
+ for _ in range(self.num_writer):
384
+ self.write_queue.put(None)
385
+ for _ in range(self.num_reader):
386
+ self.read_queue.put(None)
387
+ for _ in range(len(self.processor_list)):
388
+ self.process_queue.put(None)
389
+
390
+ self.join_threads()
391
+ self.process_metadata()
392
+
393
+
394
+ def main() -> None:
395
+ parser = argparse.ArgumentParser()
396
+ parser.add_argument("--ds_path", type=str, required=True)
397
+ parser.add_argument("--meta_path", type=str, required=True)
398
+ parser.add_argument("--vae_name", type=str, default="madebyollin/sdxl-vae-fp16-fix")
399
+ args = parser.parse_args()
400
+
401
+ path_list = glob_images_pathlib(args.ds_path, True)
402
+ pipeline = ImageProcessingPipeline(args.vae_name, path_list, args.meta_path, args.ds_path)
403
+ pipeline.run()
404
+
405
+
406
+ if __name__ == "__main__":
407
+ main()
scripts/make_ds/2.merge_tag_to_meta.py ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse
2
+ import json
3
+ import sys
4
+ from pathlib import Path
5
+
6
+ import pandas as pd
7
+ from rich.progress import Progress
8
+ from sqlalchemy import create_engine
9
+
10
+ SCRIPTS_DIR = Path(__file__).resolve().parents[1]
11
+ if str(SCRIPTS_DIR) not in sys.path:
12
+ sys.path.insert(0, str(SCRIPTS_DIR))
13
+
14
+ from _paths import DANBOORU_DB_PATH
15
+
16
+
17
+ def get_rating_tags(rating: str) -> tuple[str, ...]:
18
+ if rating == "q":
19
+ return ("nsfw",)
20
+ if rating == "e":
21
+ return ("nsfw", "explicit")
22
+ return ()
23
+
24
+
25
+ def main() -> None:
26
+ parser = argparse.ArgumentParser()
27
+ parser.add_argument("--db_path", type=str, default=str(DANBOORU_DB_PATH))
28
+ parser.add_argument("--meta_path", type=str, required=True)
29
+ parser.add_argument("--use_copyright", action="store_true")
30
+ parser.add_argument("--use_artist", action="store_true")
31
+ parser.add_argument("--use_character", action="store_true")
32
+ args = parser.parse_args()
33
+
34
+ meta_path_str = args.meta_path
35
+ with open(meta_path_str, encoding="utf-8") as file:
36
+ metadata: dict[str, dict[str, object]] = json.load(file)
37
+
38
+ db_path = args.db_path
39
+ db_url = db_path if db_path.startswith("sqlite:") else f"sqlite:///{db_path}"
40
+ engine = create_engine(db_url)
41
+ df = pd.read_sql(
42
+ "SELECT id, tag_string_general, tag_string_character, "
43
+ "tag_string_copyright, tag_string_artist, rating FROM posts",
44
+ engine,
45
+ )
46
+ df.set_index("id", inplace=True)
47
+
48
+ with Progress() as progress:
49
+ task = progress.add_task("[cyan]Processing metadata...", total=len(metadata))
50
+ for key in metadata:
51
+ filename = Path(key).name
52
+ filename_without_ext = filename.split(".")[0]
53
+ post_id = int(filename_without_ext)
54
+ if post_id not in df.index:
55
+ progress.update(task, advance=1)
56
+ continue
57
+
58
+ tags_string_general = df.loc[post_id, "tag_string_general"]
59
+ tags_string_character = df.loc[post_id, "tag_string_character"]
60
+ tags_string_artist = df.loc[post_id, "tag_string_artist"]
61
+ tags_string_copyright = df.loc[post_id, "tag_string_copyright"]
62
+
63
+ used_tags: list[str] = []
64
+ if args.use_artist and isinstance(tags_string_artist, str):
65
+ used_tags.append(tags_string_artist)
66
+ if args.use_character and isinstance(tags_string_character, str):
67
+ used_tags.append(tags_string_character)
68
+ if args.use_copyright and isinstance(tags_string_copyright, str):
69
+ used_tags.append(tags_string_copyright)
70
+
71
+ general_tags = str(tags_string_general).split(" ")
72
+ rating_tag = get_rating_tags(str(df.loc[post_id, "rating"]))
73
+ general_tags.extend(rating_tag)
74
+ metadata[key]["tags"] = (
75
+ ", ".join([tag for tag in used_tags if tag]) + " ||| " + ", ".join(general_tags)
76
+ )
77
+ progress.update(task, advance=1)
78
+
79
+ with open(meta_path_str, "w", encoding="utf-8") as file:
80
+ json.dump(metadata, file, indent=2)
81
+
82
+
83
+ if __name__ == "__main__":
84
+ main()
scripts/make_ds/3.clean_tags_and_caption.py ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse
2
+ import json
3
+ import re
4
+ import sys
5
+ from pathlib import Path
6
+
7
+ from rich.progress import Progress
8
+
9
+ SCRIPTS_DIR = Path(__file__).resolve().parents[1]
10
+ if str(SCRIPTS_DIR) not in sys.path:
11
+ sys.path.insert(0, str(SCRIPTS_DIR))
12
+
13
+ from _paths import DATASETS_DIR
14
+
15
+ PATTERN_HAIR_LENGTH = re.compile(r", (long|short|medium) hair, ")
16
+ PATTERN_HAIR_CUT = re.compile(r", (bob|hime) cut, ")
17
+ PATTERN_HAIR = re.compile(r", ([\w\-]+) hair, ")
18
+ PATTERN_WORD = re.compile(r", ([\w\-]+|hair ornament), ")
19
+
20
+ PATTERNS_REMOVE_IN_MULTI = [
21
+ PATTERN_HAIR_LENGTH,
22
+ PATTERN_HAIR_CUT,
23
+ re.compile(r", [\w\-]+ eyes, "),
24
+ re.compile(r", ([\w\-]+ sleeves|sleeveless), "),
25
+ re.compile(r", (ponytail|braid|ahoge|twintails|[\w\-]+ bun|single hair bun|single side bun|two side up|two tails|[\w\-]+ braid|sidelocks), "),
26
+ ]
27
+
28
+ CAPTION_REPLACEMENTS = [
29
+ ("anime anime", "anime"),
30
+ ("young ", ""),
31
+ ("anime girl", "girl"),
32
+ ("cartoon female", "girl"),
33
+ ("cartoon lady", "girl"),
34
+ ("cartoon character", "girl"),
35
+ ("cartoon woman", "girl"),
36
+ ("cartoon women", "girls"),
37
+ ("cartoon girl", "girl"),
38
+ ("anime female", "girl"),
39
+ ("anime lady", "girl"),
40
+ ("anime character", "girl"),
41
+ ("anime woman", "girl"),
42
+ ("anime women", "girls"),
43
+ ("lady", "girl"),
44
+ ("female", "girl"),
45
+ ("woman", "girl"),
46
+ ("women", "girls"),
47
+ ("people", "girls"),
48
+ ("person", "girl"),
49
+ ("a cartoon figure", "a figure"),
50
+ ("a cartoon image", "an image"),
51
+ ("a cartoon picture", "a picture"),
52
+ ("an anime cartoon image", "an image"),
53
+ ("a cartoon anime drawing", "a drawing"),
54
+ ("a cartoon drawing", "a drawing"),
55
+ ("girl girl", "girl"),
56
+ ]
57
+
58
+
59
+ def clean_tags(tags: str) -> str:
60
+ tags = tags.replace("^_^", "^@@@^")
61
+ tags = tags.replace("_", " ")
62
+ tags = tags.replace("^@@@^", "^_^")
63
+
64
+ tags = ", " + tags.replace(", ", ", , ") + ", "
65
+
66
+ if "girls" in tags or "boys" in tags:
67
+ for pat in PATTERNS_REMOVE_IN_MULTI:
68
+ found = pat.findall(tags)
69
+ if len(found) > 1:
70
+ tags = pat.sub("", tags)
71
+
72
+ srch_hair_len = PATTERN_HAIR_LENGTH.search(tags)
73
+ if srch_hair_len:
74
+ org = srch_hair_len.group()
75
+ tags = PATTERN_HAIR_LENGTH.sub(", @@@, ", tags)
76
+
77
+ found = PATTERN_HAIR.findall(tags)
78
+ if len(found) > 1:
79
+ tags = PATTERN_HAIR.sub("", tags)
80
+
81
+ if srch_hair_len:
82
+ tags = tags.replace(", @@@, ", org)
83
+
84
+ found = PATTERN_WORD.findall(tags)
85
+ for word in found:
86
+ if re.search(f", ((\w+) )+{word}, ", tags):
87
+ tags = tags.replace(f", {word}, ", "")
88
+
89
+ tags = tags.replace(", , ", ", ")
90
+ assert tags.startswith(", ") and tags.endswith(", ")
91
+ tags = tags[2:-2]
92
+ return tags
93
+
94
+
95
+ def clean_caption(caption: str) -> str:
96
+ for rf, rt in CAPTION_REPLACEMENTS:
97
+ replaced = True
98
+ while replaced:
99
+ bef = caption
100
+ caption = caption.replace(rf, rt)
101
+ replaced = bef != caption
102
+ return caption
103
+
104
+
105
+ parser = argparse.ArgumentParser()
106
+ parser.add_argument(
107
+ "--meta_path", type=str, default=str(DATASETS_DIR / "safe_aibooru" / "meta.json")
108
+ )
109
+ args = parser.parse_args()
110
+
111
+ meta_path_str = args.meta_path
112
+ with open(meta_path_str, encoding="utf-8") as file:
113
+ metadata: dict[str, dict[str, object]] = json.load(file)
114
+
115
+ with Progress() as progress:
116
+ task = progress.add_task("[cyan]Processing metadata...", total=len(metadata))
117
+ for key in metadata:
118
+ if isinstance(metadata[key].get("tags"), str):
119
+ metadata[key]["tags"] = clean_tags(str(metadata[key]["tags"]))
120
+ if isinstance(metadata[key].get("caption"), str):
121
+ metadata[key]["caption"] = clean_caption(str(metadata[key]["caption"]))
122
+ progress.update(task, advance=1)
123
+
124
+ with open(meta_path_str, "w", encoding="utf-8") as file:
125
+ json.dump(metadata, file, indent=2)
scripts/make_ds/4.merge_wd_tagger.py ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse
2
+ import json
3
+ import sys
4
+ import threading
5
+ from pathlib import Path
6
+ from queue import Queue
7
+
8
+ from PIL import Image
9
+ from rich import get_console
10
+ from rich.progress import BarColumn, Progress, TimeElapsedColumn, TimeRemainingColumn
11
+ from wdtagger import Tagger
12
+
13
+ ROOT = Path(__file__).resolve().parents[2]
14
+ if str(ROOT) not in sys.path:
15
+ sys.path.insert(0, str(ROOT))
16
+
17
+ from utils import get_meta_key_from_path, glob_images_pathlib
18
+
19
+
20
+ def worker(
21
+ task_queue: Queue[list[Path] | None],
22
+ result_queue: Queue[int | None],
23
+ device_id: int,
24
+ metadata: dict[str, dict[str, object]],
25
+ ds_path_str: str,
26
+ lock: threading.Lock,
27
+ ) -> None:
28
+ tagger = Tagger(
29
+ loglevel="ERROR",
30
+ model_repo="SmilingWolf/wd-vit-large-tagger-v3",
31
+ num_threads=1,
32
+ providers=[("CUDAExecutionProvider", {"device_id": device_id}), "CPUExecutionProvider"],
33
+ )
34
+
35
+ while True:
36
+ batch_files = task_queue.get()
37
+ if batch_files is None:
38
+ task_queue.task_done()
39
+ break
40
+
41
+ len_before = len(batch_files)
42
+ batch_files = [
43
+ file_path
44
+ for file_path in batch_files
45
+ if not file_path.with_suffix(".txt").exists()
46
+ ]
47
+
48
+ results = []
49
+ if batch_files:
50
+ try:
51
+ images = [Image.open(image_path) for image_path in batch_files]
52
+ results = tagger.tag(images)
53
+ except (OSError, RuntimeError, ValueError) as exc:
54
+ print(f"Tagger error: {exc}")
55
+ task_queue.task_done()
56
+ continue
57
+
58
+ if not isinstance(results, list):
59
+ results = [results]
60
+
61
+ for image_path, result in zip(batch_files, results):
62
+ with lock:
63
+ meta_key = get_meta_key_from_path(image_path, ds_path_str)
64
+ metadata.setdefault(meta_key, {})
65
+ before_tags = str(metadata[meta_key].get("tags", "")).split(", ")
66
+ more_tags = result.general_tags_string.split(", ")
67
+ more_tags_not_in_before = [
68
+ tag for tag in more_tags if tag not in before_tags
69
+ ]
70
+ final_tags = before_tags + more_tags_not_in_before
71
+ final_tags_str = ", ".join(tag for tag in final_tags if tag)
72
+ metadata[meta_key]["tags"] = final_tags_str
73
+ print("before:", before_tags)
74
+ print("after:", final_tags_str)
75
+
76
+ result_queue.put(len_before)
77
+ task_queue.task_done()
78
+
79
+ result_queue.put(None)
80
+
81
+
82
+ def main(args: argparse.Namespace) -> None:
83
+ meta_path_str = args.meta_path
84
+ ds_path_str = args.ds_path
85
+ image_paths = glob_images_pathlib(ds_path_str, True)
86
+
87
+ with open(args.meta_path, encoding="utf-8") as file:
88
+ metadata: dict[str, dict[str, object]] = json.load(file)
89
+
90
+ batch_size = 4
91
+ task_queue: Queue[list[Path] | None] = Queue()
92
+ result_queue: Queue[int | None] = Queue()
93
+ for i in range(0, len(image_paths), batch_size):
94
+ batch_files = image_paths[i : i + batch_size]
95
+ task_queue.put(batch_files)
96
+
97
+ num_workers = args.num_workers
98
+ gpu_count = args.num_gpus
99
+ lock = threading.Lock()
100
+ workers = [
101
+ threading.Thread(
102
+ target=worker,
103
+ args=(task_queue, result_queue, i % max(gpu_count, 1), metadata, ds_path_str, lock),
104
+ )
105
+ for i in range(num_workers)
106
+ ]
107
+
108
+ for worker_thread in workers:
109
+ worker_thread.start()
110
+
111
+ for _ in workers:
112
+ task_queue.put(None)
113
+
114
+ with Progress(
115
+ "[progress.description]{task.description}",
116
+ BarColumn(),
117
+ "[progress.percentage]{task.percentage:>3.0f}%",
118
+ TimeElapsedColumn(),
119
+ TimeRemainingColumn(),
120
+ "[green] [{task.completed} / {task.total}] [/]",
121
+ console=get_console(),
122
+ ) as progress:
123
+ task = progress.add_task("Processing images...", total=len(image_paths))
124
+
125
+ processed_count = 0
126
+ done_workers = 0
127
+
128
+ while done_workers < num_workers:
129
+ item = result_queue.get()
130
+ if item is None:
131
+ done_workers += 1
132
+ else:
133
+ processed_count += item
134
+ progress.update(task, completed=processed_count)
135
+
136
+ for worker_thread in workers:
137
+ worker_thread.join()
138
+
139
+ with open(meta_path_str, "w", encoding="utf-8") as meta_file:
140
+ json.dump(metadata, meta_file, indent=2)
141
+
142
+
143
+ if __name__ == "__main__":
144
+ parser = argparse.ArgumentParser()
145
+ parser.add_argument("--meta_path", type=str, required=True)
146
+ parser.add_argument("--ds_path", type=str, required=True)
147
+ parser.add_argument("--num_workers", type=int, default=4)
148
+ parser.add_argument("--num_gpus", type=int, default=1)
149
+ args = parser.parse_args()
150
+ main(args)
scripts/make_ds/5.edit_tags.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse
2
+ import json
3
+
4
+
5
+ def main() -> None:
6
+ parser = argparse.ArgumentParser()
7
+ parser.add_argument("--meta_path", type=str, required=True)
8
+ args = parser.parse_args()
9
+
10
+ meta_path_str = args.meta_path
11
+ with open(meta_path_str, encoding="utf-8") as file:
12
+ metadata: dict[str, dict[str, object]] = json.load(file)
13
+
14
+ for key, value in metadata.items():
15
+ tags = str(value.get("tags", ""))
16
+ if "by_ai" in key and "by_ai" not in tags:
17
+ tags = f"by ai, {tags}"
18
+ tags = f"best quality, high quality, {tags}"
19
+ metadata[key]["tags"] = tags
20
+
21
+ with open(meta_path_str, "w", encoding="utf-8") as file:
22
+ json.dump(metadata, file, indent=2)
23
+
24
+
25
+ if __name__ == "__main__":
26
+ main()
scripts/make_ds/8.add_tag_txt.py ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse
2
+ import sqlite3
3
+ from pathlib import Path
4
+
5
+
6
+ def is_image(path: Path) -> bool:
7
+ return path.suffix.lower() in {
8
+ ".jpg",
9
+ ".jpeg",
10
+ ".png",
11
+ ".bmp",
12
+ ".gif",
13
+ ".webp",
14
+ ".tiff",
15
+ ".tif",
16
+ ".svg",
17
+ }
18
+
19
+
20
+ def main() -> None:
21
+ parser = argparse.ArgumentParser()
22
+ parser.add_argument("--image_path", type=str, required=True)
23
+ parser.add_argument("--reclusive", action="store_true")
24
+ parser.add_argument("--dataset_path", type=str, required=True)
25
+ args = parser.parse_args()
26
+
27
+ image_base = Path(args.image_path)
28
+ if args.reclusive:
29
+ image_path_list = [
30
+ path for path in image_base.rglob("*") if path.is_file() and is_image(path)
31
+ ]
32
+ else:
33
+ image_path_list = [
34
+ path for path in image_base.iterdir() if path.is_file() and is_image(path)
35
+ ]
36
+
37
+ with sqlite3.connect(args.dataset_path) as conn:
38
+ cursor = conn.cursor()
39
+ for image_path in image_path_list:
40
+ image_id = image_path.stem
41
+ cursor.execute(
42
+ "SELECT tag_string_general FROM posts WHERE id=?",
43
+ (image_id,),
44
+ )
45
+ row = cursor.fetchone()
46
+ if row is None:
47
+ continue
48
+ tags = str(row[0]).split(" ")
49
+ tags = [tag.replace("_", " ") for tag in tags]
50
+
51
+ tag_file = image_path.with_suffix(".txt")
52
+ if tag_file.exists():
53
+ existing = tag_file.read_text(encoding="utf-8").split(", ")
54
+ tags = list(set(tags + existing))
55
+ tag_file.write_text(", ".join(tags), encoding="utf-8")
56
+
57
+
58
+ if __name__ == "__main__":
59
+ main()
scripts/make_ds/9.remove_img.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+ from pathlib import Path
3
+
4
+ SCRIPTS_DIR = Path(__file__).resolve().parents[1]
5
+ if str(SCRIPTS_DIR) not in sys.path:
6
+ sys.path.insert(0, str(SCRIPTS_DIR))
7
+
8
+ from _paths import DATASETS_DIR
9
+
10
+
11
+ def main() -> None:
12
+ base_path = DATASETS_DIR / "safe_aibooru"
13
+ for path in base_path.rglob("*"):
14
+ if path.is_file() and path.suffix not in {".json", ".txt", ".npz", ".caption"}:
15
+ path.unlink()
16
+
17
+
18
+ if __name__ == "__main__":
19
+ main()
scripts/make_ds/__init__.py ADDED
File without changes
scripts/make_ds/utils/__init__.py ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from pathlib import Path
3
+ from typing import Generator
4
+
5
+
6
+ def get_meta_key_from_path(path: Path | str, ds_path: Path | str) -> str:
7
+ return str(os.path.relpath(path, ds_path).replace("\\", "/")).split(".")[0]
8
+
9
+
10
+ def glob_images_pathlib(dir_path: Path | str, recursive: bool) -> list[Path]:
11
+ dir_path = Path(dir_path)
12
+ IMAGE_EXTENSIONS = [
13
+ ".png",
14
+ ".jpg",
15
+ ".jpeg",
16
+ ".webp",
17
+ ".bmp",
18
+ ".PNG",
19
+ ".JPG",
20
+ ".JPEG",
21
+ ".WEBP",
22
+ ".BMP",
23
+ ]
24
+ image_paths: list[Path] = []
25
+ if recursive:
26
+ for ext in IMAGE_EXTENSIONS:
27
+ image_paths += list(dir_path.rglob(f"*{ext}"))
28
+ else:
29
+ for ext in IMAGE_EXTENSIONS:
30
+ image_paths += list(dir_path.glob(f"*{ext}"))
31
+ image_paths = sorted(set(image_paths))
32
+ return image_paths
33
+
34
+
35
+ def gen_images_pathlib(dir_path: Path | str, recursive: bool) -> Generator[Path, None, None]:
36
+ dir_path = Path(dir_path)
37
+ IMAGE_EXTENSIONS = [
38
+ ".png",
39
+ ".jpg",
40
+ ".jpeg",
41
+ ".webp",
42
+ ".bmp",
43
+ ".PNG",
44
+ ".JPG",
45
+ ".JPEG",
46
+ ".WEBP",
47
+ ".BMP",
48
+ ]
49
+
50
+ seen_paths: set[Path] = set()
51
+
52
+ if recursive:
53
+ for ext in IMAGE_EXTENSIONS:
54
+ for path in dir_path.rglob(f"*{ext}"):
55
+ if path not in seen_paths:
56
+ seen_paths.add(path)
57
+ yield Path(path)
58
+ else:
59
+ for ext in IMAGE_EXTENSIONS:
60
+ for path in dir_path.glob(f"*{ext}"):
61
+ if path not in seen_paths:
62
+ seen_paths.add(path)
63
+ yield Path(path)
64
+
65
+
66
+ def glob_npz_pathlib(dir_path: Path | str, recursive: bool) -> list[Path]:
67
+ dir_path = Path(dir_path)
68
+ EXTENSIONS = [".npz"]
69
+ image_paths: list[Path] = []
70
+ if recursive:
71
+ for ext in EXTENSIONS:
72
+ image_paths += list(dir_path.rglob(f"*{ext}"))
73
+ else:
74
+ for ext in EXTENSIONS:
75
+ image_paths += list(dir_path.glob(f"*{ext}"))
76
+ image_paths = sorted(set(image_paths))
77
+ return image_paths
scripts/parquet_danbooru.py ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import pyarrow as pa
3
+ import pyarrow.parquet as pq
4
+ from sqlalchemy import text
5
+ from tqdm import tqdm
6
+
7
+ from _paths import DANBOORU_DB_PATH, PARQUET_DIR, PARQUET_PATH
8
+ from db import get_engine, t_posts
9
+
10
+
11
+ def main() -> None:
12
+ PARQUET_DIR.mkdir(parents=True, exist_ok=True)
13
+ engine = get_engine(str(DANBOORU_DB_PATH))
14
+ chunk_size = 10000
15
+
16
+ with engine.connect() as conn:
17
+ total_row = conn.execute(text("SELECT COUNT(*) FROM posts")).fetchone()
18
+ if total_row is None:
19
+ return
20
+
21
+ total_rows = total_row[0]
22
+ chunk_count = total_rows // chunk_size if total_rows else 0
23
+ chunk_iter = pd.read_sql(t_posts.select(), engine, chunksize=chunk_size)
24
+
25
+ writer: pq.ParquetWriter | None = None
26
+ for chunk in tqdm(chunk_iter, total=chunk_count):
27
+ chunk["tag_string_artist"] = chunk["tag_string_artist"].str.split(" ")
28
+ chunk["tag_string_meta"] = chunk["tag_string_meta"].str.split(" ")
29
+ chunk["tag_string_character"] = chunk["tag_string_character"].str.split(" ")
30
+ chunk["tag_string_general"] = chunk["tag_string_general"].str.split(" ")
31
+ chunk["tag_string_copyright"] = chunk["tag_string_copyright"].str.split(" ")
32
+
33
+ table = pa.Table.from_pandas(chunk)
34
+ if writer is None:
35
+ writer = pq.ParquetWriter(
36
+ str(PARQUET_PATH), table.schema, compression="snappy"
37
+ )
38
+ writer.write_table(table)
39
+
40
+ if writer is not None:
41
+ writer.close()
42
+
43
+
44
+ if __name__ == "__main__":
45
+ main()
scripts/run_make_ds.bash ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ uv run python ./scripts/make_ds/1.prepare_latents.py --ds_path "data/datasets/best_quality" --meta_path "data/datasets/best_quality/meta.json"
2
+ uv run python ./scripts/make_ds/2.merge_tag_to_meta.py --meta_path "data/datasets/best_quality/meta.json" --db_path "data/db/danbooru_metadata.db"
scripts/statistic/0.get_tag_frequency.py ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse
2
+ import sys
3
+ from collections import Counter
4
+ from pathlib import Path
5
+
6
+ import pandas as pd
7
+ from rich.progress import Progress
8
+ from sqlalchemy import create_engine
9
+
10
+ SCRIPTS_DIR = Path(__file__).resolve().parents[1]
11
+ if str(SCRIPTS_DIR) not in sys.path:
12
+ sys.path.insert(0, str(SCRIPTS_DIR))
13
+
14
+ from _paths import DANBOORU_DB_PATH, TAGS_DIR
15
+
16
+
17
+ def main(database_path: str, tag_field: str, output_file: str, start_date: str) -> None:
18
+ engine = create_engine(f"sqlite:///{database_path}")
19
+
20
+ total_query = "SELECT COUNT(*) FROM posts WHERE created_at > ?"
21
+ total_count = pd.read_sql(total_query, engine, params=(start_date,)).iloc[0, 0]
22
+
23
+ query = f"SELECT {tag_field} FROM posts WHERE created_at > ?"
24
+ counter: Counter[str] = Counter()
25
+
26
+ with Progress() as progress:
27
+ task = progress.add_task("[green]Processing data...", total=int(total_count))
28
+ for chunk in pd.read_sql(query, engine, params=(start_date,), chunksize=1000):
29
+ for tag_string in chunk[tag_field]:
30
+ if pd.isna(tag_string):
31
+ continue
32
+ for tag in str(tag_string).split(" "):
33
+ counter[tag] += 1
34
+ progress.update(task, advance=len(chunk))
35
+
36
+ df = (
37
+ pd.DataFrame(counter.items(), columns=["tag", "count"])
38
+ .sort_values("count", ascending=False)
39
+ .reset_index(drop=True)
40
+ )
41
+ TAGS_DIR.mkdir(parents=True, exist_ok=True)
42
+ df.to_csv(output_file, index=False)
43
+
44
+
45
+ if __name__ == "__main__":
46
+ parser = argparse.ArgumentParser(
47
+ description=(
48
+ "Count tag frequency in a tag field after a start date and save as CSV."
49
+ )
50
+ )
51
+ parser.add_argument("--database", type=str, default=str(DANBOORU_DB_PATH))
52
+ parser.add_argument("--tag-field", type=str, default="tag_string")
53
+ parser.add_argument("--output", type=str, default=str(TAGS_DIR / "tag_frequency.csv"))
54
+ parser.add_argument("--start-date", type=str, required=True)
55
+
56
+ args = parser.parse_args()
57
+ main(args.database, args.tag_field, args.output, args.start_date)
scripts/statistic/1.get_score_distribution.py ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse
2
+ import json
3
+ import sys
4
+ from collections import Counter, defaultdict
5
+ from pathlib import Path
6
+
7
+ import pandas as pd
8
+ from rich.progress import (
9
+ BarColumn,
10
+ MofNCompleteColumn,
11
+ Progress,
12
+ SpinnerColumn,
13
+ TimeElapsedColumn,
14
+ TimeRemainingColumn,
15
+ )
16
+ from sqlalchemy import create_engine
17
+
18
+ SCRIPTS_DIR = Path(__file__).resolve().parents[1]
19
+ if str(SCRIPTS_DIR) not in sys.path:
20
+ sys.path.insert(0, str(SCRIPTS_DIR))
21
+
22
+ from _paths import DANBOORU_DB_PATH, STATS_DIR
23
+
24
+ def main(database_path: str, output_file: str) -> None:
25
+ engine = create_engine(f"sqlite:///{database_path}")
26
+ result: dict[str, dict[str, Counter[int]]] = defaultdict(lambda: defaultdict(Counter))
27
+
28
+ with Progress(
29
+ SpinnerColumn(),
30
+ "[progress.description]{task.description}",
31
+ BarColumn(),
32
+ MofNCompleteColumn(),
33
+ TimeElapsedColumn(),
34
+ TimeRemainingColumn(),
35
+ ) as progress:
36
+ total = pd.read_sql("SELECT COUNT(*) FROM posts", engine).iloc[0, 0]
37
+ task_id = progress.add_task("[green]Processing data...", total=int(total))
38
+
39
+ for chunk in pd.read_sql(
40
+ "SELECT created_at, rating, score FROM posts", engine, chunksize=1000
41
+ ):
42
+ for _, row in chunk.iterrows():
43
+ created_at = str(row["created_at"])
44
+ rating = str(row["rating"])
45
+ score = int(row["score"])
46
+ year_month = created_at[:7]
47
+ result[year_month][rating][score] += 1
48
+ progress.update(task_id, advance=len(chunk))
49
+
50
+ STATS_DIR.mkdir(parents=True, exist_ok=True)
51
+ with open(output_file, "w", encoding="utf-8") as file:
52
+ file.write("year_month,rating,score,count\n")
53
+ for year_month, ratings in result.items():
54
+ for rating, counter in ratings.items():
55
+ for score, count in counter.items():
56
+ file.write(f"{year_month},{rating},{score},{count}\n")
57
+
58
+ json_ready = {
59
+ year_month: {rating: dict(counter) for rating, counter in ratings.items()}
60
+ for year_month, ratings in result.items()
61
+ }
62
+ with open(output_file.replace(".csv", ".json"), "w", encoding="utf-8") as file:
63
+ json.dump(json_ready, file)
64
+
65
+
66
+ if __name__ == "__main__":
67
+ parser = argparse.ArgumentParser(
68
+ description="Compute per-month score distributions grouped by rating."
69
+ )
70
+ parser.add_argument("--database", type=str, default=str(DANBOORU_DB_PATH))
71
+ parser.add_argument("--output", type=str, default=str(STATS_DIR / "score_distribution.csv"))
72
+ args = parser.parse_args()
73
+
74
+ main(args.database, args.output)
scripts/statistic/2.get_percentile.py ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+ from pathlib import Path
3
+
4
+ import numpy as np
5
+ import pandas as pd
6
+ from rich.progress import (
7
+ BarColumn,
8
+ MofNCompleteColumn,
9
+ Progress,
10
+ SpinnerColumn,
11
+ TimeElapsedColumn,
12
+ TimeRemainingColumn,
13
+ )
14
+ from sqlalchemy import create_engine
15
+
16
+ SCRIPTS_DIR = Path(__file__).resolve().parents[1]
17
+ if str(SCRIPTS_DIR) not in sys.path:
18
+ sys.path.insert(0, str(SCRIPTS_DIR))
19
+
20
+ from _paths import DANBOORU_DB_PATH, STATS_DIR
21
+
22
+ def weighted_quantile(
23
+ values: list[float] | np.ndarray,
24
+ quantiles: list[float] | np.ndarray,
25
+ sample_weight: list[float] | np.ndarray,
26
+ ) -> np.ndarray:
27
+ sorter = np.argsort(values)
28
+ values_arr = np.array(values)[sorter]
29
+ weight_arr = np.array(sample_weight)[sorter]
30
+ weighted_quantiles = np.cumsum(weight_arr) - 0.5 * weight_arr
31
+ weighted_quantiles /= np.sum(weight_arr)
32
+ return np.interp(quantiles, weighted_quantiles, values_arr)
33
+
34
+
35
+ def main() -> None:
36
+ STATS_DIR.mkdir(parents=True, exist_ok=True)
37
+ df = pd.read_csv(STATS_DIR / "score_distribution.csv")
38
+ quantiles = np.array([0.1, 0.5, 0.9])
39
+ results: list[list[float | str]] = []
40
+
41
+ for (year_month, rating), group in df.groupby(["year_month", "rating"]):
42
+ scores = group["score"].to_numpy()
43
+ counts = group["count"].to_numpy()
44
+ q_values = weighted_quantile(scores, quantiles, counts)
45
+ results.append([year_month, rating, q_values[0], q_values[1], q_values[2]])
46
+
47
+ result_df = pd.DataFrame(
48
+ results,
49
+ columns=[
50
+ "year_month",
51
+ "rating",
52
+ "10th_percentile",
53
+ "50th_percentile",
54
+ "90th_percentile",
55
+ ],
56
+ ).round(1)
57
+ result_df.to_csv(STATS_DIR / "score_percentile.csv", index=False)
58
+
59
+ engine = create_engine(f"sqlite:///{DANBOORU_DB_PATH}")
60
+ post_quality: dict[int, str] = {}
61
+
62
+ with Progress(
63
+ SpinnerColumn(),
64
+ BarColumn(),
65
+ MofNCompleteColumn(),
66
+ TimeElapsedColumn(),
67
+ TimeRemainingColumn(),
68
+ ) as progress:
69
+ posts_df = pd.read_sql("SELECT id, created_at, rating, score FROM posts", engine)
70
+ posts_df["year_month"] = posts_df["created_at"].apply(lambda value: str(value)[:7])
71
+
72
+ percentile_df = (
73
+ posts_df.groupby(["year_month", "rating"])["score"]
74
+ .quantile(quantiles)
75
+ .unstack()
76
+ )
77
+
78
+ total = len(posts_df)
79
+ task = progress.add_task("[green]Processing data...", total=total)
80
+
81
+ for _, row in posts_df.iterrows():
82
+ year_month = row["year_month"]
83
+ rating = row["rating"]
84
+ score = row["score"]
85
+
86
+ quality = "worst quality"
87
+ if (year_month, rating) in percentile_df.index:
88
+ percentiles = percentile_df.loc[(year_month, rating)]
89
+ if score >= percentiles[0.1]:
90
+ quality = "low quality"
91
+ if score >= percentiles[0.5]:
92
+ quality = "normal quality"
93
+ if score >= percentiles[0.9]:
94
+ quality = "high quality"
95
+
96
+ post_quality[int(row["id"])] = quality
97
+ progress.update(task, advance=1)
98
+
99
+ quality_df = pd.DataFrame(post_quality.items(), columns=["post_id", "quality"])
100
+ quality_df.to_csv(STATS_DIR / "post_quality.csv", index=False)
101
+
102
+ quality_counts = quality_df["quality"].value_counts()
103
+ print(quality_counts)
104
+
105
+
106
+ if __name__ == "__main__":
107
+ main()
scripts/statistic/3.get_artist_quality.py ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+ from pathlib import Path
3
+
4
+ import pandas as pd
5
+ from rich import get_console
6
+ from rich.progress import (
7
+ BarColumn,
8
+ MofNCompleteColumn,
9
+ Progress,
10
+ SpinnerColumn,
11
+ TimeElapsedColumn,
12
+ TimeRemainingColumn,
13
+ )
14
+ from sqlalchemy import create_engine
15
+
16
+ SCRIPTS_DIR = Path(__file__).resolve().parents[1]
17
+ if str(SCRIPTS_DIR) not in sys.path:
18
+ sys.path.insert(0, str(SCRIPTS_DIR))
19
+
20
+ from _paths import DANBOORU_DB_PATH, STATS_DIR
21
+
22
+
23
+ def main() -> None:
24
+ console = get_console()
25
+
26
+ console.log("Reading post quality data...", style="bold blue")
27
+ quality_df = pd.read_csv(STATS_DIR / "post_quality.csv").set_index("post_id")
28
+
29
+ console.log("Reading post metadata...", style="bold blue")
30
+ engine = create_engine(f"sqlite:///{DANBOORU_DB_PATH}")
31
+ posts_df = pd.read_sql(
32
+ "SELECT id, tag_string_artist as artist, rating, created_at FROM posts",
33
+ engine,
34
+ )
35
+
36
+ artist_quality: dict[str, dict[str, int]] = {}
37
+
38
+ console.log("Processing data...", style="bold blue")
39
+ with Progress(
40
+ SpinnerColumn(),
41
+ BarColumn(),
42
+ MofNCompleteColumn(),
43
+ TimeElapsedColumn(),
44
+ TimeRemainingColumn(),
45
+ ) as progress:
46
+ task_id = progress.add_task("[green]Processing data...", total=len(posts_df))
47
+ for _, row in posts_df.iterrows():
48
+ if row["rating"] == "e" or str(row["created_at"]) < "2021-01":
49
+ progress.update(task_id, advance=1)
50
+ continue
51
+ artist = str(row["artist"])
52
+ quality = (
53
+ quality_df.loc[row["id"], "quality"]
54
+ if row["id"] in quality_df.index
55
+ else "normal quality"
56
+ )
57
+ artist_quality.setdefault(artist, {"high quality": 0, "total": 0})
58
+ artist_quality[artist]["total"] += 1
59
+ artist_quality[artist]["high quality"] += int(quality == "high quality")
60
+ progress.update(task_id, advance=1)
61
+
62
+ console.log("Calculating artist quality...", style="bold blue")
63
+ result = {
64
+ artist: data["high quality"] / data["total"]
65
+ for artist, data in artist_quality.items()
66
+ if data["total"] > 10
67
+ }
68
+
69
+ console.log("Sorting artist quality...", style="bold blue")
70
+ sorted_artists = sorted(result, key=lambda key: result[key], reverse=True)
71
+
72
+ STATS_DIR.mkdir(parents=True, exist_ok=True)
73
+ with open(STATS_DIR / "artist_quality.csv", "w", encoding="utf-8") as file:
74
+ file.write("tag,quality\n")
75
+ for artist in sorted_artists:
76
+ file.write(f"{artist},{result[artist]:.2%}\n")
77
+
78
+
79
+ if __name__ == "__main__":
80
+ main()
scripts/statistic/4.download_top_artist_posts.py ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import csv
2
+ import sqlite3
3
+ import sys
4
+ from concurrent.futures import ThreadPoolExecutor, as_completed
5
+ from pathlib import Path
6
+
7
+ import requests
8
+
9
+ SCRIPTS_DIR = Path(__file__).resolve().parents[1]
10
+ if str(SCRIPTS_DIR) not in sys.path:
11
+ sys.path.insert(0, str(SCRIPTS_DIR))
12
+
13
+ from _paths import DANBOORU_DB_PATH, DATASETS_DIR, STATS_DIR
14
+
15
+ def download_image(artist: str, post_id: int, file_url: str) -> None:
16
+ try:
17
+ response = requests.get(file_url)
18
+ response.raise_for_status()
19
+ artist_path = DATASETS_DIR / "top_artists" / artist
20
+ artist_path.mkdir(parents=True, exist_ok=True)
21
+ with open(artist_path / f"{post_id}.jpg", "wb") as file:
22
+ file.write(response.content)
23
+ print(f"Downloaded {artist} - {post_id}")
24
+ except requests.RequestException as exc:
25
+ print(f"Failed to download {artist} - {post_id}: {exc}")
26
+
27
+
28
+ def main() -> None:
29
+ file_path = STATS_DIR / "artist_quality.csv"
30
+ top_n = 99
31
+
32
+ top_n_artists: list[str] = ["snowcake47"]
33
+ with open(file_path, encoding="utf-8") as file:
34
+ reader = csv.reader(file)
35
+ next(reader, None)
36
+ for row in reader:
37
+ artist, _ = row
38
+ top_n_artists.append(artist)
39
+ if len(top_n_artists) == top_n:
40
+ break
41
+
42
+ conn = sqlite3.connect(str(DANBOORU_DB_PATH))
43
+ cursor = conn.cursor()
44
+ (DATASETS_DIR / "top_artists").mkdir(parents=True, exist_ok=True)
45
+
46
+ with ThreadPoolExecutor(max_workers=16) as executor:
47
+ futures = []
48
+ for artist in top_n_artists:
49
+ cursor.execute(
50
+ "SELECT id, file_url FROM posts "
51
+ "WHERE tag_string_artist = ? AND created_at >= '2021-01' "
52
+ "ORDER BY id DESC LIMIT 50",
53
+ (artist,),
54
+ )
55
+ for post_id, file_url in cursor.fetchall():
56
+ if not isinstance(file_url, str):
57
+ continue
58
+ futures.append(executor.submit(download_image, artist, post_id, file_url))
59
+
60
+ for future in as_completed(futures):
61
+ future.result()
62
+
63
+ conn.close()
64
+
65
+
66
+ if __name__ == "__main__":
67
+ main()
scripts/statistic/5.download_my_seleced.py ADDED
@@ -0,0 +1,486 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse
2
+ import os
3
+ import queue
4
+ import sys
5
+ import threading
6
+ from pathlib import Path
7
+
8
+ import requests
9
+ from rich import get_console
10
+ from sqlalchemy import create_engine, text
11
+
12
+ SCRIPTS_DIR = Path(__file__).resolve().parents[1]
13
+ if str(SCRIPTS_DIR) not in sys.path:
14
+ sys.path.insert(0, str(SCRIPTS_DIR))
15
+
16
+ from _paths import DANBOORU_DB_PATH, DOWNLOADS_DIR
17
+
18
+ console = get_console()
19
+ parser = argparse.ArgumentParser()
20
+ parser.add_argument("--out_dir", type=str, default=str(DOWNLOADS_DIR / "selected_artists"))
21
+ parser.add_argument("--num_threads", type=int, default=16)
22
+ parser.add_argument("--api_key", type=str)
23
+ parser.add_argument("--login", type=str)
24
+ args = parser.parse_args()
25
+
26
+ OUT_DIR: str = args.out_dir
27
+ os.makedirs(OUT_DIR, exist_ok=True)
28
+
29
+ NUM_THREADS: int = args.num_threads
30
+
31
+ task_queue: queue.Queue[tuple[int, str, str]] = queue.Queue(64)
32
+
33
+ IMAGE_EXTENSIONS: set[str] = {
34
+ "png",
35
+ "jpg",
36
+ "jpeg",
37
+ "webp",
38
+ "bmp",
39
+ "PNG",
40
+ "JPG",
41
+ "JPEG",
42
+ "WEBP",
43
+ "BMP",
44
+ }
45
+
46
+
47
+ def fetch_posts_to_queue(tag: str) -> None:
48
+ engine = create_engine(f"sqlite:///{DANBOORU_DB_PATH}")
49
+ with engine.connect() as conn:
50
+ sql = text("SELECT id FROM posts_fts WHERE tag_string_artist MATCH :tag")
51
+ resp = conn.execute(sql.bindparams(tag=f'"{tag}"'))
52
+ for row in resp:
53
+ post_id = row[0]
54
+ file_sql = text("SELECT file_url FROM posts WHERE id = :post_id LIMIT 1")
55
+ file_row = conn.execute(file_sql.bindparams(post_id=post_id)).fetchone()
56
+ if file_row is None:
57
+ continue
58
+ file_url = file_row[0]
59
+ if not isinstance(file_url, str):
60
+ continue
61
+ if file_url.split(".")[-1] in IMAGE_EXTENSIONS:
62
+ task_queue.put((int(post_id), file_url, tag))
63
+
64
+
65
+ def download_image(post_id: int, url: str, target_dir: str) -> None:
66
+ try:
67
+ response = requests.get(url, stream=True)
68
+ response.raise_for_status()
69
+ ext = url.split(".")[-1]
70
+ file_path = os.path.join(target_dir, f"{post_id}.{ext}")
71
+ with open(file_path, "wb") as file:
72
+ for chunk in response.iter_content(1024):
73
+ file.write(chunk)
74
+ except requests.RequestException as exc:
75
+ console.log(f"Failed to download {url}: {exc}")
76
+
77
+
78
+ def worker() -> None:
79
+ while True:
80
+ try:
81
+ post_id, url, tag = task_queue.get()
82
+ except queue.Empty:
83
+ break
84
+ target_dir = os.path.join(OUT_DIR, tag)
85
+ os.makedirs(target_dir, exist_ok=True)
86
+ download_image(post_id, url, target_dir)
87
+ task_queue.task_done()
88
+
89
+
90
+ def main() -> None:
91
+ threads: list[threading.Thread] = []
92
+ for _ in range(NUM_THREADS):
93
+ thread = threading.Thread(target=worker)
94
+ thread.start()
95
+ threads.append(thread)
96
+
97
+ try:
98
+ tags = [
99
+ "-you_(you_2023_8_16)",
100
+ "2_blankk",
101
+ "9chung",
102
+ "abpart",
103
+ "adju_ster",
104
+ "ai_dongdong",
105
+ "aisutei",
106
+ "ajeu914",
107
+ "akabino",
108
+ "akahito_(akaironotanin)",
109
+ "akari0120_s",
110
+ "akita_hika",
111
+ "akusema",
112
+ "alisi",
113
+ "amagasa_yun",
114
+ "amana_(pocketkey)",
115
+ "ame_(uten_cancel)",
116
+ "amiki_yuzuru",
117
+ "anmi",
118
+ "ano_(gccx8784)",
119
+ "anteiru",
120
+ "archinoer",
121
+ "as109",
122
+ "asakura_maru",
123
+ "asura_(asurauser)",
124
+ "auguste",
125
+ "autumnlll",
126
+ "aya02ka",
127
+ "aztodio",
128
+ "beijuu",
129
+ "bga",
130
+ "bluefield",
131
+ "bo_toike57",
132
+ "booota",
133
+ "c_civciv",
134
+ "change_(1044080555)",
135
+ "chela77",
136
+ "chiroru_(cheese-roll)",
137
+ "chui_art",
138
+ "chyko",
139
+ "chyoel",
140
+ "ciloranko",
141
+ "cmdr_saturn",
142
+ "cofffee",
143
+ "cutesexyrobutts",
144
+ "cyobiro",
145
+ "daji",
146
+ "daniel_deng",
147
+ "darling0221",
148
+ "dashi_(dashiart)",
149
+ "demizu_posuka",
150
+ "deyo_(nicijyou)",
151
+ "dichlorvos",
152
+ "dino_(dinoartforame)",
153
+ "dkxlek",
154
+ "dodo_(yatotoyatoto)",
155
+ "domi_(hongsung0819)",
156
+ "douya_(233)",
157
+ "dr_altruist",
158
+ "drive_shot",
159
+ "drone_(drone_37)",
160
+ "ebifurya",
161
+ "ebiri_fy",
162
+ "echo_(circa)",
163
+ "edison_(mvpg8237)",
164
+ "eencya",
165
+ "emmmerald",
166
+ "emyo",
167
+ "fadingz",
168
+ "fajyobore",
169
+ "fangxiang_cuoluan",
170
+ "flippy_(cripine111)",
171
+ "foolish_potato",
172
+ "foxeleos",
173
+ "free_style_(yohan1754)",
174
+ "funii",
175
+ "gatchan",
176
+ "gegeron",
177
+ "genera-x",
178
+ "gin00",
179
+ "glassjill",
180
+ "gou_213",
181
+ "greenapple",
182
+ "guchico",
183
+ "gum_shrew",
184
+ "guweiz",
185
+ "hakusyokuto",
186
+ "halkawa501",
187
+ "hana_mori",
188
+ "hansum",
189
+ "haoyihe",
190
+ "happoubi_jin",
191
+ "haruakira",
192
+ "hayate_(leaf98k)",
193
+ "heartki",
194
+ "heine_(haloo1101)",
195
+ "hen-tie",
196
+ "heripiro",
197
+ "hesoten",
198
+ "himeyamato",
199
+ "himura_moritaka",
200
+ "hintobento",
201
+ "hiyashi_mirano",
202
+ "hizuki_miya",
203
+ "hong_(white_spider)",
204
+ "hoshino_koucha",
205
+ "houkisei",
206
+ "houraku",
207
+ "houtei9",
208
+ "hundun_no_bifang",
209
+ "hungry_clicker",
210
+ "hxxg",
211
+ "hyeonwook9",
212
+ "hyocorou",
213
+ "iasimo",
214
+ "igayan",
215
+ "ika_(4801055)",
216
+ "iparupua",
217
+ "ipuu_(el-ane_koubou)",
218
+ "isakoro_(hx9cj)",
219
+ "isaya_(pixiv4541633)",
220
+ "iwashi_111",
221
+ "ixy",
222
+ "jesse_(pixiv34586727)",
223
+ "jiusan_naitang",
224
+ "jk",
225
+ "jocelin_carmes",
226
+ "juejue",
227
+ "jun_daniell",
228
+ "kabe_(zp66104)",
229
+ "kadohusa_ginpo",
230
+ "kaedeko_(kaedelic)",
231
+ "kaito_(k4itoh)",
232
+ "kakerayuri",
233
+ "kakuwashi",
234
+ "kamatpit",
235
+ "kame_(kamepan44231)",
236
+ "kaneko_(bblogtinhan)",
237
+ "kani_biimu",
238
+ "kantoku",
239
+ "karacak",
240
+ "karanagare",
241
+ "karory",
242
+ "kat (bu-kunn)",
243
+ "kat_(bu-kunn)",
244
+ "kikimi",
245
+ "kimi_tsuru",
246
+ "kinkymation",
247
+ "kino_(kino_konomi)",
248
+ "kinta_(distortion)",
249
+ "kiragera",
250
+ "kirschma",
251
+ "kittew",
252
+ "kitto_ha",
253
+ "kj",
254
+ "kkamiiz",
255
+ "koahri",
256
+ "kokuto",
257
+ "konya_karasue",
258
+ "kook",
259
+ "krab_(fumekrab)",
260
+ "krao",
261
+ "kuro_(rudyan0128)",
262
+ "kuse_(0201)",
263
+ "kuuus",
264
+ "kyo_mizusawa",
265
+ "kyusoukyu",
266
+ "kyuu_(plastic_night_q)",
267
+ "lepypepy",
268
+ "leviathan_(hikinito0902)",
269
+ "liaowen",
270
+ "lifeline_(a384079959)",
271
+ "liremi",
272
+ "lobelia_(saclia)",
273
+ "loloco",
274
+ "loyo",
275
+ "lukapia",
276
+ "luna_(luna610)",
277
+ "lunch_(shin_new)",
278
+ "m_k",
279
+ "maccha_(mochancc)",
280
+ "mads_ez",
281
+ "mao_(expuella)",
282
+ "marumoru",
283
+ "marushin_(denwa0214)",
284
+ "massakasama",
285
+ "mayogii",
286
+ "meekohopanes",
287
+ "melaton",
288
+ "mery_(yangmalgage)",
289
+ "miakiuehashi",
290
+ "michinoku_(hiking_miusan18)",
291
+ "mika_pikazo",
292
+ "mikozin",
293
+ "minaba_hideo",
294
+ "mintice_(asatsukimint)",
295
+ "misaka_12003-gou",
296
+ "misoni_(mi_so_ni_t)",
297
+ "miyase_mahiro",
298
+ "miyuchiq",
299
+ "mocha_kura",
300
+ "mochi_upamo",
301
+ "moddedjoker",
302
+ "moriiii",
303
+ "mosae",
304
+ "mosuke1221",
305
+ "mrlime",
306
+ "mwoji",
307
+ "nachoz_(nachozart)",
308
+ "namiorii",
309
+ "nanmo_(nanmokamo)",
310
+ "naru_0",
311
+ "naruse_(0819)",
312
+ "natuna_natu",
313
+ "nekoda_(maoda)",
314
+ "nekonosuke",
315
+ "ness_(pjw0168)",
316
+ "niac",
317
+ "nijihashi_sora",
318
+ "niliu_chahui",
319
+ "ningen_mame",
320
+ "ningri_(lianyungangwyz)",
321
+ "nitoron",
322
+ "nixeu",
323
+ "noir_eku",
324
+ "nokoya",
325
+ "nore_th",
326
+ "nutsbutty",
327
+ "nyansky",
328
+ "nyorotono_(amafurashi)",
329
+ "nyucha",
330
+ "okey",
331
+ "onacia",
332
+ "oni-noboru",
333
+ "onono_imoko",
334
+ "oreazu",
335
+ "ori_dal",
336
+ "orion_(orionproject)",
337
+ "oxenia",
338
+ "p-san_(sansin)",
339
+ "pannko6216",
340
+ "parfaitlate",
341
+ "parisa_reaz",
342
+ "patanda",
343
+ "pearlgang_e",
344
+ "pei_(sumurai)",
345
+ "pepperdevil",
346
+ "phantom_ix_row",
347
+ "pinki_o64",
348
+ "poki_(j0ch3fvj6nd)",
349
+ "pong_(pong_o0)",
350
+ "potg_(piotegu)",
351
+ "qiandaiyiyu",
352
+ "queasy_s",
353
+ "qys3",
354
+ "rararamax",
355
+ "rasusurasu",
356
+ "rat_huang",
357
+ "rauto",
358
+ "recycled",
359
+ "reeh_(yukuri130)",
360
+ "reiartdayo",
361
+ "renetan",
362
+ "rerin",
363
+ "ribao",
364
+ "riko_(rik0ring)",
365
+ "rogerwitt",
366
+ "rosumerii",
367
+ "runfufu",
368
+ "ryu160303",
369
+ "ryuuneart",
370
+ "sa-ya2",
371
+ "sakuradani",
372
+ "same_(samefgo)",
373
+ "sankuro_(agoitei)",
374
+ "sanyang003",
375
+ "satou_daiji",
376
+ "satsuya",
377
+ "saylamars",
378
+ "sayosayo-0",
379
+ "sciamano240",
380
+ "se-u-ra",
381
+ "semu_(zgom1251129)",
382
+ "sencha_(senta_10)",
383
+ "shale",
384
+ "shanguier",
385
+ "shexyo",
386
+ "shi_ling_yu",
387
+ "shibuki_kamone",
388
+ "shiitake_taishi",
389
+ "shijima_sekiun",
390
+ "shima46",
391
+ "shinori_(efvbji6264)",
392
+ "shirokitsune",
393
+ "shouhui_lang_qun",
394
+ "shule_de_yu",
395
+ "shunka_tunacan",
396
+ "shurock",
397
+ "shycocoa",
398
+ "siino",
399
+ "simao_(x_x36131422)",
400
+ "sky_cappuccino",
401
+ "slugbox",
402
+ "soaryuna",
403
+ "sofra",
404
+ "solar_(happymonk)",
405
+ "somray",
406
+ "sorani_(kaeru0768)",
407
+ "soufflebune",
408
+ "sp_(8454)",
409
+ "ssr_(azmr2828)",
410
+ "su3ka",
411
+ "suimz",
412
+ "sushispin",
413
+ "sy4",
414
+ "techi_(siro-white_0803)",
415
+ "tefco",
416
+ "theflatfacadeds",
417
+ "tmt",
418
+ "toga_(toganawa)",
419
+ "toki_(toki_ship8)",
420
+ "tol10131",
421
+ "toto_(caaaaarrot)",
422
+ "tousaki_shiina",
423
+ "toutenkou",
424
+ "tracyton",
425
+ "tsurusaki_takahiro",
426
+ "tunoko98",
427
+ "tyomimas",
428
+ "tyranosaure",
429
+ "uechin_ewokaku",
430
+ "ugwa",
431
+ "ume_(plumblossom)",
432
+ "umibouzu_(niito)",
433
+ "umiu_geso",
434
+ "uo_denim",
435
+ "ura_illust",
436
+ "urabe_(mstchan)",
437
+ "uu-tan_(hushigi10)",
438
+ "varniskarnis",
439
+ "veerinly",
440
+ "vincent_leo",
441
+ "wendao",
442
+ "white-corner",
443
+ "wlop",
444
+ "wo_meiyou_mao",
445
+ "wowoguni",
446
+ "yamada_auto",
447
+ "yamamoto_souichirou",
448
+ "yamamura_le",
449
+ "yamasede_neiko",
450
+ "yaoyao_(yoyo27456335489)",
451
+ "yd_(orange_maru)",
452
+ "ye_jji",
453
+ "yellowpaint",
454
+ "yolanda",
455
+ "yomoda_yomo",
456
+ "yoneyama_mai",
457
+ "yoshida_pino",
458
+ "yukiaka",
459
+ "yuku",
460
+ "yuna_4568",
461
+ "yunouou10",
462
+ "yunweishukuang",
463
+ "yurun_(yurun_ume)",
464
+ "z3zz4",
465
+ "zeragoes",
466
+ "zhibuji_loom",
467
+ "zinnkousai3850",
468
+ "zishudongmao",
469
+ "zombie_ke",
470
+ ]
471
+ for tag in tags:
472
+ fetch_posts_to_queue(tag)
473
+
474
+ task_queue.join()
475
+
476
+ for thread in threads:
477
+ thread.join()
478
+
479
+ console.log("All downloads completed.")
480
+ except KeyboardInterrupt:
481
+ console.log("Download interrupted.")
482
+ os._exit(1)
483
+
484
+
485
+ if __name__ == "__main__":
486
+ main()
scripts/tag.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+
3
+ import pandas as pd
4
+
5
+ from _paths import TAGS_DIR
6
+
7
+
8
+ def main() -> None:
9
+ with open(TAGS_DIR / "tag_frequency.json", encoding="utf-8") as file:
10
+ data: dict[str, int] = json.load(file)
11
+
12
+ data = dict(sorted(data.items(), key=lambda item: item[1], reverse=True))
13
+ dataframe = pd.DataFrame(data.items(), columns=["tag", "frequency"])
14
+ print(dataframe.head(1000))
15
+
16
+
17
+ if __name__ == "__main__":
18
+ main()
scripts/tag_frequency.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ from collections import Counter
3
+
4
+ import pyarrow.parquet as pq
5
+ from tqdm import tqdm
6
+
7
+ from _paths import PARQUET_PATH, TAGS_DIR
8
+
9
+
10
+ def main() -> None:
11
+ TAGS_DIR.mkdir(parents=True, exist_ok=True)
12
+ table = pq.read_table(str(PARQUET_PATH), columns=["tag_string_general"])
13
+ tag_columns = ["tag_string_general"]
14
+ counter: Counter[str] = Counter()
15
+
16
+ for column in tag_columns:
17
+ for tags in tqdm(table[column]):
18
+ if tags is None:
19
+ continue
20
+ for tag in tags:
21
+ counter[tag.as_py()] += 1
22
+
23
+ output_path = TAGS_DIR / "tag_frequency_general.json"
24
+ with open(output_path, "w", encoding="utf-8") as outfile:
25
+ json.dump(counter, outfile)
26
+
27
+
28
+ if __name__ == "__main__":
29
+ main()
scripts/tag_frequency_gt_100.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ from collections import OrderedDict
3
+
4
+ from _paths import TAGS_DIR
5
+
6
+
7
+ def main() -> None:
8
+ TAGS_DIR.mkdir(parents=True, exist_ok=True)
9
+ input_path = TAGS_DIR / "tag_frequency_general.json"
10
+ with open(input_path, encoding="utf-8") as file:
11
+ data: dict[str, int] = json.load(file)
12
+
13
+ data = {k: v for k, v in data.items() if v >= 1000}
14
+ data = OrderedDict(sorted(data.items(), key=lambda item: item[1], reverse=True))
15
+
16
+ output_path = TAGS_DIR / "tag_frequency_gt_1000.json"
17
+ with open(output_path, "w", encoding="utf-8") as outfile:
18
+ json.dump(data, outfile)
19
+
20
+ translated = {k: k.replace("_", " ") for k in data}
21
+ translated_path = TAGS_DIR / "tag_frequency_gt_1000_translate.json"
22
+ with open(translated_path, "w", encoding="utf-8") as outfile:
23
+ json.dump(translated, outfile)
24
+
25
+
26
+ if __name__ == "__main__":
27
+ main()
scripts/tag_group.py ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ from collections import defaultdict
3
+
4
+ import pyarrow.parquet as pq
5
+ from tqdm import tqdm
6
+
7
+ from _paths import PARQUET_PATH, TAGS_DIR
8
+
9
+
10
+ def main() -> None:
11
+ TAGS_DIR.mkdir(parents=True, exist_ok=True)
12
+ table = pq.read_table(
13
+ str(PARQUET_PATH),
14
+ columns=[
15
+ "tag_string_artist",
16
+ "tag_string_meta",
17
+ "tag_string_character",
18
+ "tag_string_general",
19
+ "tag_string_copyright",
20
+ ],
21
+ )
22
+ res: dict[str, set[str]] = defaultdict(set)
23
+
24
+ tag_columns = [
25
+ "tag_string_artist",
26
+ "tag_string_meta",
27
+ "tag_string_character",
28
+ "tag_string_general",
29
+ "tag_string_copyright",
30
+ ]
31
+ for column in tag_columns:
32
+ for tags in tqdm(table[column]):
33
+ if tags is None:
34
+ continue
35
+ for tag in tags:
36
+ res[column].add(tag.as_py())
37
+
38
+ output = {key: sorted(values) for key, values in res.items()}
39
+ output_path = TAGS_DIR / "tag_group.json"
40
+ with open(output_path, "w", encoding="utf-8") as outfile:
41
+ json.dump(output, outfile)
42
+
43
+
44
+ if __name__ == "__main__":
45
+ main()
scripts/tag_group_read.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+
3
+ from _paths import TAGS_DIR
4
+
5
+
6
+ def main() -> None:
7
+ TAGS_DIR.mkdir(parents=True, exist_ok=True)
8
+ with open(TAGS_DIR / "tag_group.json", encoding="utf-8") as file:
9
+ data: dict[str, list[str]] = json.load(file)
10
+
11
+ with open(TAGS_DIR / "tag_frequency_gt_100.json", encoding="utf-8") as file:
12
+ data_tag_freq_gt_100: dict[str, int] = json.load(file)
13
+
14
+ for key, tags in data.items():
15
+ data[key] = [tag for tag in tags if tag in data_tag_freq_gt_100]
16
+
17
+ with open(TAGS_DIR / "tag_group_gt_100.json", "w", encoding="utf-8") as outfile:
18
+ json.dump(data, outfile)
19
+
20
+
21
+ if __name__ == "__main__":
22
+ main()
scripts/test.bat ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ uv run python scripts/make_ds/2.merge_tag_to_meta.py --db_path sqlite:///data/db/safe_aibooru_metadata.db --meta_path data/datasets/safe_aibooru/meta.json
2
+ uv run python scripts/make_ds/3.clean_tags_and_caption.py --meta_path data/datasets/safe_aibooru/meta.json
3
+ uv run python scripts/make_ds/4.merge_wd_tagger.py --meta_path data/datasets/safe_aibooru/meta.json --ds_path data/datasets/safe_aibooru
scripts/to_webp.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from pathlib import Path
3
+
4
+ import pillow_avif
5
+ from PIL import Image
6
+
7
+ from _paths import GOOD_IMAGE_DIR, GOOD_IMAGE_WEBP_DIR
8
+
9
+ _ = pillow_avif # Ensure AVIF support is registered for Pillow.
10
+
11
+
12
+ def format_bytes_to_mb(bytes_size: int) -> str:
13
+ mb_size = bytes_size / (1024 * 1024)
14
+ return f"{mb_size:.2f} MB"
15
+
16
+
17
+ def convert_images_to_webp(input_dir: str, output_dir: str) -> None:
18
+ input_path = Path(input_dir)
19
+ output_path = Path(output_dir)
20
+ output_path.mkdir(parents=True, exist_ok=True)
21
+
22
+ for filename in os.listdir(input_path):
23
+ file_path = input_path / filename
24
+
25
+ try:
26
+ with Image.open(file_path) as img:
27
+ base_name = file_path.stem
28
+ target = output_path / f"{base_name}.webp"
29
+ img.save(target, format="webp", quality=90)
30
+
31
+ original_size = file_path.stat().st_size
32
+ webp_size = target.stat().st_size
33
+ ratio = webp_size / original_size if original_size > 0 else 0
34
+ print(
35
+ f"{file_path}, Original: {format_bytes_to_mb(original_size)}, "
36
+ f"WebP: {format_bytes_to_mb(webp_size)}, ratio: {ratio:.2f}"
37
+ )
38
+ except OSError:
39
+ print(f"File {filename} is not a valid image, skipping.")
40
+
41
+
42
+ if __name__ == "__main__":
43
+ convert_images_to_webp(str(GOOD_IMAGE_DIR), str(GOOD_IMAGE_WEBP_DIR))
update_danbooru.py → scripts/update_danbooru.py RENAMED
@@ -2,6 +2,7 @@ import argparse
2
  import queue
3
  import threading
4
  import time
 
5
  from time import sleep
6
 
7
  import requests
@@ -14,46 +15,47 @@ from rich.progress import (
14
  )
15
  from sqlalchemy import text
16
 
 
17
  from db import get_engine, t_posts
18
 
19
- url_queue = queue.Queue(maxsize=64)
20
- data_queue = queue.Queue(maxsize=64)
21
 
22
  parser = argparse.ArgumentParser()
23
  parser.add_argument("--start_id", type=int, default=0)
24
  parser.add_argument("--api_key", type=str)
25
  parser.add_argument("--login", type=str)
26
  parser.add_argument("--workers", type=int, default=16)
 
27
  args = parser.parse_args()
28
 
29
- API_KEY = args.api_key
30
- LOGIN = args.login
31
 
32
- base_api_url = (
33
  "https://danbooru.donmai.us/posts.json?page=a{}&limit=200&api_key={}&login={}"
34
  )
35
- latest_id_url = "https://danbooru.donmai.us/posts.json?api_key={}&login={}"
36
 
37
- latest_id = 1 # latset id
38
 
39
 
40
- # get latest ID
41
- def fetch_latest_id(max_retries=5, backoff_factor=1):
42
  global latest_id
43
  attempt = 0
44
 
45
  while attempt < max_retries:
46
  try:
47
- response = requests.get(latest_id_url.format(API_KEY, LOGIN))
48
  if response.status_code == 200:
49
  data = response.json()
50
- if data and "id" in data[0]:
51
- latest_id = data[0]["id"]
52
- return # 成功获取到ID后退出函数
53
  else:
54
  print(f"Failed to retrieve latest ID: {response.status_code}")
55
- except Exception as e:
56
- print(f"An error occurred while fetching the latest ID: {e}")
57
 
58
  attempt += 1
59
  sleep_time = backoff_factor * (2**attempt)
@@ -63,16 +65,17 @@ def fetch_latest_id(max_retries=5, backoff_factor=1):
63
  print(f"Failed to retrieve latest ID after {max_retries} attempts")
64
 
65
 
66
- def update_latest_id():
67
  while True:
68
  fetch_latest_id()
69
  time.sleep(60)
70
 
71
 
72
- def fetch_data(max_retries=3, retry_delay=2):
73
  while True:
74
- url = url_queue.get() # get url from url_queue
75
  if url is None:
 
76
  break
77
 
78
  retry_count = 0
@@ -81,92 +84,100 @@ def fetch_data(max_retries=3, retry_delay=2):
81
  response = requests.get(url)
82
  if response.status_code == 200:
83
  data = response.json()
84
- data_queue.put(data)
85
- break # 成功的请求,无需重试,跳出重试循环
86
- else:
87
- print(f"Failed to fetch data from {url}: {response.status_code}")
88
- retry_count += 1
89
- time.sleep(retry_delay)
90
-
91
- except Exception as e:
92
  retry_count += 1
93
  print(
94
- f"An error occurred while fetching data from {url}: {e}. Retrying in {retry_delay} seconds..."
 
95
  )
96
  time.sleep(retry_delay)
97
 
98
  url_queue.task_done()
99
 
100
 
101
- # create 16 threads to fetch data
102
- threads = []
103
- for _ in range(args.workers):
104
- thread = threading.Thread(target=fetch_data)
105
- thread.daemon = True
106
- thread.start()
107
- threads.append(thread)
108
-
109
- # 启动线程来定期更新最新 ID
110
- id_update_thread = threading.Thread(target=update_latest_id)
111
- id_update_thread.daemon = True
112
- id_update_thread.start()
113
-
114
- required_columns = [col.name for col in t_posts.columns if not col.primary_key]
115
-
116
- danbooru_engine = get_engine("danbooru_metadata.db")
117
- t_posts.metadata.create_all(danbooru_engine)
118
-
119
- # 获取数据库中最大的 ID
120
- with danbooru_engine.connect() as conn:
121
- res = conn.execute(text("SELECT MAX(id) FROM posts"))
122
- latest_id = res.fetchone()[0] or 1
123
- start_id = args.start_id if args.start_id != 0 else latest_id
124
- print("start_id:", start_id)
125
-
126
-
127
- def save_data():
128
  while True:
129
  data = data_queue.get()
 
 
 
130
  for column in required_columns:
131
- for d in data:
132
- if column not in d:
133
- d[column] = None
134
- with danbooru_engine.connect() as conn:
135
  conn.execute(t_posts.insert().prefix_with("OR REPLACE"), data)
136
  conn.commit()
137
-
138
-
139
- save_thread = threading.Thread(target=save_data)
140
- save_thread.daemon = True
141
- save_thread.start()
142
-
143
-
144
- try:
145
- with Progress(
146
- TextColumn("[progress.description]{task.description}"),
147
- BarColumn(),
148
- TextColumn("[progress.percentage]{task.percentage:>3.0f}%"),
149
- TimeElapsedColumn(),
150
- TimeRemainingColumn(),
151
- TextColumn("[{task.completed} / {task.total}]"),
152
- ) as progress:
153
- # 添加一个任务,注意 total 参数设置为 latest_id
154
- task = progress.add_task(
155
- "Processing", start=True, total=latest_id - start_id + 1
156
- )
157
- current_id = start_id
158
-
159
- while True:
160
- if current_id >= latest_id:
161
- progress.update(task, completed=latest_id) # 确保进度条满格
162
- sleep(2)
163
- continue
164
-
165
- url = base_api_url.format(current_id, API_KEY, LOGIN)
166
- url_queue.put(url) # 将生成的 URL 放入 URL 队列
167
- current_id += 200
168
- progress.update(task, completed=current_id, total=latest_id)
169
- sleep(0.1)
170
- except KeyboardInterrupt:
171
- print("Stopped by user")
172
- exit(0)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  import queue
3
  import threading
4
  import time
5
+ from pathlib import Path
6
  from time import sleep
7
 
8
  import requests
 
15
  )
16
  from sqlalchemy import text
17
 
18
+ from _paths import DANBOORU_DB_PATH
19
  from db import get_engine, t_posts
20
 
21
+ url_queue: queue.Queue[str | None] = queue.Queue(maxsize=64)
22
+ data_queue: queue.Queue[list[dict[str, object]] | None] = queue.Queue(maxsize=64)
23
 
24
  parser = argparse.ArgumentParser()
25
  parser.add_argument("--start_id", type=int, default=0)
26
  parser.add_argument("--api_key", type=str)
27
  parser.add_argument("--login", type=str)
28
  parser.add_argument("--workers", type=int, default=16)
29
+ parser.add_argument("--db_path", type=str, default=str(DANBOORU_DB_PATH))
30
  args = parser.parse_args()
31
 
32
+ API_KEY: str | None = args.api_key
33
+ LOGIN: str | None = args.login
34
 
35
+ BASE_API_URL = (
36
  "https://danbooru.donmai.us/posts.json?page=a{}&limit=200&api_key={}&login={}"
37
  )
38
+ LATEST_ID_URL = "https://danbooru.donmai.us/posts.json?api_key={}&login={}"
39
 
40
+ latest_id = 1
41
 
42
 
43
+ def fetch_latest_id(max_retries: int = 5, backoff_factor: int = 1) -> None:
 
44
  global latest_id
45
  attempt = 0
46
 
47
  while attempt < max_retries:
48
  try:
49
+ response = requests.get(LATEST_ID_URL.format(API_KEY, LOGIN))
50
  if response.status_code == 200:
51
  data = response.json()
52
+ if isinstance(data, list) and data and isinstance(data[0], dict) and "id" in data[0]:
53
+ latest_id = int(data[0]["id"])
54
+ return
55
  else:
56
  print(f"Failed to retrieve latest ID: {response.status_code}")
57
+ except requests.RequestException as exc:
58
+ print(f"An error occurred while fetching the latest ID: {exc}")
59
 
60
  attempt += 1
61
  sleep_time = backoff_factor * (2**attempt)
 
65
  print(f"Failed to retrieve latest ID after {max_retries} attempts")
66
 
67
 
68
+ def update_latest_id() -> None:
69
  while True:
70
  fetch_latest_id()
71
  time.sleep(60)
72
 
73
 
74
+ def fetch_data(max_retries: int = 3, retry_delay: int = 2) -> None:
75
  while True:
76
+ url = url_queue.get()
77
  if url is None:
78
+ url_queue.task_done()
79
  break
80
 
81
  retry_count = 0
 
84
  response = requests.get(url)
85
  if response.status_code == 200:
86
  data = response.json()
87
+ if isinstance(data, list):
88
+ data_queue.put(data)
89
+ break
90
+ print(f"Failed to fetch data from {url}: {response.status_code}")
91
+ retry_count += 1
92
+ time.sleep(retry_delay)
93
+ except requests.RequestException as exc:
 
94
  retry_count += 1
95
  print(
96
+ f"An error occurred while fetching data from {url}: {exc}. "
97
+ f"Retrying in {retry_delay} seconds..."
98
  )
99
  time.sleep(retry_delay)
100
 
101
  url_queue.task_done()
102
 
103
 
104
+ def save_data(engine_path: str, required_columns: list[str]) -> None:
105
+ engine = get_engine(engine_path)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  while True:
107
  data = data_queue.get()
108
+ if data is None:
109
+ data_queue.task_done()
110
+ break
111
  for column in required_columns:
112
+ for row in data:
113
+ if column not in row:
114
+ row[column] = None
115
+ with engine.connect() as conn:
116
  conn.execute(t_posts.insert().prefix_with("OR REPLACE"), data)
117
  conn.commit()
118
+ data_queue.task_done()
119
+
120
+
121
+ def main() -> None:
122
+ engine_path = Path(args.db_path)
123
+ if engine_path.parent != Path("."):
124
+ engine_path.parent.mkdir(parents=True, exist_ok=True)
125
+ threads: list[threading.Thread] = []
126
+ for _ in range(args.workers):
127
+ thread = threading.Thread(target=fetch_data, daemon=True)
128
+ thread.start()
129
+ threads.append(thread)
130
+
131
+ id_update_thread = threading.Thread(target=update_latest_id, daemon=True)
132
+ id_update_thread.start()
133
+
134
+ required_columns = [col.name for col in t_posts.columns if not col.primary_key]
135
+ danbooru_engine = get_engine(str(engine_path))
136
+ t_posts.metadata.create_all(danbooru_engine)
137
+
138
+ with danbooru_engine.connect() as conn:
139
+ res = conn.execute(text("SELECT MAX(id) FROM posts"))
140
+ row = res.fetchone()
141
+ latest_db_id = row[0] if row and row[0] else 1
142
+
143
+ start_id = args.start_id if args.start_id != 0 else latest_db_id
144
+ print("start_id:", start_id)
145
+
146
+ save_thread = threading.Thread(
147
+ target=save_data,
148
+ args=(str(engine_path), required_columns),
149
+ daemon=True,
150
+ )
151
+ save_thread.start()
152
+
153
+ try:
154
+ with Progress(
155
+ TextColumn("[progress.description]{task.description}"),
156
+ BarColumn(),
157
+ TextColumn("[progress.percentage]{task.percentage:>3.0f}%"),
158
+ TimeElapsedColumn(),
159
+ TimeRemainingColumn(),
160
+ TextColumn("[{task.completed} / {task.total}]"),
161
+ ) as progress:
162
+ total_items = max(latest_id - start_id + 1, 0)
163
+ task = progress.add_task("Processing", start=True, total=total_items)
164
+ current_id = start_id
165
+
166
+ while True:
167
+ if current_id >= latest_id:
168
+ progress.update(task, completed=latest_id)
169
+ sleep(2)
170
+ continue
171
+
172
+ url = BASE_API_URL.format(current_id, API_KEY, LOGIN)
173
+ url_queue.put(url)
174
+ current_id += 200
175
+ progress.update(task, completed=current_id, total=latest_id)
176
+ sleep(0.1)
177
+ except KeyboardInterrupt:
178
+ print("Stopped by user")
179
+ raise SystemExit(0)
180
+
181
+
182
+ if __name__ == "__main__":
183
+ main()
utils/__init__.py ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from pathlib import Path
3
+ from typing import Generator
4
+
5
+
6
+ def get_meta_key_from_path(path: Path | str, ds_path: Path | str) -> str:
7
+ return str(os.path.relpath(path, ds_path).replace("\\", "/")).split(".")[0]
8
+
9
+
10
+ def glob_images_pathlib(dir_path: Path | str, recursive: bool) -> list[Path]:
11
+ dir_path = Path(dir_path)
12
+ IMAGE_EXTENSIONS = [
13
+ ".png",
14
+ ".jpg",
15
+ ".jpeg",
16
+ ".webp",
17
+ ".bmp",
18
+ ".PNG",
19
+ ".JPG",
20
+ ".JPEG",
21
+ ".WEBP",
22
+ ".BMP",
23
+ ]
24
+ image_paths: list[Path] = []
25
+ if recursive:
26
+ for ext in IMAGE_EXTENSIONS:
27
+ image_paths += list(dir_path.rglob(f"*{ext}"))
28
+ else:
29
+ for ext in IMAGE_EXTENSIONS:
30
+ image_paths += list(dir_path.glob(f"*{ext}"))
31
+ image_paths = sorted(set(image_paths))
32
+ return image_paths
33
+
34
+
35
+ def gen_images_pathlib(dir_path: Path | str, recursive: bool) -> Generator[Path, None, None]:
36
+ dir_path = Path(dir_path)
37
+ IMAGE_EXTENSIONS = [
38
+ ".png",
39
+ ".jpg",
40
+ ".jpeg",
41
+ ".webp",
42
+ ".bmp",
43
+ ".PNG",
44
+ ".JPG",
45
+ ".JPEG",
46
+ ".WEBP",
47
+ ".BMP",
48
+ ]
49
+
50
+ seen_paths: set[Path] = set()
51
+
52
+ if recursive:
53
+ for ext in IMAGE_EXTENSIONS:
54
+ for path in dir_path.rglob(f"*{ext}"):
55
+ if path not in seen_paths:
56
+ seen_paths.add(path)
57
+ yield Path(path)
58
+ else:
59
+ for ext in IMAGE_EXTENSIONS:
60
+ for path in dir_path.glob(f"*{ext}"):
61
+ if path not in seen_paths:
62
+ seen_paths.add(path)
63
+ yield Path(path)
64
+
65
+
66
+ def glob_npz_pathlib(dir_path: Path | str, recursive: bool) -> list[Path]:
67
+ dir_path = Path(dir_path)
68
+ EXTENSIONS = [".npz"]
69
+ image_paths: list[Path] = []
70
+ if recursive:
71
+ for ext in EXTENSIONS:
72
+ image_paths += list(dir_path.rglob(f"*{ext}"))
73
+ else:
74
+ for ext in EXTENSIONS:
75
+ image_paths += list(dir_path.glob(f"*{ext}"))
76
+ image_paths = sorted(set(image_paths))
77
+ return image_paths
uv.lock ADDED
@@ -0,0 +1,301 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version = 1
2
+ revision = 2
3
+ requires-python = ">=3.12"
4
+
5
+ [[package]]
6
+ name = "certifi"
7
+ version = "2026.1.4"
8
+ source = { registry = "https://pypi.org/simple" }
9
+ sdist = { url = "https://files.pythonhosted.org/packages/e0/2d/a891ca51311197f6ad14a7ef42e2399f36cf2f9bd44752b3dc4eab60fdc5/certifi-2026.1.4.tar.gz", hash = "sha256:ac726dd470482006e014ad384921ed6438c457018f4b3d204aea4281258b2120", size = 154268, upload-time = "2026-01-04T02:42:41.825Z" }
10
+ wheels = [
11
+ { url = "https://files.pythonhosted.org/packages/e6/ad/3cc14f097111b4de0040c83a525973216457bbeeb63739ef1ed275c1c021/certifi-2026.1.4-py3-none-any.whl", hash = "sha256:9943707519e4add1115f44c2bc244f782c0249876bf51b6599fee1ffbedd685c", size = 152900, upload-time = "2026-01-04T02:42:40.15Z" },
12
+ ]
13
+
14
+ [[package]]
15
+ name = "charset-normalizer"
16
+ version = "3.4.4"
17
+ source = { registry = "https://pypi.org/simple" }
18
+ sdist = { url = "https://files.pythonhosted.org/packages/13/69/33ddede1939fdd074bce5434295f38fae7136463422fe4fd3e0e89b98062/charset_normalizer-3.4.4.tar.gz", hash = "sha256:94537985111c35f28720e43603b8e7b43a6ecfb2ce1d3058bbe955b73404e21a", size = 129418, upload-time = "2025-10-14T04:42:32.879Z" }
19
+ wheels = [
20
+ { url = "https://files.pythonhosted.org/packages/f3/85/1637cd4af66fa687396e757dec650f28025f2a2f5a5531a3208dc0ec43f2/charset_normalizer-3.4.4-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:0a98e6759f854bd25a58a73fa88833fba3b7c491169f86ce1180c948ab3fd394", size = 208425, upload-time = "2025-10-14T04:40:53.353Z" },
21
+ { url = "https://files.pythonhosted.org/packages/9d/6a/04130023fef2a0d9c62d0bae2649b69f7b7d8d24ea5536feef50551029df/charset_normalizer-3.4.4-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:b5b290ccc2a263e8d185130284f8501e3e36c5e02750fc6b6bdeb2e9e96f1e25", size = 148162, upload-time = "2025-10-14T04:40:54.558Z" },
22
+ { url = "https://files.pythonhosted.org/packages/78/29/62328d79aa60da22c9e0b9a66539feae06ca0f5a4171ac4f7dc285b83688/charset_normalizer-3.4.4-cp312-cp312-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:74bb723680f9f7a6234dcf67aea57e708ec1fbdf5699fb91dfd6f511b0a320ef", size = 144558, upload-time = "2025-10-14T04:40:55.677Z" },
23
+ { url = "https://files.pythonhosted.org/packages/86/bb/b32194a4bf15b88403537c2e120b817c61cd4ecffa9b6876e941c3ee38fe/charset_normalizer-3.4.4-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:f1e34719c6ed0b92f418c7c780480b26b5d9c50349e9a9af7d76bf757530350d", size = 161497, upload-time = "2025-10-14T04:40:57.217Z" },
24
+ { url = "https://files.pythonhosted.org/packages/19/89/a54c82b253d5b9b111dc74aca196ba5ccfcca8242d0fb64146d4d3183ff1/charset_normalizer-3.4.4-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:2437418e20515acec67d86e12bf70056a33abdacb5cb1655042f6538d6b085a8", size = 159240, upload-time = "2025-10-14T04:40:58.358Z" },
25
+ { url = "https://files.pythonhosted.org/packages/c0/10/d20b513afe03acc89ec33948320a5544d31f21b05368436d580dec4e234d/charset_normalizer-3.4.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:11d694519d7f29d6cd09f6ac70028dba10f92f6cdd059096db198c283794ac86", size = 153471, upload-time = "2025-10-14T04:40:59.468Z" },
26
+ { url = "https://files.pythonhosted.org/packages/61/fa/fbf177b55bdd727010f9c0a3c49eefa1d10f960e5f09d1d887bf93c2e698/charset_normalizer-3.4.4-cp312-cp312-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:ac1c4a689edcc530fc9d9aa11f5774b9e2f33f9a0c6a57864e90908f5208d30a", size = 150864, upload-time = "2025-10-14T04:41:00.623Z" },
27
+ { url = "https://files.pythonhosted.org/packages/05/12/9fbc6a4d39c0198adeebbde20b619790e9236557ca59fc40e0e3cebe6f40/charset_normalizer-3.4.4-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:21d142cc6c0ec30d2efee5068ca36c128a30b0f2c53c1c07bd78cb6bc1d3be5f", size = 150647, upload-time = "2025-10-14T04:41:01.754Z" },
28
+ { url = "https://files.pythonhosted.org/packages/ad/1f/6a9a593d52e3e8c5d2b167daf8c6b968808efb57ef4c210acb907c365bc4/charset_normalizer-3.4.4-cp312-cp312-musllinux_1_2_armv7l.whl", hash = "sha256:5dbe56a36425d26d6cfb40ce79c314a2e4dd6211d51d6d2191c00bed34f354cc", size = 145110, upload-time = "2025-10-14T04:41:03.231Z" },
29
+ { url = "https://files.pythonhosted.org/packages/30/42/9a52c609e72471b0fc54386dc63c3781a387bb4fe61c20231a4ebcd58bdd/charset_normalizer-3.4.4-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:5bfbb1b9acf3334612667b61bd3002196fe2a1eb4dd74d247e0f2a4d50ec9bbf", size = 162839, upload-time = "2025-10-14T04:41:04.715Z" },
30
+ { url = "https://files.pythonhosted.org/packages/c4/5b/c0682bbf9f11597073052628ddd38344a3d673fda35a36773f7d19344b23/charset_normalizer-3.4.4-cp312-cp312-musllinux_1_2_riscv64.whl", hash = "sha256:d055ec1e26e441f6187acf818b73564e6e6282709e9bcb5b63f5b23068356a15", size = 150667, upload-time = "2025-10-14T04:41:05.827Z" },
31
+ { url = "https://files.pythonhosted.org/packages/e4/24/a41afeab6f990cf2daf6cb8c67419b63b48cf518e4f56022230840c9bfb2/charset_normalizer-3.4.4-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:af2d8c67d8e573d6de5bc30cdb27e9b95e49115cd9baad5ddbd1a6207aaa82a9", size = 160535, upload-time = "2025-10-14T04:41:06.938Z" },
32
+ { url = "https://files.pythonhosted.org/packages/2a/e5/6a4ce77ed243c4a50a1fecca6aaaab419628c818a49434be428fe24c9957/charset_normalizer-3.4.4-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:780236ac706e66881f3b7f2f32dfe90507a09e67d1d454c762cf642e6e1586e0", size = 154816, upload-time = "2025-10-14T04:41:08.101Z" },
33
+ { url = "https://files.pythonhosted.org/packages/a8/ef/89297262b8092b312d29cdb2517cb1237e51db8ecef2e9af5edbe7b683b1/charset_normalizer-3.4.4-cp312-cp312-win32.whl", hash = "sha256:5833d2c39d8896e4e19b689ffc198f08ea58116bee26dea51e362ecc7cd3ed26", size = 99694, upload-time = "2025-10-14T04:41:09.23Z" },
34
+ { url = "https://files.pythonhosted.org/packages/3d/2d/1e5ed9dd3b3803994c155cd9aacb60c82c331bad84daf75bcb9c91b3295e/charset_normalizer-3.4.4-cp312-cp312-win_amd64.whl", hash = "sha256:a79cfe37875f822425b89a82333404539ae63dbdddf97f84dcbc3d339aae9525", size = 107131, upload-time = "2025-10-14T04:41:10.467Z" },
35
+ { url = "https://files.pythonhosted.org/packages/d0/d9/0ed4c7098a861482a7b6a95603edce4c0d9db2311af23da1fb2b75ec26fc/charset_normalizer-3.4.4-cp312-cp312-win_arm64.whl", hash = "sha256:376bec83a63b8021bb5c8ea75e21c4ccb86e7e45ca4eb81146091b56599b80c3", size = 100390, upload-time = "2025-10-14T04:41:11.915Z" },
36
+ { url = "https://files.pythonhosted.org/packages/97/45/4b3a1239bbacd321068ea6e7ac28875b03ab8bc0aa0966452db17cd36714/charset_normalizer-3.4.4-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:e1f185f86a6f3403aa2420e815904c67b2f9ebc443f045edd0de921108345794", size = 208091, upload-time = "2025-10-14T04:41:13.346Z" },
37
+ { url = "https://files.pythonhosted.org/packages/7d/62/73a6d7450829655a35bb88a88fca7d736f9882a27eacdca2c6d505b57e2e/charset_normalizer-3.4.4-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:6b39f987ae8ccdf0d2642338faf2abb1862340facc796048b604ef14919e55ed", size = 147936, upload-time = "2025-10-14T04:41:14.461Z" },
38
+ { url = "https://files.pythonhosted.org/packages/89/c5/adb8c8b3d6625bef6d88b251bbb0d95f8205831b987631ab0c8bb5d937c2/charset_normalizer-3.4.4-cp313-cp313-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:3162d5d8ce1bb98dd51af660f2121c55d0fa541b46dff7bb9b9f86ea1d87de72", size = 144180, upload-time = "2025-10-14T04:41:15.588Z" },
39
+ { url = "https://files.pythonhosted.org/packages/91/ed/9706e4070682d1cc219050b6048bfd293ccf67b3d4f5a4f39207453d4b99/charset_normalizer-3.4.4-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:81d5eb2a312700f4ecaa977a8235b634ce853200e828fbadf3a9c50bab278328", size = 161346, upload-time = "2025-10-14T04:41:16.738Z" },
40
+ { url = "https://files.pythonhosted.org/packages/d5/0d/031f0d95e4972901a2f6f09ef055751805ff541511dc1252ba3ca1f80cf5/charset_normalizer-3.4.4-cp313-cp313-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:5bd2293095d766545ec1a8f612559f6b40abc0eb18bb2f5d1171872d34036ede", size = 158874, upload-time = "2025-10-14T04:41:17.923Z" },
41
+ { url = "https://files.pythonhosted.org/packages/f5/83/6ab5883f57c9c801ce5e5677242328aa45592be8a00644310a008d04f922/charset_normalizer-3.4.4-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:a8a8b89589086a25749f471e6a900d3f662d1d3b6e2e59dcecf787b1cc3a1894", size = 153076, upload-time = "2025-10-14T04:41:19.106Z" },
42
+ { url = "https://files.pythonhosted.org/packages/75/1e/5ff781ddf5260e387d6419959ee89ef13878229732732ee73cdae01800f2/charset_normalizer-3.4.4-cp313-cp313-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:bc7637e2f80d8530ee4a78e878bce464f70087ce73cf7c1caf142416923b98f1", size = 150601, upload-time = "2025-10-14T04:41:20.245Z" },
43
+ { url = "https://files.pythonhosted.org/packages/d7/57/71be810965493d3510a6ca79b90c19e48696fb1ff964da319334b12677f0/charset_normalizer-3.4.4-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:f8bf04158c6b607d747e93949aa60618b61312fe647a6369f88ce2ff16043490", size = 150376, upload-time = "2025-10-14T04:41:21.398Z" },
44
+ { url = "https://files.pythonhosted.org/packages/e5/d5/c3d057a78c181d007014feb7e9f2e65905a6c4ef182c0ddf0de2924edd65/charset_normalizer-3.4.4-cp313-cp313-musllinux_1_2_armv7l.whl", hash = "sha256:554af85e960429cf30784dd47447d5125aaa3b99a6f0683589dbd27e2f45da44", size = 144825, upload-time = "2025-10-14T04:41:22.583Z" },
45
+ { url = "https://files.pythonhosted.org/packages/e6/8c/d0406294828d4976f275ffbe66f00266c4b3136b7506941d87c00cab5272/charset_normalizer-3.4.4-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:74018750915ee7ad843a774364e13a3db91682f26142baddf775342c3f5b1133", size = 162583, upload-time = "2025-10-14T04:41:23.754Z" },
46
+ { url = "https://files.pythonhosted.org/packages/d7/24/e2aa1f18c8f15c4c0e932d9287b8609dd30ad56dbe41d926bd846e22fb8d/charset_normalizer-3.4.4-cp313-cp313-musllinux_1_2_riscv64.whl", hash = "sha256:c0463276121fdee9c49b98908b3a89c39be45d86d1dbaa22957e38f6321d4ce3", size = 150366, upload-time = "2025-10-14T04:41:25.27Z" },
47
+ { url = "https://files.pythonhosted.org/packages/e4/5b/1e6160c7739aad1e2df054300cc618b06bf784a7a164b0f238360721ab86/charset_normalizer-3.4.4-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:362d61fd13843997c1c446760ef36f240cf81d3ebf74ac62652aebaf7838561e", size = 160300, upload-time = "2025-10-14T04:41:26.725Z" },
48
+ { url = "https://files.pythonhosted.org/packages/7a/10/f882167cd207fbdd743e55534d5d9620e095089d176d55cb22d5322f2afd/charset_normalizer-3.4.4-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:9a26f18905b8dd5d685d6d07b0cdf98a79f3c7a918906af7cc143ea2e164c8bc", size = 154465, upload-time = "2025-10-14T04:41:28.322Z" },
49
+ { url = "https://files.pythonhosted.org/packages/89/66/c7a9e1b7429be72123441bfdbaf2bc13faab3f90b933f664db506dea5915/charset_normalizer-3.4.4-cp313-cp313-win32.whl", hash = "sha256:9b35f4c90079ff2e2edc5b26c0c77925e5d2d255c42c74fdb70fb49b172726ac", size = 99404, upload-time = "2025-10-14T04:41:29.95Z" },
50
+ { url = "https://files.pythonhosted.org/packages/c4/26/b9924fa27db384bdcd97ab83b4f0a8058d96ad9626ead570674d5e737d90/charset_normalizer-3.4.4-cp313-cp313-win_amd64.whl", hash = "sha256:b435cba5f4f750aa6c0a0d92c541fb79f69a387c91e61f1795227e4ed9cece14", size = 107092, upload-time = "2025-10-14T04:41:31.188Z" },
51
+ { url = "https://files.pythonhosted.org/packages/af/8f/3ed4bfa0c0c72a7ca17f0380cd9e4dd842b09f664e780c13cff1dcf2ef1b/charset_normalizer-3.4.4-cp313-cp313-win_arm64.whl", hash = "sha256:542d2cee80be6f80247095cc36c418f7bddd14f4a6de45af91dfad36d817bba2", size = 100408, upload-time = "2025-10-14T04:41:32.624Z" },
52
+ { url = "https://files.pythonhosted.org/packages/2a/35/7051599bd493e62411d6ede36fd5af83a38f37c4767b92884df7301db25d/charset_normalizer-3.4.4-cp314-cp314-macosx_10_13_universal2.whl", hash = "sha256:da3326d9e65ef63a817ecbcc0df6e94463713b754fe293eaa03da99befb9a5bd", size = 207746, upload-time = "2025-10-14T04:41:33.773Z" },
53
+ { url = "https://files.pythonhosted.org/packages/10/9a/97c8d48ef10d6cd4fcead2415523221624bf58bcf68a802721a6bc807c8f/charset_normalizer-3.4.4-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:8af65f14dc14a79b924524b1e7fffe304517b2bff5a58bf64f30b98bbc5079eb", size = 147889, upload-time = "2025-10-14T04:41:34.897Z" },
54
+ { url = "https://files.pythonhosted.org/packages/10/bf/979224a919a1b606c82bd2c5fa49b5c6d5727aa47b4312bb27b1734f53cd/charset_normalizer-3.4.4-cp314-cp314-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:74664978bb272435107de04e36db5a9735e78232b85b77d45cfb38f758efd33e", size = 143641, upload-time = "2025-10-14T04:41:36.116Z" },
55
+ { url = "https://files.pythonhosted.org/packages/ba/33/0ad65587441fc730dc7bd90e9716b30b4702dc7b617e6ba4997dc8651495/charset_normalizer-3.4.4-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:752944c7ffbfdd10c074dc58ec2d5a8a4cd9493b314d367c14d24c17684ddd14", size = 160779, upload-time = "2025-10-14T04:41:37.229Z" },
56
+ { url = "https://files.pythonhosted.org/packages/67/ed/331d6b249259ee71ddea93f6f2f0a56cfebd46938bde6fcc6f7b9a3d0e09/charset_normalizer-3.4.4-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:d1f13550535ad8cff21b8d757a3257963e951d96e20ec82ab44bc64aeb62a191", size = 159035, upload-time = "2025-10-14T04:41:38.368Z" },
57
+ { url = "https://files.pythonhosted.org/packages/67/ff/f6b948ca32e4f2a4576aa129d8bed61f2e0543bf9f5f2b7fc3758ed005c9/charset_normalizer-3.4.4-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:ecaae4149d99b1c9e7b88bb03e3221956f68fd6d50be2ef061b2381b61d20838", size = 152542, upload-time = "2025-10-14T04:41:39.862Z" },
58
+ { url = "https://files.pythonhosted.org/packages/16/85/276033dcbcc369eb176594de22728541a925b2632f9716428c851b149e83/charset_normalizer-3.4.4-cp314-cp314-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:cb6254dc36b47a990e59e1068afacdcd02958bdcce30bb50cc1700a8b9d624a6", size = 149524, upload-time = "2025-10-14T04:41:41.319Z" },
59
+ { url = "https://files.pythonhosted.org/packages/9e/f2/6a2a1f722b6aba37050e626530a46a68f74e63683947a8acff92569f979a/charset_normalizer-3.4.4-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:c8ae8a0f02f57a6e61203a31428fa1d677cbe50c93622b4149d5c0f319c1d19e", size = 150395, upload-time = "2025-10-14T04:41:42.539Z" },
60
+ { url = "https://files.pythonhosted.org/packages/60/bb/2186cb2f2bbaea6338cad15ce23a67f9b0672929744381e28b0592676824/charset_normalizer-3.4.4-cp314-cp314-musllinux_1_2_armv7l.whl", hash = "sha256:47cc91b2f4dd2833fddaedd2893006b0106129d4b94fdb6af1f4ce5a9965577c", size = 143680, upload-time = "2025-10-14T04:41:43.661Z" },
61
+ { url = "https://files.pythonhosted.org/packages/7d/a5/bf6f13b772fbb2a90360eb620d52ed8f796f3c5caee8398c3b2eb7b1c60d/charset_normalizer-3.4.4-cp314-cp314-musllinux_1_2_ppc64le.whl", hash = "sha256:82004af6c302b5d3ab2cfc4cc5f29db16123b1a8417f2e25f9066f91d4411090", size = 162045, upload-time = "2025-10-14T04:41:44.821Z" },
62
+ { url = "https://files.pythonhosted.org/packages/df/c5/d1be898bf0dc3ef9030c3825e5d3b83f2c528d207d246cbabe245966808d/charset_normalizer-3.4.4-cp314-cp314-musllinux_1_2_riscv64.whl", hash = "sha256:2b7d8f6c26245217bd2ad053761201e9f9680f8ce52f0fcd8d0755aeae5b2152", size = 149687, upload-time = "2025-10-14T04:41:46.442Z" },
63
+ { url = "https://files.pythonhosted.org/packages/a5/42/90c1f7b9341eef50c8a1cb3f098ac43b0508413f33affd762855f67a410e/charset_normalizer-3.4.4-cp314-cp314-musllinux_1_2_s390x.whl", hash = "sha256:799a7a5e4fb2d5898c60b640fd4981d6a25f1c11790935a44ce38c54e985f828", size = 160014, upload-time = "2025-10-14T04:41:47.631Z" },
64
+ { url = "https://files.pythonhosted.org/packages/76/be/4d3ee471e8145d12795ab655ece37baed0929462a86e72372fd25859047c/charset_normalizer-3.4.4-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:99ae2cffebb06e6c22bdc25801d7b30f503cc87dbd283479e7b606f70aff57ec", size = 154044, upload-time = "2025-10-14T04:41:48.81Z" },
65
+ { url = "https://files.pythonhosted.org/packages/b0/6f/8f7af07237c34a1defe7defc565a9bc1807762f672c0fde711a4b22bf9c0/charset_normalizer-3.4.4-cp314-cp314-win32.whl", hash = "sha256:f9d332f8c2a2fcbffe1378594431458ddbef721c1769d78e2cbc06280d8155f9", size = 99940, upload-time = "2025-10-14T04:41:49.946Z" },
66
+ { url = "https://files.pythonhosted.org/packages/4b/51/8ade005e5ca5b0d80fb4aff72a3775b325bdc3d27408c8113811a7cbe640/charset_normalizer-3.4.4-cp314-cp314-win_amd64.whl", hash = "sha256:8a6562c3700cce886c5be75ade4a5db4214fda19fede41d9792d100288d8f94c", size = 107104, upload-time = "2025-10-14T04:41:51.051Z" },
67
+ { url = "https://files.pythonhosted.org/packages/da/5f/6b8f83a55bb8278772c5ae54a577f3099025f9ade59d0136ac24a0df4bde/charset_normalizer-3.4.4-cp314-cp314-win_arm64.whl", hash = "sha256:de00632ca48df9daf77a2c65a484531649261ec9f25489917f09e455cb09ddb2", size = 100743, upload-time = "2025-10-14T04:41:52.122Z" },
68
+ { url = "https://files.pythonhosted.org/packages/0a/4c/925909008ed5a988ccbb72dcc897407e5d6d3bd72410d69e051fc0c14647/charset_normalizer-3.4.4-py3-none-any.whl", hash = "sha256:7a32c560861a02ff789ad905a2fe94e3f840803362c84fecf1851cb4cf3dc37f", size = 53402, upload-time = "2025-10-14T04:42:31.76Z" },
69
+ ]
70
+
71
+ [[package]]
72
+ name = "danbooru-metadata"
73
+ version = "0.0.0"
74
+ source = { virtual = "." }
75
+ dependencies = [
76
+ { name = "pyarrow" },
77
+ { name = "requests" },
78
+ { name = "rich" },
79
+ { name = "sqlalchemy" },
80
+ ]
81
+
82
+ [package.metadata]
83
+ requires-dist = [
84
+ { name = "pyarrow", specifier = ">=18.1.0" },
85
+ { name = "requests", specifier = ">=2.32.5" },
86
+ { name = "rich", specifier = ">=14.3.1" },
87
+ { name = "sqlalchemy", specifier = ">=2.0.46" },
88
+ ]
89
+
90
+ [[package]]
91
+ name = "greenlet"
92
+ version = "3.3.1"
93
+ source = { registry = "https://pypi.org/simple" }
94
+ sdist = { url = "https://files.pythonhosted.org/packages/8a/99/1cd3411c56a410994669062bd73dd58270c00cc074cac15f385a1fd91f8a/greenlet-3.3.1.tar.gz", hash = "sha256:41848f3230b58c08bb43dee542e74a2a2e34d3c59dc3076cec9151aeeedcae98", size = 184690, upload-time = "2026-01-23T15:31:02.076Z" }
95
+ wheels = [
96
+ { url = "https://files.pythonhosted.org/packages/f9/c8/9d76a66421d1ae24340dfae7e79c313957f6e3195c144d2c73333b5bfe34/greenlet-3.3.1-cp312-cp312-macosx_11_0_universal2.whl", hash = "sha256:7e806ca53acf6d15a888405880766ec84721aa4181261cd11a457dfe9a7a4975", size = 276443, upload-time = "2026-01-23T15:30:10.066Z" },
97
+ { url = "https://files.pythonhosted.org/packages/81/99/401ff34bb3c032d1f10477d199724f5e5f6fbfb59816ad1455c79c1eb8e7/greenlet-3.3.1-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:d842c94b9155f1c9b3058036c24ffb8ff78b428414a19792b2380be9cecf4f36", size = 597359, upload-time = "2026-01-23T16:00:57.394Z" },
98
+ { url = "https://files.pythonhosted.org/packages/2b/bc/4dcc0871ed557792d304f50be0f7487a14e017952ec689effe2180a6ff35/greenlet-3.3.1-cp312-cp312-manylinux_2_24_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:20fedaadd422fa02695f82093f9a98bad3dab5fcda793c658b945fcde2ab27ba", size = 607805, upload-time = "2026-01-23T16:05:28.068Z" },
99
+ { url = "https://files.pythonhosted.org/packages/3b/cd/7a7ca57588dac3389e97f7c9521cb6641fd8b6602faf1eaa4188384757df/greenlet-3.3.1-cp312-cp312-manylinux_2_24_s390x.manylinux_2_28_s390x.whl", hash = "sha256:c620051669fd04ac6b60ebc70478210119c56e2d5d5df848baec4312e260e4ca", size = 622363, upload-time = "2026-01-23T16:15:54.754Z" },
100
+ { url = "https://files.pythonhosted.org/packages/cf/05/821587cf19e2ce1f2b24945d890b164401e5085f9d09cbd969b0c193cd20/greenlet-3.3.1-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:14194f5f4305800ff329cbf02c5fcc88f01886cadd29941b807668a45f0d2336", size = 609947, upload-time = "2026-01-23T15:32:51.004Z" },
101
+ { url = "https://files.pythonhosted.org/packages/a4/52/ee8c46ed9f8babaa93a19e577f26e3d28a519feac6350ed6f25f1afee7e9/greenlet-3.3.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:7b2fe4150a0cf59f847a67db8c155ac36aed89080a6a639e9f16df5d6c6096f1", size = 1567487, upload-time = "2026-01-23T16:04:22.125Z" },
102
+ { url = "https://files.pythonhosted.org/packages/8f/7c/456a74f07029597626f3a6db71b273a3632aecb9afafeeca452cfa633197/greenlet-3.3.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:49f4ad195d45f4a66a0eb9c1ba4832bb380570d361912fa3554746830d332149", size = 1636087, upload-time = "2026-01-23T15:33:47.486Z" },
103
+ { url = "https://files.pythonhosted.org/packages/34/2f/5e0e41f33c69655300a5e54aeb637cf8ff57f1786a3aba374eacc0228c1d/greenlet-3.3.1-cp312-cp312-win_amd64.whl", hash = "sha256:cc98b9c4e4870fa983436afa999d4eb16b12872fab7071423d5262fa7120d57a", size = 227156, upload-time = "2026-01-23T15:34:34.808Z" },
104
+ { url = "https://files.pythonhosted.org/packages/c8/ab/717c58343cf02c5265b531384b248787e04d8160b8afe53d9eec053d7b44/greenlet-3.3.1-cp312-cp312-win_arm64.whl", hash = "sha256:bfb2d1763d777de5ee495c85309460f6fd8146e50ec9d0ae0183dbf6f0a829d1", size = 226403, upload-time = "2026-01-23T15:31:39.372Z" },
105
+ { url = "https://files.pythonhosted.org/packages/ec/ab/d26750f2b7242c2b90ea2ad71de70cfcd73a948a49513188a0fc0d6fc15a/greenlet-3.3.1-cp313-cp313-macosx_11_0_universal2.whl", hash = "sha256:7ab327905cabb0622adca5971e488064e35115430cec2c35a50fd36e72a315b3", size = 275205, upload-time = "2026-01-23T15:30:24.556Z" },
106
+ { url = "https://files.pythonhosted.org/packages/10/d3/be7d19e8fad7c5a78eeefb2d896a08cd4643e1e90c605c4be3b46264998f/greenlet-3.3.1-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:65be2f026ca6a176f88fb935ee23c18333ccea97048076aef4db1ef5bc0713ac", size = 599284, upload-time = "2026-01-23T16:00:58.584Z" },
107
+ { url = "https://files.pythonhosted.org/packages/ae/21/fe703aaa056fdb0f17e5afd4b5c80195bbdab701208918938bd15b00d39b/greenlet-3.3.1-cp313-cp313-manylinux_2_24_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:7a3ae05b3d225b4155bda56b072ceb09d05e974bc74be6c3fc15463cf69f33fd", size = 610274, upload-time = "2026-01-23T16:05:29.312Z" },
108
+ { url = "https://files.pythonhosted.org/packages/06/00/95df0b6a935103c0452dad2203f5be8377e551b8466a29650c4c5a5af6cc/greenlet-3.3.1-cp313-cp313-manylinux_2_24_s390x.manylinux_2_28_s390x.whl", hash = "sha256:12184c61e5d64268a160226fb4818af4df02cfead8379d7f8b99a56c3a54ff3e", size = 624375, upload-time = "2026-01-23T16:15:55.915Z" },
109
+ { url = "https://files.pythonhosted.org/packages/cb/86/5c6ab23bb3c28c21ed6bebad006515cfe08b04613eb105ca0041fecca852/greenlet-3.3.1-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:6423481193bbbe871313de5fd06a082f2649e7ce6e08015d2a76c1e9186ca5b3", size = 612904, upload-time = "2026-01-23T15:32:52.317Z" },
110
+ { url = "https://files.pythonhosted.org/packages/c2/f3/7949994264e22639e40718c2daf6f6df5169bf48fb038c008a489ec53a50/greenlet-3.3.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:33a956fe78bbbda82bfc95e128d61129b32d66bcf0a20a1f0c08aa4839ffa951", size = 1567316, upload-time = "2026-01-23T16:04:23.316Z" },
111
+ { url = "https://files.pythonhosted.org/packages/8d/6e/d73c94d13b6465e9f7cd6231c68abde838bb22408596c05d9059830b7872/greenlet-3.3.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:4b065d3284be43728dd280f6f9a13990b56470b81be20375a207cdc814a983f2", size = 1636549, upload-time = "2026-01-23T15:33:48.643Z" },
112
+ { url = "https://files.pythonhosted.org/packages/5e/b3/c9c23a6478b3bcc91f979ce4ca50879e4d0b2bd7b9a53d8ecded719b92e2/greenlet-3.3.1-cp313-cp313-win_amd64.whl", hash = "sha256:27289986f4e5b0edec7b5a91063c109f0276abb09a7e9bdab08437525977c946", size = 227042, upload-time = "2026-01-23T15:33:58.216Z" },
113
+ { url = "https://files.pythonhosted.org/packages/90/e7/824beda656097edee36ab15809fd063447b200cc03a7f6a24c34d520bc88/greenlet-3.3.1-cp313-cp313-win_arm64.whl", hash = "sha256:2f080e028001c5273e0b42690eaf359aeef9cb1389da0f171ea51a5dc3c7608d", size = 226294, upload-time = "2026-01-23T15:30:52.73Z" },
114
+ { url = "https://files.pythonhosted.org/packages/ae/fb/011c7c717213182caf78084a9bea51c8590b0afda98001f69d9f853a495b/greenlet-3.3.1-cp314-cp314-macosx_11_0_universal2.whl", hash = "sha256:bd59acd8529b372775cd0fcbc5f420ae20681c5b045ce25bd453ed8455ab99b5", size = 275737, upload-time = "2026-01-23T15:32:16.889Z" },
115
+ { url = "https://files.pythonhosted.org/packages/41/2e/a3a417d620363fdbb08a48b1dd582956a46a61bf8fd27ee8164f9dfe87c2/greenlet-3.3.1-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:b31c05dd84ef6871dd47120386aed35323c944d86c3d91a17c4b8d23df62f15b", size = 646422, upload-time = "2026-01-23T16:01:00.354Z" },
116
+ { url = "https://files.pythonhosted.org/packages/b4/09/c6c4a0db47defafd2d6bab8ddfe47ad19963b4e30f5bed84d75328059f8c/greenlet-3.3.1-cp314-cp314-manylinux_2_24_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:02925a0bfffc41e542c70aa14c7eda3593e4d7e274bfcccca1827e6c0875902e", size = 658219, upload-time = "2026-01-23T16:05:30.956Z" },
117
+ { url = "https://files.pythonhosted.org/packages/e2/89/b95f2ddcc5f3c2bc09c8ee8d77be312df7f9e7175703ab780f2014a0e781/greenlet-3.3.1-cp314-cp314-manylinux_2_24_s390x.manylinux_2_28_s390x.whl", hash = "sha256:3e0f3878ca3a3ff63ab4ea478585942b53df66ddde327b59ecb191b19dbbd62d", size = 671455, upload-time = "2026-01-23T16:15:57.232Z" },
118
+ { url = "https://files.pythonhosted.org/packages/80/38/9d42d60dffb04b45f03dbab9430898352dba277758640751dc5cc316c521/greenlet-3.3.1-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:34a729e2e4e4ffe9ae2408d5ecaf12f944853f40ad724929b7585bca808a9d6f", size = 660237, upload-time = "2026-01-23T15:32:53.967Z" },
119
+ { url = "https://files.pythonhosted.org/packages/96/61/373c30b7197f9e756e4c81ae90a8d55dc3598c17673f91f4d31c3c689c3f/greenlet-3.3.1-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:aec9ab04e82918e623415947921dea15851b152b822661cce3f8e4393c3df683", size = 1615261, upload-time = "2026-01-23T16:04:25.066Z" },
120
+ { url = "https://files.pythonhosted.org/packages/fd/d3/ca534310343f5945316f9451e953dcd89b36fe7a19de652a1dc5a0eeef3f/greenlet-3.3.1-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:71c767cf281a80d02b6c1bdc41c9468e1f5a494fb11bc8688c360524e273d7b1", size = 1683719, upload-time = "2026-01-23T15:33:50.61Z" },
121
+ { url = "https://files.pythonhosted.org/packages/52/cb/c21a3fd5d2c9c8b622e7bede6d6d00e00551a5ee474ea6d831b5f567a8b4/greenlet-3.3.1-cp314-cp314-win_amd64.whl", hash = "sha256:96aff77af063b607f2489473484e39a0bbae730f2ea90c9e5606c9b73c44174a", size = 228125, upload-time = "2026-01-23T15:32:45.265Z" },
122
+ { url = "https://files.pythonhosted.org/packages/6a/8e/8a2db6d11491837af1de64b8aff23707c6e85241be13c60ed399a72e2ef8/greenlet-3.3.1-cp314-cp314-win_arm64.whl", hash = "sha256:b066e8b50e28b503f604fa538adc764a638b38cf8e81e025011d26e8a627fa79", size = 227519, upload-time = "2026-01-23T15:31:47.284Z" },
123
+ { url = "https://files.pythonhosted.org/packages/28/24/cbbec49bacdcc9ec652a81d3efef7b59f326697e7edf6ed775a5e08e54c2/greenlet-3.3.1-cp314-cp314t-macosx_11_0_universal2.whl", hash = "sha256:3e63252943c921b90abb035ebe9de832c436401d9c45f262d80e2d06cc659242", size = 282706, upload-time = "2026-01-23T15:33:05.525Z" },
124
+ { url = "https://files.pythonhosted.org/packages/86/2e/4f2b9323c144c4fe8842a4e0d92121465485c3c2c5b9e9b30a52e80f523f/greenlet-3.3.1-cp314-cp314t-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:76e39058e68eb125de10c92524573924e827927df5d3891fbc97bd55764a8774", size = 651209, upload-time = "2026-01-23T16:01:01.517Z" },
125
+ { url = "https://files.pythonhosted.org/packages/d9/87/50ca60e515f5bb55a2fbc5f0c9b5b156de7d2fc51a0a69abc9d23914a237/greenlet-3.3.1-cp314-cp314t-manylinux_2_24_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:c9f9d5e7a9310b7a2f416dd13d2e3fd8b42d803968ea580b7c0f322ccb389b97", size = 654300, upload-time = "2026-01-23T16:05:32.199Z" },
126
+ { url = "https://files.pythonhosted.org/packages/7c/25/c51a63f3f463171e09cb586eb64db0861eb06667ab01a7968371a24c4f3b/greenlet-3.3.1-cp314-cp314t-manylinux_2_24_s390x.manylinux_2_28_s390x.whl", hash = "sha256:4b9721549a95db96689458a1e0ae32412ca18776ed004463df3a9299c1b257ab", size = 662574, upload-time = "2026-01-23T16:15:58.364Z" },
127
+ { url = "https://files.pythonhosted.org/packages/1d/94/74310866dfa2b73dd08659a3d18762f83985ad3281901ba0ee9a815194fb/greenlet-3.3.1-cp314-cp314t-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:92497c78adf3ac703b57f1e3813c2d874f27f71a178f9ea5887855da413cd6d2", size = 653842, upload-time = "2026-01-23T15:32:55.671Z" },
128
+ { url = "https://files.pythonhosted.org/packages/97/43/8bf0ffa3d498eeee4c58c212a3905dd6146c01c8dc0b0a046481ca29b18c/greenlet-3.3.1-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:ed6b402bc74d6557a705e197d47f9063733091ed6357b3de33619d8a8d93ac53", size = 1614917, upload-time = "2026-01-23T16:04:26.276Z" },
129
+ { url = "https://files.pythonhosted.org/packages/89/90/a3be7a5f378fc6e84abe4dcfb2ba32b07786861172e502388b4c90000d1b/greenlet-3.3.1-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:59913f1e5ada20fde795ba906916aea25d442abcc0593fba7e26c92b7ad76249", size = 1676092, upload-time = "2026-01-23T15:33:52.176Z" },
130
+ { url = "https://files.pythonhosted.org/packages/e1/2b/98c7f93e6db9977aaee07eb1e51ca63bd5f779b900d362791d3252e60558/greenlet-3.3.1-cp314-cp314t-win_amd64.whl", hash = "sha256:301860987846c24cb8964bdec0e31a96ad4a2a801b41b4ef40963c1b44f33451", size = 233181, upload-time = "2026-01-23T15:33:00.29Z" },
131
+ ]
132
+
133
+ [[package]]
134
+ name = "idna"
135
+ version = "3.11"
136
+ source = { registry = "https://pypi.org/simple" }
137
+ sdist = { url = "https://files.pythonhosted.org/packages/6f/6d/0703ccc57f3a7233505399edb88de3cbd678da106337b9fcde432b65ed60/idna-3.11.tar.gz", hash = "sha256:795dafcc9c04ed0c1fb032c2aa73654d8e8c5023a7df64a53f39190ada629902", size = 194582, upload-time = "2025-10-12T14:55:20.501Z" }
138
+ wheels = [
139
+ { url = "https://files.pythonhosted.org/packages/0e/61/66938bbb5fc52dbdf84594873d5b51fb1f7c7794e9c0f5bd885f30bc507b/idna-3.11-py3-none-any.whl", hash = "sha256:771a87f49d9defaf64091e6e6fe9c18d4833f140bd19464795bc32d966ca37ea", size = 71008, upload-time = "2025-10-12T14:55:18.883Z" },
140
+ ]
141
+
142
+ [[package]]
143
+ name = "markdown-it-py"
144
+ version = "4.0.0"
145
+ source = { registry = "https://pypi.org/simple" }
146
+ dependencies = [
147
+ { name = "mdurl" },
148
+ ]
149
+ sdist = { url = "https://files.pythonhosted.org/packages/5b/f5/4ec618ed16cc4f8fb3b701563655a69816155e79e24a17b651541804721d/markdown_it_py-4.0.0.tar.gz", hash = "sha256:cb0a2b4aa34f932c007117b194e945bd74e0ec24133ceb5bac59009cda1cb9f3", size = 73070, upload-time = "2025-08-11T12:57:52.854Z" }
150
+ wheels = [
151
+ { url = "https://files.pythonhosted.org/packages/94/54/e7d793b573f298e1c9013b8c4dade17d481164aa517d1d7148619c2cedbf/markdown_it_py-4.0.0-py3-none-any.whl", hash = "sha256:87327c59b172c5011896038353a81343b6754500a08cd7a4973bb48c6d578147", size = 87321, upload-time = "2025-08-11T12:57:51.923Z" },
152
+ ]
153
+
154
+ [[package]]
155
+ name = "mdurl"
156
+ version = "0.1.2"
157
+ source = { registry = "https://pypi.org/simple" }
158
+ sdist = { url = "https://files.pythonhosted.org/packages/d6/54/cfe61301667036ec958cb99bd3efefba235e65cdeb9c84d24a8293ba1d90/mdurl-0.1.2.tar.gz", hash = "sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba", size = 8729, upload-time = "2022-08-14T12:40:10.846Z" }
159
+ wheels = [
160
+ { url = "https://files.pythonhosted.org/packages/b3/38/89ba8ad64ae25be8de66a6d463314cf1eb366222074cfda9ee839c56a4b4/mdurl-0.1.2-py3-none-any.whl", hash = "sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8", size = 9979, upload-time = "2022-08-14T12:40:09.779Z" },
161
+ ]
162
+
163
+ [[package]]
164
+ name = "pyarrow"
165
+ version = "23.0.0"
166
+ source = { registry = "https://pypi.org/simple" }
167
+ sdist = { url = "https://files.pythonhosted.org/packages/01/33/ffd9c3eb087fa41dd79c3cf20c4c0ae3cdb877c4f8e1107a446006344924/pyarrow-23.0.0.tar.gz", hash = "sha256:180e3150e7edfcd182d3d9afba72f7cf19839a497cc76555a8dce998a8f67615", size = 1167185, upload-time = "2026-01-18T16:19:42.218Z" }
168
+ wheels = [
169
+ { url = "https://files.pythonhosted.org/packages/3d/bd/c861d020831ee57609b73ea721a617985ece817684dc82415b0bc3e03ac3/pyarrow-23.0.0-cp312-cp312-macosx_12_0_arm64.whl", hash = "sha256:5961a9f646c232697c24f54d3419e69b4261ba8a8b66b0ac54a1851faffcbab8", size = 34189116, upload-time = "2026-01-18T16:15:28.054Z" },
170
+ { url = "https://files.pythonhosted.org/packages/8c/23/7725ad6cdcbaf6346221391e7b3eecd113684c805b0a95f32014e6fa0736/pyarrow-23.0.0-cp312-cp312-macosx_12_0_x86_64.whl", hash = "sha256:632b3e7c3d232f41d64e1a4a043fb82d44f8a349f339a1188c6a0dd9d2d47d8a", size = 35803831, upload-time = "2026-01-18T16:15:33.798Z" },
171
+ { url = "https://files.pythonhosted.org/packages/57/06/684a421543455cdc2944d6a0c2cc3425b028a4c6b90e34b35580c4899743/pyarrow-23.0.0-cp312-cp312-manylinux_2_28_aarch64.whl", hash = "sha256:76242c846db1411f1d6c2cc3823be6b86b40567ee24493344f8226ba34a81333", size = 44436452, upload-time = "2026-01-18T16:15:41.598Z" },
172
+ { url = "https://files.pythonhosted.org/packages/c6/6f/8f9eb40c2328d66e8b097777ddcf38494115ff9f1b5bc9754ba46991191e/pyarrow-23.0.0-cp312-cp312-manylinux_2_28_x86_64.whl", hash = "sha256:b73519f8b52ae28127000986bf228fda781e81d3095cd2d3ece76eb5cf760e1b", size = 47557396, upload-time = "2026-01-18T16:15:51.252Z" },
173
+ { url = "https://files.pythonhosted.org/packages/10/6e/f08075f1472e5159553501fde2cc7bc6700944bdabe49a03f8a035ee6ccd/pyarrow-23.0.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:068701f6823449b1b6469120f399a1239766b117d211c5d2519d4ed5861f75de", size = 48147129, upload-time = "2026-01-18T16:16:00.299Z" },
174
+ { url = "https://files.pythonhosted.org/packages/7d/82/d5a680cd507deed62d141cc7f07f7944a6766fc51019f7f118e4d8ad0fb8/pyarrow-23.0.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:1801ba947015d10e23bca9dd6ef5d0e9064a81569a89b6e9a63b59224fd060df", size = 50596642, upload-time = "2026-01-18T16:16:08.502Z" },
175
+ { url = "https://files.pythonhosted.org/packages/a9/26/4f29c61b3dce9fa7780303b86895ec6a0917c9af927101daaaf118fbe462/pyarrow-23.0.0-cp312-cp312-win_amd64.whl", hash = "sha256:52265266201ec25b6839bf6bd4ea918ca6d50f31d13e1cf200b4261cd11dc25c", size = 27660628, upload-time = "2026-01-18T16:16:15.28Z" },
176
+ { url = "https://files.pythonhosted.org/packages/66/34/564db447d083ec7ff93e0a883a597d2f214e552823bfc178a2d0b1f2c257/pyarrow-23.0.0-cp313-cp313-macosx_12_0_arm64.whl", hash = "sha256:ad96a597547af7827342ffb3c503c8316e5043bb09b47a84885ce39394c96e00", size = 34184630, upload-time = "2026-01-18T16:16:22.141Z" },
177
+ { url = "https://files.pythonhosted.org/packages/aa/3a/3999daebcb5e6119690c92a621c4d78eef2ffba7a0a1b56386d2875fcd77/pyarrow-23.0.0-cp313-cp313-macosx_12_0_x86_64.whl", hash = "sha256:b9edf990df77c2901e79608f08c13fbde60202334a4fcadb15c1f57bf7afee43", size = 35796820, upload-time = "2026-01-18T16:16:29.441Z" },
178
+ { url = "https://files.pythonhosted.org/packages/ec/ee/39195233056c6a8d0976d7d1ac1cd4fe21fb0ec534eca76bc23ef3f60e11/pyarrow-23.0.0-cp313-cp313-manylinux_2_28_aarch64.whl", hash = "sha256:36d1b5bc6ddcaff0083ceec7e2561ed61a51f49cce8be079ee8ed406acb6fdef", size = 44438735, upload-time = "2026-01-18T16:16:38.79Z" },
179
+ { url = "https://files.pythonhosted.org/packages/2c/41/6a7328ee493527e7afc0c88d105ecca69a3580e29f2faaeac29308369fd7/pyarrow-23.0.0-cp313-cp313-manylinux_2_28_x86_64.whl", hash = "sha256:4292b889cd224f403304ddda8b63a36e60f92911f89927ec8d98021845ea21be", size = 47557263, upload-time = "2026-01-18T16:16:46.248Z" },
180
+ { url = "https://files.pythonhosted.org/packages/c6/ee/34e95b21ee84db494eae60083ddb4383477b31fb1fd19fd866d794881696/pyarrow-23.0.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:dfd9e133e60eaa847fd80530a1b89a052f09f695d0b9c34c235ea6b2e0924cf7", size = 48153529, upload-time = "2026-01-18T16:16:53.412Z" },
181
+ { url = "https://files.pythonhosted.org/packages/52/88/8a8d83cea30f4563efa1b7bf51d241331ee5cd1b185a7e063f5634eca415/pyarrow-23.0.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:832141cc09fac6aab1cd3719951d23301396968de87080c57c9a7634e0ecd068", size = 50598851, upload-time = "2026-01-18T16:17:01.133Z" },
182
+ { url = "https://files.pythonhosted.org/packages/c6/4c/2929c4be88723ba025e7b3453047dc67e491c9422965c141d24bab6b5962/pyarrow-23.0.0-cp313-cp313-win_amd64.whl", hash = "sha256:7a7d067c9a88faca655c71bcc30ee2782038d59c802d57950826a07f60d83c4c", size = 27577747, upload-time = "2026-01-18T16:18:02.413Z" },
183
+ { url = "https://files.pythonhosted.org/packages/64/52/564a61b0b82d72bd68ec3aef1adda1e3eba776f89134b9ebcb5af4b13cb6/pyarrow-23.0.0-cp313-cp313t-macosx_12_0_arm64.whl", hash = "sha256:ce9486e0535a843cf85d990e2ec5820a47918235183a5c7b8b97ed7e92c2d47d", size = 34446038, upload-time = "2026-01-18T16:17:07.861Z" },
184
+ { url = "https://files.pythonhosted.org/packages/cc/c9/232d4f9855fd1de0067c8a7808a363230d223c83aeee75e0fe6eab851ba9/pyarrow-23.0.0-cp313-cp313t-macosx_12_0_x86_64.whl", hash = "sha256:075c29aeaa685fd1182992a9ed2499c66f084ee54eea47da3eb76e125e06064c", size = 35921142, upload-time = "2026-01-18T16:17:15.401Z" },
185
+ { url = "https://files.pythonhosted.org/packages/96/f2/60af606a3748367b906bb82d41f0032e059f075444445d47e32a7ff1df62/pyarrow-23.0.0-cp313-cp313t-manylinux_2_28_aarch64.whl", hash = "sha256:799965a5379589510d888be3094c2296efd186a17ca1cef5b77703d4d5121f53", size = 44490374, upload-time = "2026-01-18T16:17:23.93Z" },
186
+ { url = "https://files.pythonhosted.org/packages/ff/2d/7731543050a678ea3a413955a2d5d80d2a642f270aa57a3cb7d5a86e3f46/pyarrow-23.0.0-cp313-cp313t-manylinux_2_28_x86_64.whl", hash = "sha256:ef7cac8fe6fccd8b9e7617bfac785b0371a7fe26af59463074e4882747145d40", size = 47527896, upload-time = "2026-01-18T16:17:33.393Z" },
187
+ { url = "https://files.pythonhosted.org/packages/5a/90/f3342553b7ac9879413aed46500f1637296f3c8222107523a43a1c08b42a/pyarrow-23.0.0-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:15a414f710dc927132dd67c361f78c194447479555af57317066ee5116b90e9e", size = 48210401, upload-time = "2026-01-18T16:17:42.012Z" },
188
+ { url = "https://files.pythonhosted.org/packages/f3/da/9862ade205ecc46c172b6ce5038a74b5151c7401e36255f15975a45878b2/pyarrow-23.0.0-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:3e0d2e6915eca7d786be6a77bf227fbc06d825a75b5b5fe9bcbef121dec32685", size = 50579677, upload-time = "2026-01-18T16:17:50.241Z" },
189
+ { url = "https://files.pythonhosted.org/packages/c2/4c/f11f371f5d4740a5dafc2e11c76bcf42d03dfdb2d68696da97de420b6963/pyarrow-23.0.0-cp313-cp313t-win_amd64.whl", hash = "sha256:4b317ea6e800b5704e5e5929acb6e2dc13e9276b708ea97a39eb8b345aa2658b", size = 27631889, upload-time = "2026-01-18T16:17:56.55Z" },
190
+ { url = "https://files.pythonhosted.org/packages/97/bb/15aec78bcf43a0c004067bd33eb5352836a29a49db8581fc56f2b6ca88b7/pyarrow-23.0.0-cp314-cp314-macosx_12_0_arm64.whl", hash = "sha256:20b187ed9550d233a872074159f765f52f9d92973191cd4b93f293a19efbe377", size = 34213265, upload-time = "2026-01-18T16:18:07.904Z" },
191
+ { url = "https://files.pythonhosted.org/packages/f6/6c/deb2c594bbba41c37c5d9aa82f510376998352aa69dfcb886cb4b18ad80f/pyarrow-23.0.0-cp314-cp314-macosx_12_0_x86_64.whl", hash = "sha256:18ec84e839b493c3886b9b5e06861962ab4adfaeb79b81c76afbd8d84c7d5fda", size = 35819211, upload-time = "2026-01-18T16:18:13.94Z" },
192
+ { url = "https://files.pythonhosted.org/packages/e0/e5/ee82af693cb7b5b2b74f6524cdfede0e6ace779d7720ebca24d68b57c36b/pyarrow-23.0.0-cp314-cp314-manylinux_2_28_aarch64.whl", hash = "sha256:e438dd3f33894e34fd02b26bd12a32d30d006f5852315f611aa4add6c7fab4bc", size = 44502313, upload-time = "2026-01-18T16:18:20.367Z" },
193
+ { url = "https://files.pythonhosted.org/packages/9c/86/95c61ad82236495f3c31987e85135926ba3ec7f3819296b70a68d8066b49/pyarrow-23.0.0-cp314-cp314-manylinux_2_28_x86_64.whl", hash = "sha256:a244279f240c81f135631be91146d7fa0e9e840e1dfed2aba8483eba25cd98e6", size = 47585886, upload-time = "2026-01-18T16:18:27.544Z" },
194
+ { url = "https://files.pythonhosted.org/packages/bb/6e/a72d901f305201802f016d015de1e05def7706fff68a1dedefef5dc7eff7/pyarrow-23.0.0-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:c4692e83e42438dba512a570c6eaa42be2f8b6c0f492aea27dec54bdc495103a", size = 48207055, upload-time = "2026-01-18T16:18:35.425Z" },
195
+ { url = "https://files.pythonhosted.org/packages/f9/e5/5de029c537630ca18828db45c30e2a78da03675a70ac6c3528203c416fe3/pyarrow-23.0.0-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:ae7f30f898dfe44ea69654a35c93e8da4cef6606dc4c72394068fd95f8e9f54a", size = 50619812, upload-time = "2026-01-18T16:18:43.553Z" },
196
+ { url = "https://files.pythonhosted.org/packages/59/8d/2af846cd2412e67a087f5bda4a8e23dfd4ebd570f777db2e8686615dafc1/pyarrow-23.0.0-cp314-cp314-win_amd64.whl", hash = "sha256:5b86bb649e4112fb0614294b7d0a175c7513738876b89655605ebb87c804f861", size = 28263851, upload-time = "2026-01-18T16:19:38.567Z" },
197
+ { url = "https://files.pythonhosted.org/packages/7b/7f/caab863e587041156f6786c52e64151b7386742c8c27140f637176e9230e/pyarrow-23.0.0-cp314-cp314t-macosx_12_0_arm64.whl", hash = "sha256:ebc017d765d71d80a3f8584ca0566b53e40464586585ac64176115baa0ada7d3", size = 34463240, upload-time = "2026-01-18T16:18:49.755Z" },
198
+ { url = "https://files.pythonhosted.org/packages/c9/fa/3a5b8c86c958e83622b40865e11af0857c48ec763c11d472c87cd518283d/pyarrow-23.0.0-cp314-cp314t-macosx_12_0_x86_64.whl", hash = "sha256:0800cc58a6d17d159df823f87ad66cefebf105b982493d4bad03ee7fab84b993", size = 35935712, upload-time = "2026-01-18T16:18:55.626Z" },
199
+ { url = "https://files.pythonhosted.org/packages/c5/08/17a62078fc1a53decb34a9aa79cf9009efc74d63d2422e5ade9fed2f99e3/pyarrow-23.0.0-cp314-cp314t-manylinux_2_28_aarch64.whl", hash = "sha256:3a7c68c722da9bb5b0f8c10e3eae71d9825a4b429b40b32709df5d1fa55beb3d", size = 44503523, upload-time = "2026-01-18T16:19:03.958Z" },
200
+ { url = "https://files.pythonhosted.org/packages/cc/70/84d45c74341e798aae0323d33b7c39194e23b1abc439ceaf60a68a7a969a/pyarrow-23.0.0-cp314-cp314t-manylinux_2_28_x86_64.whl", hash = "sha256:bd5556c24622df90551063ea41f559b714aa63ca953db884cfb958559087a14e", size = 47542490, upload-time = "2026-01-18T16:19:11.208Z" },
201
+ { url = "https://files.pythonhosted.org/packages/61/d9/d1274b0e6f19e235de17441e53224f4716574b2ca837022d55702f24d71d/pyarrow-23.0.0-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:54810f6e6afc4ffee7c2e0051b61722fbea9a4961b46192dcfae8ea12fa09059", size = 48233605, upload-time = "2026-01-18T16:19:19.544Z" },
202
+ { url = "https://files.pythonhosted.org/packages/39/07/e4e2d568cb57543d84482f61e510732820cddb0f47c4bb7df629abfed852/pyarrow-23.0.0-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:14de7d48052cf4b0ed174533eafa3cfe0711b8076ad70bede32cf59f744f0d7c", size = 50603979, upload-time = "2026-01-18T16:19:26.717Z" },
203
+ { url = "https://files.pythonhosted.org/packages/72/9c/47693463894b610f8439b2e970b82ef81e9599c757bf2049365e40ff963c/pyarrow-23.0.0-cp314-cp314t-win_amd64.whl", hash = "sha256:427deac1f535830a744a4f04a6ac183a64fcac4341b3f618e693c41b7b98d2b0", size = 28338905, upload-time = "2026-01-18T16:19:32.93Z" },
204
+ ]
205
+
206
+ [[package]]
207
+ name = "pygments"
208
+ version = "2.19.2"
209
+ source = { registry = "https://pypi.org/simple" }
210
+ sdist = { url = "https://files.pythonhosted.org/packages/b0/77/a5b8c569bf593b0140bde72ea885a803b82086995367bf2037de0159d924/pygments-2.19.2.tar.gz", hash = "sha256:636cb2477cec7f8952536970bc533bc43743542f70392ae026374600add5b887", size = 4968631, upload-time = "2025-06-21T13:39:12.283Z" }
211
+ wheels = [
212
+ { url = "https://files.pythonhosted.org/packages/c7/21/705964c7812476f378728bdf590ca4b771ec72385c533964653c68e86bdc/pygments-2.19.2-py3-none-any.whl", hash = "sha256:86540386c03d588bb81d44bc3928634ff26449851e99741617ecb9037ee5ec0b", size = 1225217, upload-time = "2025-06-21T13:39:07.939Z" },
213
+ ]
214
+
215
+ [[package]]
216
+ name = "requests"
217
+ version = "2.32.5"
218
+ source = { registry = "https://pypi.org/simple" }
219
+ dependencies = [
220
+ { name = "certifi" },
221
+ { name = "charset-normalizer" },
222
+ { name = "idna" },
223
+ { name = "urllib3" },
224
+ ]
225
+ sdist = { url = "https://files.pythonhosted.org/packages/c9/74/b3ff8e6c8446842c3f5c837e9c3dfcfe2018ea6ecef224c710c85ef728f4/requests-2.32.5.tar.gz", hash = "sha256:dbba0bac56e100853db0ea71b82b4dfd5fe2bf6d3754a8893c3af500cec7d7cf", size = 134517, upload-time = "2025-08-18T20:46:02.573Z" }
226
+ wheels = [
227
+ { url = "https://files.pythonhosted.org/packages/1e/db/4254e3eabe8020b458f1a747140d32277ec7a271daf1d235b70dc0b4e6e3/requests-2.32.5-py3-none-any.whl", hash = "sha256:2462f94637a34fd532264295e186976db0f5d453d1cdd31473c85a6a161affb6", size = 64738, upload-time = "2025-08-18T20:46:00.542Z" },
228
+ ]
229
+
230
+ [[package]]
231
+ name = "rich"
232
+ version = "14.3.1"
233
+ source = { registry = "https://pypi.org/simple" }
234
+ dependencies = [
235
+ { name = "markdown-it-py" },
236
+ { name = "pygments" },
237
+ ]
238
+ sdist = { url = "https://files.pythonhosted.org/packages/a1/84/4831f881aa6ff3c976f6d6809b58cdfa350593ffc0dc3c58f5f6586780fb/rich-14.3.1.tar.gz", hash = "sha256:b8c5f568a3a749f9290ec6bddedf835cec33696bfc1e48bcfecb276c7386e4b8", size = 230125, upload-time = "2026-01-24T21:40:44.847Z" }
239
+ wheels = [
240
+ { url = "https://files.pythonhosted.org/packages/87/2a/a1810c8627b9ec8c57ec5ec325d306701ae7be50235e8fd81266e002a3cc/rich-14.3.1-py3-none-any.whl", hash = "sha256:da750b1aebbff0b372557426fb3f35ba56de8ef954b3190315eb64076d6fb54e", size = 309952, upload-time = "2026-01-24T21:40:42.969Z" },
241
+ ]
242
+
243
+ [[package]]
244
+ name = "sqlalchemy"
245
+ version = "2.0.46"
246
+ source = { registry = "https://pypi.org/simple" }
247
+ dependencies = [
248
+ { name = "greenlet", marker = "platform_machine == 'AMD64' or platform_machine == 'WIN32' or platform_machine == 'aarch64' or platform_machine == 'amd64' or platform_machine == 'ppc64le' or platform_machine == 'win32' or platform_machine == 'x86_64'" },
249
+ { name = "typing-extensions" },
250
+ ]
251
+ sdist = { url = "https://files.pythonhosted.org/packages/06/aa/9ce0f3e7a9829ead5c8ce549392f33a12c4555a6c0609bb27d882e9c7ddf/sqlalchemy-2.0.46.tar.gz", hash = "sha256:cf36851ee7219c170bb0793dbc3da3e80c582e04a5437bc601bfe8c85c9216d7", size = 9865393, upload-time = "2026-01-21T18:03:45.119Z" }
252
+ wheels = [
253
+ { url = "https://files.pythonhosted.org/packages/b6/35/d16bfa235c8b7caba3730bba43e20b1e376d2224f407c178fbf59559f23e/sqlalchemy-2.0.46-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:3a9a72b0da8387f15d5810f1facca8f879de9b85af8c645138cba61ea147968c", size = 2153405, upload-time = "2026-01-21T19:05:54.143Z" },
254
+ { url = "https://files.pythonhosted.org/packages/06/6c/3192e24486749862f495ddc6584ed730c0c994a67550ec395d872a2ad650/sqlalchemy-2.0.46-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:2347c3f0efc4de367ba00218e0ae5c4ba2306e47216ef80d6e31761ac97cb0b9", size = 3334702, upload-time = "2026-01-21T18:46:45.384Z" },
255
+ { url = "https://files.pythonhosted.org/packages/ea/a2/b9f33c8d68a3747d972a0bb758c6b63691f8fb8a49014bc3379ba15d4274/sqlalchemy-2.0.46-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:9094c8b3197db12aa6f05c51c05daaad0a92b8c9af5388569847b03b1007fb1b", size = 3347664, upload-time = "2026-01-21T18:40:09.979Z" },
256
+ { url = "https://files.pythonhosted.org/packages/aa/d2/3e59e2a91eaec9db7e8dc6b37b91489b5caeb054f670f32c95bcba98940f/sqlalchemy-2.0.46-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:37fee2164cf21417478b6a906adc1a91d69ae9aba8f9533e67ce882f4bb1de53", size = 3277372, upload-time = "2026-01-21T18:46:47.168Z" },
257
+ { url = "https://files.pythonhosted.org/packages/dd/dd/67bc2e368b524e2192c3927b423798deda72c003e73a1e94c21e74b20a85/sqlalchemy-2.0.46-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:b1e14b2f6965a685c7128bd315e27387205429c2e339eeec55cb75ca4ab0ea2e", size = 3312425, upload-time = "2026-01-21T18:40:11.548Z" },
258
+ { url = "https://files.pythonhosted.org/packages/43/82/0ecd68e172bfe62247e96cb47867c2d68752566811a4e8c9d8f6e7c38a65/sqlalchemy-2.0.46-cp312-cp312-win32.whl", hash = "sha256:412f26bb4ba942d52016edc8d12fb15d91d3cd46b0047ba46e424213ad407bcb", size = 2113155, upload-time = "2026-01-21T18:42:49.748Z" },
259
+ { url = "https://files.pythonhosted.org/packages/bc/2a/2821a45742073fc0331dc132552b30de68ba9563230853437cac54b2b53e/sqlalchemy-2.0.46-cp312-cp312-win_amd64.whl", hash = "sha256:ea3cd46b6713a10216323cda3333514944e510aa691c945334713fca6b5279ff", size = 2140078, upload-time = "2026-01-21T18:42:51.197Z" },
260
+ { url = "https://files.pythonhosted.org/packages/b3/4b/fa7838fe20bb752810feed60e45625a9a8b0102c0c09971e2d1d95362992/sqlalchemy-2.0.46-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:93a12da97cca70cea10d4b4fc602589c4511f96c1f8f6c11817620c021d21d00", size = 2150268, upload-time = "2026-01-21T19:05:56.621Z" },
261
+ { url = "https://files.pythonhosted.org/packages/46/c1/b34dccd712e8ea846edf396e00973dda82d598cb93762e55e43e6835eba9/sqlalchemy-2.0.46-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:af865c18752d416798dae13f83f38927c52f085c52e2f32b8ab0fef46fdd02c2", size = 3276511, upload-time = "2026-01-21T18:46:49.022Z" },
262
+ { url = "https://files.pythonhosted.org/packages/96/48/a04d9c94753e5d5d096c628c82a98c4793b9c08ca0e7155c3eb7d7db9f24/sqlalchemy-2.0.46-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:8d679b5f318423eacb61f933a9a0f75535bfca7056daeadbf6bd5bcee6183aee", size = 3292881, upload-time = "2026-01-21T18:40:13.089Z" },
263
+ { url = "https://files.pythonhosted.org/packages/be/f4/06eda6e91476f90a7d8058f74311cb65a2fb68d988171aced81707189131/sqlalchemy-2.0.46-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:64901e08c33462acc9ec3bad27fc7a5c2b6491665f2aa57564e57a4f5d7c52ad", size = 3224559, upload-time = "2026-01-21T18:46:50.974Z" },
264
+ { url = "https://files.pythonhosted.org/packages/ab/a2/d2af04095412ca6345ac22b33b89fe8d6f32a481e613ffcb2377d931d8d0/sqlalchemy-2.0.46-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:e8ac45e8f4eaac0f9f8043ea0e224158855c6a4329fd4ee37c45c61e3beb518e", size = 3262728, upload-time = "2026-01-21T18:40:14.883Z" },
265
+ { url = "https://files.pythonhosted.org/packages/31/48/1980c7caa5978a3b8225b4d230e69a2a6538a3562b8b31cea679b6933c83/sqlalchemy-2.0.46-cp313-cp313-win32.whl", hash = "sha256:8d3b44b3d0ab2f1319d71d9863d76eeb46766f8cf9e921ac293511804d39813f", size = 2111295, upload-time = "2026-01-21T18:42:52.366Z" },
266
+ { url = "https://files.pythonhosted.org/packages/2d/54/f8d65bbde3d877617c4720f3c9f60e99bb7266df0d5d78b6e25e7c149f35/sqlalchemy-2.0.46-cp313-cp313-win_amd64.whl", hash = "sha256:77f8071d8fbcbb2dd11b7fd40dedd04e8ebe2eb80497916efedba844298065ef", size = 2137076, upload-time = "2026-01-21T18:42:53.924Z" },
267
+ { url = "https://files.pythonhosted.org/packages/56/ba/9be4f97c7eb2b9d5544f2624adfc2853e796ed51d2bb8aec90bc94b7137e/sqlalchemy-2.0.46-cp313-cp313t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:a1e8cc6cc01da346dc92d9509a63033b9b1bda4fed7a7a7807ed385c7dccdc10", size = 3556533, upload-time = "2026-01-21T18:33:06.636Z" },
268
+ { url = "https://files.pythonhosted.org/packages/20/a6/b1fc6634564dbb4415b7ed6419cdfeaadefd2c39cdab1e3aa07a5f2474c2/sqlalchemy-2.0.46-cp313-cp313t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:96c7cca1a4babaaf3bfff3e4e606e38578856917e52f0384635a95b226c87764", size = 3523208, upload-time = "2026-01-21T18:45:08.436Z" },
269
+ { url = "https://files.pythonhosted.org/packages/a1/d8/41e0bdfc0f930ff236f86fccd12962d8fa03713f17ed57332d38af6a3782/sqlalchemy-2.0.46-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:b2a9f9aee38039cf4755891a1e50e1effcc42ea6ba053743f452c372c3152b1b", size = 3464292, upload-time = "2026-01-21T18:33:08.208Z" },
270
+ { url = "https://files.pythonhosted.org/packages/f0/8b/9dcbec62d95bea85f5ecad9b8d65b78cc30fb0ffceeb3597961f3712549b/sqlalchemy-2.0.46-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:db23b1bf8cfe1f7fda19018e7207b20cdb5168f83c437ff7e95d19e39289c447", size = 3473497, upload-time = "2026-01-21T18:45:10.552Z" },
271
+ { url = "https://files.pythonhosted.org/packages/e9/f8/5ecdfc73383ec496de038ed1614de9e740a82db9ad67e6e4514ebc0708a3/sqlalchemy-2.0.46-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:56bdd261bfd0895452006d5316cbf35739c53b9bb71a170a331fa0ea560b2ada", size = 2152079, upload-time = "2026-01-21T19:05:58.477Z" },
272
+ { url = "https://files.pythonhosted.org/packages/e5/bf/eba3036be7663ce4d9c050bc3d63794dc29fbe01691f2bf5ccb64e048d20/sqlalchemy-2.0.46-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:33e462154edb9493f6c3ad2125931e273bbd0be8ae53f3ecd1c161ea9a1dd366", size = 3272216, upload-time = "2026-01-21T18:46:52.634Z" },
273
+ { url = "https://files.pythonhosted.org/packages/05/45/1256fb597bb83b58a01ddb600c59fe6fdf0e5afe333f0456ed75c0f8d7bd/sqlalchemy-2.0.46-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:9bcdce05f056622a632f1d44bb47dbdb677f58cad393612280406ce37530eb6d", size = 3277208, upload-time = "2026-01-21T18:40:16.38Z" },
274
+ { url = "https://files.pythonhosted.org/packages/d9/a0/2053b39e4e63b5d7ceb3372cface0859a067c1ddbd575ea7e9985716f771/sqlalchemy-2.0.46-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:8e84b09a9b0f19accedcbeff5c2caf36e0dd537341a33aad8d680336152dc34e", size = 3221994, upload-time = "2026-01-21T18:46:54.622Z" },
275
+ { url = "https://files.pythonhosted.org/packages/1e/87/97713497d9502553c68f105a1cb62786ba1ee91dea3852ae4067ed956a50/sqlalchemy-2.0.46-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:4f52f7291a92381e9b4de9050b0a65ce5d6a763333406861e33906b8aa4906bf", size = 3243990, upload-time = "2026-01-21T18:40:18.253Z" },
276
+ { url = "https://files.pythonhosted.org/packages/a8/87/5d1b23548f420ff823c236f8bea36b1a997250fd2f892e44a3838ca424f4/sqlalchemy-2.0.46-cp314-cp314-win32.whl", hash = "sha256:70ed2830b169a9960193f4d4322d22be5c0925357d82cbf485b3369893350908", size = 2114215, upload-time = "2026-01-21T18:42:55.232Z" },
277
+ { url = "https://files.pythonhosted.org/packages/3a/20/555f39cbcf0c10cf452988b6a93c2a12495035f68b3dbd1a408531049d31/sqlalchemy-2.0.46-cp314-cp314-win_amd64.whl", hash = "sha256:3c32e993bc57be6d177f7d5d31edb93f30726d798ad86ff9066d75d9bf2e0b6b", size = 2139867, upload-time = "2026-01-21T18:42:56.474Z" },
278
+ { url = "https://files.pythonhosted.org/packages/3e/f0/f96c8057c982d9d8a7a68f45d69c674bc6f78cad401099692fe16521640a/sqlalchemy-2.0.46-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:4dafb537740eef640c4d6a7c254611dca2df87eaf6d14d6a5fca9d1f4c3fc0fa", size = 3561202, upload-time = "2026-01-21T18:33:10.337Z" },
279
+ { url = "https://files.pythonhosted.org/packages/d7/53/3b37dda0a5b137f21ef608d8dfc77b08477bab0fe2ac9d3e0a66eaeab6fc/sqlalchemy-2.0.46-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:42a1643dc5427b69aca967dae540a90b0fbf57eaf248f13a90ea5930e0966863", size = 3526296, upload-time = "2026-01-21T18:45:12.657Z" },
280
+ { url = "https://files.pythonhosted.org/packages/33/75/f28622ba6dde79cd545055ea7bd4062dc934e0621f7b3be2891f8563f8de/sqlalchemy-2.0.46-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:ff33c6e6ad006bbc0f34f5faf941cfc62c45841c64c0a058ac38c799f15b5ede", size = 3470008, upload-time = "2026-01-21T18:33:11.725Z" },
281
+ { url = "https://files.pythonhosted.org/packages/a9/42/4afecbbc38d5e99b18acef446453c76eec6fbd03db0a457a12a056836e22/sqlalchemy-2.0.46-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:82ec52100ec1e6ec671563bbd02d7c7c8d0b9e71a0723c72f22ecf52d1755330", size = 3476137, upload-time = "2026-01-21T18:45:15.001Z" },
282
+ { url = "https://files.pythonhosted.org/packages/fc/a1/9c4efa03300926601c19c18582531b45aededfb961ab3c3585f1e24f120b/sqlalchemy-2.0.46-py3-none-any.whl", hash = "sha256:f9c11766e7e7c0a2767dda5acb006a118640c9fc0a4104214b96269bfb78399e", size = 1937882, upload-time = "2026-01-21T18:22:10.456Z" },
283
+ ]
284
+
285
+ [[package]]
286
+ name = "typing-extensions"
287
+ version = "4.15.0"
288
+ source = { registry = "https://pypi.org/simple" }
289
+ sdist = { url = "https://files.pythonhosted.org/packages/72/94/1a15dd82efb362ac84269196e94cf00f187f7ed21c242792a923cdb1c61f/typing_extensions-4.15.0.tar.gz", hash = "sha256:0cea48d173cc12fa28ecabc3b837ea3cf6f38c6d1136f85cbaaf598984861466", size = 109391, upload-time = "2025-08-25T13:49:26.313Z" }
290
+ wheels = [
291
+ { url = "https://files.pythonhosted.org/packages/18/67/36e9267722cc04a6b9f15c7f3441c2363321a3ea07da7ae0c0707beb2a9c/typing_extensions-4.15.0-py3-none-any.whl", hash = "sha256:f0fa19c6845758ab08074a0cfa8b7aecb71c999ca73d62883bc25cc018c4e548", size = 44614, upload-time = "2025-08-25T13:49:24.86Z" },
292
+ ]
293
+
294
+ [[package]]
295
+ name = "urllib3"
296
+ version = "2.6.3"
297
+ source = { registry = "https://pypi.org/simple" }
298
+ sdist = { url = "https://files.pythonhosted.org/packages/c7/24/5f1b3bdffd70275f6661c76461e25f024d5a38a46f04aaca912426a2b1d3/urllib3-2.6.3.tar.gz", hash = "sha256:1b62b6884944a57dbe321509ab94fd4d3b307075e0c2eae991ac71ee15ad38ed", size = 435556, upload-time = "2026-01-07T16:24:43.925Z" }
299
+ wheels = [
300
+ { url = "https://files.pythonhosted.org/packages/39/08/aaaad47bc4e9dc8c725e68f9d04865dbcb2052843ff09c97b08904852d84/urllib3-2.6.3-py3-none-any.whl", hash = "sha256:bf272323e553dfb2e87d9bfd225ca7b0f467b919d7bbd355436d3fd37cb0acd4", size = 131584, upload-time = "2026-01-07T16:24:42.685Z" },
301
+ ]