ci: faster model_replay (#34036)

* cache draft

* fix

* fix

* fix

* better

* zst

* more

* try

* pool

* fix

* fix

* revert :C

* better

* cleanup

* no cache

* this too
This commit is contained in:
Maxime Desroches
2024-11-16 15:34:21 -08:00
committed by GitHub
parent 22d19f2fc4
commit 847a5ce1f3
3 changed files with 56 additions and 10 deletions
+22
View File
@@ -535,3 +535,25 @@ def FrameIterator(fn, pix_fmt, **kwargs):
else:
for i in range(fr.frame_count):
yield fr.get(i, pix_fmt=pix_fmt)[0]
class NumpyFrameReader:
def __init__(self, name, w, h, cache_size):
self.name = name
self.pos = -1
self.frames = None
self.w = w
self.h = h
self.cache_size = cache_size
def close(self):
pass
def get(self, num, count=1, pix_fmt="nv12"):
num -= 1
q = num // self.cache_size
if q != self.pos:
del self.frames
self.pos = q
self.frames = np.load(f'{self.name}_{self.pos}.npy')
return [self.frames[num % self.cache_size]]