Jannchie commited on
Commit
ffce9bc
·
1 Parent(s): 4b79013

refactor!: strip repo down to metadata sync and tag statistics

Browse files

Remove the dataset pipeline (make_ds), image downloaders, quality and
debias statistics, parquet/webp converters, stale tag-group scripts,
and the now-unused danbooru/ and utils/ packages. Drop pyarrow and
declare requires-python >= 3.12.

BREAKING CHANGE: removed scripts remain available in history at 62a4c39.

.gitignore CHANGED
@@ -11,3 +11,4 @@ image
11
  *.txt
12
  *.caption
13
  *.npz
 
 
11
  *.txt
12
  *.caption
13
  *.npz
14
+ *.stackdump
README.md CHANGED
@@ -1,27 +1,23 @@
1
- ---
2
- license: mit
3
- ---
4
-
5
- Metadata of all posts from Danbooru.
6
-
7
- I did not include the media_asset field because it is largely redundant with other fields.
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
  ```
 
1
+ ---
2
+ license: mit
3
+ ---
4
+
5
+ Metadata of all posts from Danbooru.
6
+
7
+ I did not include the media_asset field because it is largely redundant with other fields.
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
  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.
12
 
13
  ## Layout
14
+ - `scripts/update_danbooru.py`: incremental/full metadata sync from the Danbooru API into SQLite.
15
+ - `scripts/tag_frequency.py`: count tag frequency per category (general/artist/character/copyright) into CSV.
16
  - `data/db/`: SQLite databases.
17
+ - `data/outputs/tags/`: tag frequency CSV outputs.
 
 
 
 
18
 
19
  Example:
20
  ```
21
  uv run python scripts/update_danbooru.py --api_key <KEY> --login <USER>
