| """Quick sanity check — sample 12 random SS:coriander images to verify labeling.""" | |
| import random | |
| from pathlib import Path | |
| import matplotlib | |
| matplotlib.use("Agg") | |
| import matplotlib.pyplot as plt | |
| from PIL import Image | |
| CORIANDER_DIR = Path("D:/SpiceNet/Spice_Spectrum/coriander") | |
| OUT = Path("D:/SpiceNet/outputs/coriander_inspection.png") | |
| random.seed(42) | |
| paths = sorted(p for p in CORIANDER_DIR.iterdir() | |
| if p.suffix.lower() in {".jpg", ".jpeg", ".png"}) | |
| print(f"Total SS:coriander images: {len(paths)}") | |
| sample = random.sample(paths, 12) | |
| fig, axes = plt.subplots(3, 4, figsize=(12, 9)) | |
| for ax, p in zip(axes.flatten(), sample): | |
| ax.imshow(Image.open(p).convert("RGB")) | |
| ax.set_title(p.name, fontsize=8) | |
| ax.axis("off") | |
| plt.suptitle("SpiceSpectrum 'coriander' — 12 random samples", fontsize=12) | |
| plt.tight_layout(rect=(0, 0, 1, 0.97)) | |
| plt.savefig(OUT, dpi=120, bbox_inches="tight") | |
| plt.close() | |
| print(f"Saved {OUT}") | |