Pagination (200/page), batched+checkpointed ingest (batch_size, resume-safe), quality max_files slicing, upload page; Caddy routes for prefect/photo-filter
This commit is contained in:
@@ -86,9 +86,37 @@ def _move(p: Path, dest_root: Path, src_root: Path):
|
||||
shutil.move(str(p), str(dest))
|
||||
|
||||
|
||||
|
||||
|
||||
def _slice_dir(base_dir: str, max_files: int) -> str:
|
||||
"""Copy first N images into a temp dir for CleanVision to audit."""
|
||||
import shutil
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
|
||||
src = Path(base_dir)
|
||||
tmp = Path(tempfile.mkdtemp(prefix="cvslice_"))
|
||||
exts = {".jpg", ".jpeg", ".png", ".webp", ".gif", ".heic", ".tif", ".bmp"}
|
||||
n = 0
|
||||
for p in src.rglob("*"):
|
||||
if p.is_file() and p.suffix.lower() in exts:
|
||||
shutil.copy2(p, tmp / p.name)
|
||||
n += 1
|
||||
if n >= max_files:
|
||||
break
|
||||
print(f"_slice_dir: copied {n} files to {tmp}")
|
||||
return str(tmp)
|
||||
|
||||
|
||||
@flow(name="photo-quality-scan")
|
||||
def quality_scan(base_dir: str, move: bool = False, notify: bool = True):
|
||||
"""Audit image quality with CleanVision; classify into keep/review/delete."""
|
||||
def quality_scan(base_dir: str, move: bool = False, notify: bool = True, max_files: int = None):
|
||||
"""Audit image quality with CleanVision; classify into keep/review/delete.
|
||||
|
||||
max_files: if set, only audit the first N image files (slices huge folders
|
||||
into reviewable chunks — prevents OOM on 50K-file trees).
|
||||
"""
|
||||
if max_files: # 0/None = unlimited
|
||||
base_dir = _slice_dir(base_dir, max_files)
|
||||
audit = audit_folder(base_dir)
|
||||
print(f"Issue summary: {audit['summary']}")
|
||||
result = classify_and_sort(base_dir, audit["per_image"], move=move)
|
||||
|
||||
Reference in New Issue
Block a user