def test_save_and_load(): cl = SVMClassifier() cl.load_model(MODEL_PATH) classify_result = cl.classify(VIDEO_PATH) result_file = "save.json" reporter = Reporter() reporter.save(result_file, classify_result) assert os.path.isfile(result_file) classify_result_after = Reporter.load(result_file) assert len(classify_result) == len(classify_result_after) for i, j in zip(classify_result, classify_result_after): assert i.to_dict() == j.to_dict()
def test_save_and_load(): cl = SVMClassifier() cl.load_model(MODEL_PATH) classify_result = cl.classify(VIDEO_PATH, boost_mode=False) result_file = "save.json" reporter = Reporter() reporter.add_extra("some_name", "some_value") reporter.save(result_file, classify_result) assert os.path.isfile(result_file) classify_result_after = Reporter.load(result_file) assert classify_result.get_length() == classify_result_after.get_length() for i, j in zip(classify_result.data, classify_result_after.data): assert i.to_dict() == j.to_dict() assert isinstance(reporter.get_stable_stage_sample(classify_result), np.ndarray)