Files
sunnypilot/selfdrive/test/model_test.py
Adeeb Shihadeh c7c49e8e35 fix up model tests + tools (#21071)
* unlogger: send yuv stream

* fix up model test tools

* fix unlogger

* rename model replay

* bump cereal

* test in actions

* no ci for now
old-commit-hash: cf6d133638
2021-05-28 23:08:08 -07:00

31 lines
1.1 KiB
Python
Executable File

#!/usr/bin/env python3
import os
import numpy as np
from tools.lib.logreader import LogReader
from tools.lib.framereader import FrameReader
from tools.lib.cache import cache_path_for_file_path
from selfdrive.test.process_replay.model_replay import model_replay
if __name__ == "__main__":
lr = LogReader(os.path.expanduser('~/rlog.bz2'))
fr = FrameReader(os.path.expanduser('~/fcamera.hevc'))
desire = np.load(os.path.expanduser('~/desire.npy'))
calib = np.load(os.path.expanduser('~/calib.npy'))
try:
msgs = model_replay(list(lr), fr, desire=desire, calib=calib)
finally:
cache_path = cache_path_for_file_path(os.path.expanduser('~/fcamera.hevc'))
if os.path.isfile(cache_path):
os.remove(cache_path)
output_size = len(np.frombuffer(msgs[0].model.rawPredictions, dtype=np.float32))
output_data = np.zeros((len(msgs), output_size), dtype=np.float32)
for i, msg in enumerate(msgs):
output_data[i] = np.frombuffer(msg.model.rawPredictions, dtype=np.float32)
np.save(os.path.expanduser('~/modeldata.npy'), output_data)
print("Finished replay")