22
+ uv run python scripts/tag_frequency.py
23
  ```
danbooru/__init__.py DELETED
@@ -1,139 +0,0 @@
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}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
pyproject.toml CHANGED
@@ -1,8 +1,8 @@
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",
 
1
  [project]
2
  name = "danbooru_metadata"
3
  version = "0.0.0"
4
+ requires-python = ">=3.12"
5
  dependencies = [
 
6
  "requests>=2.32.5",
7
  "rich>=14.3.1",
8
  "sqlalchemy>=2.0.46",
requirements.txt DELETED
Binary file (2.81 kB)
 
scripts/_paths.py CHANGED
@@ -8,21 +8,10 @@ if str(ROOT) not in sys.path:
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():
 
8
 
9
  DATA_DIR = ROOT / "data"
10
  DB_DIR = DATA_DIR / "db"
 
 
11
  OUTPUTS_DIR = DATA_DIR / "outputs"
12
  TAGS_DIR = OUTPUTS_DIR / "tags"
 
 
 
 
 
 
 
13
 
14
  DANBOORU_DB_PATH = DB_DIR / "danbooru_metadata.db"
 
 
15
 
16
  LEGACY_DANBOORU_DB_PATH = ROOT / "danbooru_metadata.db"
17
  if not DANBOORU_DB_PATH.exists() and LEGACY_DANBOORU_DB_PATH.exists():
scripts/download_images.py DELETED
@@ -1,135 +0,0 @@
1
- import argparse
2
- import os
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",
32
- "webp",
33
- "bmp",
34
- "PNG",
35
- "JPG",
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(),
55
- "[progress.percentage]{task.percentage:>3.0f}%",
56
- TimeElapsedColumn(),
57
- TimeRemainingColumn(),
58
- "[green] [{task.completed} / {task.total}] [/]",
59
- )
60
- task = progress.add_task("Downloading", total=count)
61
- progress.start()
62
- print("Fetching posts")
63
- cursor.execute("SELECT id, file_url, file_ext FROM posts")
64
- while True:
65
- progress.update(task, advance=1)
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)
86
- response.raise_for_status()
87
-
88
- # Calculate directory based on post_id and create it if necessary
89
- directory = os.path.join(OUT_DIR, f"{post_id % 1000:04d}")
90
- os.makedirs(directory, exist_ok=True)
91
- ext = url.split(".")[-1]
92
- # Determine file path and save the image
93
- file_path = os.path.join(directory, f"{post_id}.{ext}")
94
- with open(file_path, "wb") as f:
95
- for chunk in response.iter_content(1024):
96
- f.write(chunk)
97
- # print(f"Downloaded {file_path}")
98
- except requests.RequestException as e:
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:
106
- post_id, url = task_queue.get()
107
- except queue.Empty:
108
- break
109
- download_image(post_id, url)
110
- task_queue.task_done()
111
-
112
-
113
- if __name__ == "__main__":
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()
121
- threads.append(thread)
122
- # Wait for all threads to finish
123
- try:
124
- fetch_posts_to_queue()
125
-
126
- # Ensure all tasks are done
127
- task_queue.join()
128
-
129
- for thread in threads:
130
- thread.join()
131
-
132
- print("All downloads completed.")
133
- except KeyboardInterrupt:
134
- print("Download interrupted.")
135
- os._exit(1)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
scripts/get_image DELETED
File without changes
scripts/make_ds/0.get_meta_from_latents.py DELETED
@@ -1,45 +0,0 @@
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 DELETED
@@ -1,407 +0,0 @@
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 DELETED
@@ -1,84 +0,0 @@
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 DELETED
@@ -1,125 +0,0 @@
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 DELETED
@@ -1,150 +0,0 @@
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 DELETED
@@ -1,26 +0,0 @@
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 DELETED
@@ -1,59 +0,0 @@
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 DELETED
@@ -1,19 +0,0 @@
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 DELETED
File without changes
scripts/make_ds/utils/__init__.py DELETED
@@ -1,77 +0,0 @@
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 DELETED
@@ -1,45 +0,0 @@
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 DELETED
@@ -1,2 +0,0 @@
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 DELETED
@@ -1,57 +0,0 @@
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 DELETED
@@ -1,74 +0,0 @@
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 DELETED
@@ -1,107 +0,0 @@
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 DELETED
@@ -1,80 +0,0 @@
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 DELETED
@@ -1,67 +0,0 @@
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 DELETED
@@ -1,486 +0,0 @@
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 DELETED
@@ -1,18 +0,0 @@
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_gt_100.py DELETED
@@ -1,27 +0,0 @@
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 DELETED
@@ -1,45 +0,0 @@
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 DELETED
@@ -1,22 +0,0 @@
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 DELETED
@@ -1,3 +0,0 @@
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 DELETED
@@ -1,43 +0,0 @@
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))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
utils/__init__.py DELETED
@@ -1,77 +0,0 @@
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 CHANGED
@@ -1,5 +1,5 @@
1
  version = 1
2
- revision = 2
3
  requires-python = ">=3.12"
4
 
5
  [[package]]
@@ -73,7 +73,6 @@ 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" },
@@ -81,7 +80,6 @@ dependencies = [
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" },
@@ -96,7 +94,6 @@ 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" },
@@ -105,7 +102,6 @@ wheels = [
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" },
@@ -114,7 +110,6 @@ wheels = [
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" },
@@ -123,7 +118,6 @@ wheels = [
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" },
@@ -160,49 +154,6 @@ 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"
 
1
  version = 1
2
+ revision = 3
3
  requires-python = ">=3.12"
4
 
5
  [[package]]
 
73
  version = "0.0.0"
74
  source = { virtual = "." }
75
  dependencies = [
 
76
  { name = "requests" },
77
  { name = "rich" },
78
  { name = "sqlalchemy" },
 
80
 
81
  [package.metadata]
82
  requires-dist = [
 
83
  { name = "requests", specifier = ">=2.32.5" },
84
  { name = "rich", specifier = ">=14.3.1" },
85
  { name = "sqlalchemy", specifier = ">=2.0.46" },
 
94
  { 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" },
95
  { 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" },
96
  { 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" },
 
97
  { 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" },
98
  { 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" },
99
  { 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" },
 
102
  { 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" },
103
  { 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" },
104
  { 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" },
 
105
  { 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" },
106
  { 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" },
107
  { 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" },
 
110
  { 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" },
111
  { 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" },
112
  { 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" },
 
113
  { 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" },
114
  { 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" },
115
  { 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" },
 
118
  { 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" },
119
  { 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" },
120
  { 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" },
 
121
  { 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" },
122
  { 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" },
123
  { 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" },
 
154
  { 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" },
155
  ]
156
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
  [[package]]
158
  name = "pygments"
159
  version = "2.19.2"