mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-09-14 19:44:05 +08:00
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:
@@ -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]]
|
||||
|
||||
Reference in New Issue
Block a user