our_knp/objects/prepare_fresh_test.py
int 8f126bc29a Exact spiking pipeline simulator, fresh test set, night log
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 00:13:52 +03:00

17 lines
893 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""Fresh cats/dogs test: CIFAR-10 JPEG mirror test 0700–0999 per class (600 images never used before).
usage: ~/anvenv/bin/python prepare_fresh_test.py → /home/int/run/cats-dogs/data-v3/fresh_test.npz
"""
from pathlib import Path
import numpy as np
from PIL import Image
cache = Path('/home/int/run/cats-dogs/data/github-jpeg-cache')
items = [(label, cls, i) for cls, label in enumerate(('cat', 'dog')) for i in range(700, 1000)]
order = np.random.default_rng(20261015).permutation(len(items))
items = [items[j] for j in order]
rgb = np.stack([np.asarray(Image.open(cache / f'test-{l}-{i:04d}.jpg').convert('RGB')).transpose(2, 0, 1) for l, _, i in items])
np.savez_compressed('/home/int/run/cats-dogs/data-v3/fresh_test.npz', rgb=rgb,
labels=np.array([c for _, c, _ in items], np.uint8), names=np.array([f'test/{l}/{i:04d}' for l, _, i in items]))
print(rgb.shape)