mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-09 10:30:37 +08:00
add more tests
This commit is contained in:
@@ -66,5 +66,55 @@ def test_detection_faster_rcnn():
|
|||||||
# with open("faster_rcnn_baseline.pkl", "wb") as f:
|
# with open("faster_rcnn_baseline.pkl", "wb") as f:
|
||||||
# pickle.dump([np.array(result.boxes), np.array(result.scores), np.array(result.label_ids)], f)
|
# pickle.dump([np.array(result.boxes), np.array(result.scores), np.array(result.label_ids)], f)
|
||||||
|
|
||||||
|
def test_detection_faster_rcnn1():
|
||||||
|
model_url = "https://bj.bcebos.com/paddlehub/fastdeploy/faster_rcnn_r50_vd_fpn_2x_coco.tgz"
|
||||||
|
input_url1 = "https://gitee.com/paddlepaddle/PaddleDetection/raw/release/2.4/demo/000000014439.jpg"
|
||||||
|
result_url = "https://bj.bcebos.com/fastdeploy/tests/data/faster_rcnn_baseline.pkl"
|
||||||
|
fd.download_and_decompress(model_url, "resources")
|
||||||
|
fd.download(input_url1, "resources")
|
||||||
|
fd.download(result_url, "resources")
|
||||||
|
model_path = "resources/faster_rcnn_r50_vd_fpn_2x_coco"
|
||||||
|
|
||||||
|
model_file = os.path.join(model_path, "model.pdmodel")
|
||||||
|
params_file = os.path.join(model_path, "model.pdiparams")
|
||||||
|
config_file = os.path.join(model_path, "infer_cfg.yml")
|
||||||
|
preprocessor = fd.vision.detection.PaddleDetPreprocessor(config_file)
|
||||||
|
postprocessor = fd.vision.detection.PaddleDetPostprocessor()
|
||||||
|
|
||||||
|
option = rc.test_option
|
||||||
|
option.set_model_path(model_file, params_file)
|
||||||
|
option.use_paddle_infer_backend()
|
||||||
|
runtime = fd.Runtime(option);
|
||||||
|
|
||||||
|
# compare diff
|
||||||
|
im1 = cv2.imread("./resources/000000014439.jpg")
|
||||||
|
for i in range(2):
|
||||||
|
im1 = cv2.imread("./resources/000000014439.jpg")
|
||||||
|
input_tensors = preprocessor.run([im1])
|
||||||
|
output_tensors = runtime.infer({"image": input_tensors[0], "scale_factor": input_tensors[1], "im_shape": input_tensors[2]})
|
||||||
|
results = postprocessor.run(output_tensors)
|
||||||
|
result = results[0]
|
||||||
|
|
||||||
|
with open("resources/faster_rcnn_baseline.pkl", "rb") as f:
|
||||||
|
boxes, scores, label_ids = pickle.load(f)
|
||||||
|
pred_boxes = np.array(result.boxes)
|
||||||
|
pred_scores = np.array(result.scores)
|
||||||
|
pred_label_ids = np.array(result.label_ids)
|
||||||
|
|
||||||
|
diff_boxes = np.fabs(boxes - pred_boxes)
|
||||||
|
diff_scores = np.fabs(scores - pred_scores)
|
||||||
|
diff_label_ids = np.fabs(label_ids - pred_label_ids)
|
||||||
|
|
||||||
|
print(diff_boxes.max(), diff_scores.max(), diff_label_ids.max())
|
||||||
|
|
||||||
|
score_threshold = 0.0
|
||||||
|
assert diff_boxes[scores > score_threshold].max(
|
||||||
|
) < 1e-04, "There's diff in boxes."
|
||||||
|
assert diff_scores[scores > score_threshold].max(
|
||||||
|
) < 1e-04, "There's diff in scores."
|
||||||
|
assert diff_label_ids[scores > score_threshold].max(
|
||||||
|
) < 1e-04, "There's diff in label_ids."
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
test_detection_faster_rcnn()
|
test_detection_faster_rcnn()
|
||||||
|
test_detection_faster_rcnn1()
|
||||||
|
@@ -13,6 +13,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import fastdeploy as fd
|
import fastdeploy as fd
|
||||||
|
import copy
|
||||||
import cv2
|
import cv2
|
||||||
import os
|
import os
|
||||||
import pickle
|
import pickle
|
||||||
@@ -38,7 +39,61 @@ def test_detection_mask_rcnn():
|
|||||||
# compare diff
|
# compare diff
|
||||||
im1 = cv2.imread("./resources/000000014439.jpg")
|
im1 = cv2.imread("./resources/000000014439.jpg")
|
||||||
for i in range(2):
|
for i in range(2):
|
||||||
|
with open("resources/mask_rcnn_baseline.pkl", "rb") as f:
|
||||||
|
boxes, scores, label_ids = pickle.load(f)
|
||||||
result = model.predict(im1)
|
result = model.predict(im1)
|
||||||
|
pred_boxes = np.array(result.boxes)
|
||||||
|
pred_scores = np.array(result.scores)
|
||||||
|
pred_label_ids = np.array(result.label_ids)
|
||||||
|
|
||||||
|
diff_boxes = np.fabs(boxes - pred_boxes)
|
||||||
|
diff_scores = np.fabs(scores - pred_scores)
|
||||||
|
diff_label_ids = np.fabs(label_ids - pred_label_ids)
|
||||||
|
|
||||||
|
print(diff_boxes.max(), diff_scores.max(), diff_label_ids.max())
|
||||||
|
|
||||||
|
score_threshold = 0.0
|
||||||
|
assert diff_boxes[scores > score_threshold].max(
|
||||||
|
) < 1e-01, "There's diff in boxes."
|
||||||
|
assert diff_scores[scores > score_threshold].max(
|
||||||
|
) < 1e-02, "There's diff in scores."
|
||||||
|
assert diff_label_ids[scores > score_threshold].max(
|
||||||
|
) < 1e-04, "There's diff in label_ids."
|
||||||
|
|
||||||
|
|
||||||
|
# result = model.predict(im1)
|
||||||
|
# with open("mask_rcnn_baseline.pkl", "wb") as f:
|
||||||
|
# pickle.dump([np.array(result.boxes), np.array(result.scores), np.array(result.label_ids)], f)
|
||||||
|
|
||||||
|
def test_detection_mask_rcnn1():
|
||||||
|
model_url = "https://bj.bcebos.com/paddlehub/fastdeploy/mask_rcnn_r50_1x_coco.tgz"
|
||||||
|
input_url1 = "https://gitee.com/paddlepaddle/PaddleDetection/raw/release/2.4/demo/000000014439.jpg"
|
||||||
|
result_url = "https://bj.bcebos.com/fastdeploy/tests/data/mask_rcnn_baseline.pkl"
|
||||||
|
fd.download_and_decompress(model_url, "resources")
|
||||||
|
fd.download(input_url1, "resources")
|
||||||
|
fd.download(result_url, "resources")
|
||||||
|
model_path = "resources/mask_rcnn_r50_1x_coco"
|
||||||
|
|
||||||
|
model_file = os.path.join(model_path, "model.pdmodel")
|
||||||
|
params_file = os.path.join(model_path, "model.pdiparams")
|
||||||
|
config_file = os.path.join(model_path, "infer_cfg.yml")
|
||||||
|
preprocessor = fd.vision.detection.PaddleDetPreprocessor(config_file)
|
||||||
|
postprocessor = fd.vision.detection.PaddleDetPostprocessor()
|
||||||
|
|
||||||
|
option = rc.test_option
|
||||||
|
option.set_model_path(model_file, params_file)
|
||||||
|
option.use_paddle_infer_backend()
|
||||||
|
runtime = fd.Runtime(option);
|
||||||
|
|
||||||
|
# compare diff
|
||||||
|
im1 = cv2.imread("./resources/000000014439.jpg")
|
||||||
|
for i in range(2):
|
||||||
|
im1 = cv2.imread("./resources/000000014439.jpg")
|
||||||
|
input_tensors = preprocessor.run([im1])
|
||||||
|
output_tensors = runtime.infer({"image": input_tensors[0], "scale_factor": input_tensors[1], "im_shape": input_tensors[2]})
|
||||||
|
results = postprocessor.run(output_tensors)
|
||||||
|
result = results[0]
|
||||||
|
|
||||||
with open("resources/mask_rcnn_baseline.pkl", "rb") as f:
|
with open("resources/mask_rcnn_baseline.pkl", "rb") as f:
|
||||||
boxes, scores, label_ids = pickle.load(f)
|
boxes, scores, label_ids = pickle.load(f)
|
||||||
pred_boxes = np.array(result.boxes)
|
pred_boxes = np.array(result.boxes)
|
||||||
@@ -53,16 +108,12 @@ def test_detection_mask_rcnn():
|
|||||||
|
|
||||||
score_threshold = 0.0
|
score_threshold = 0.0
|
||||||
assert diff_boxes[scores > score_threshold].max(
|
assert diff_boxes[scores > score_threshold].max(
|
||||||
) < 1e-04, "There's diff in boxes."
|
) < 1e-01, "There's diff in boxes."
|
||||||
assert diff_scores[scores > score_threshold].max(
|
assert diff_scores[scores > score_threshold].max(
|
||||||
) < 1e-04, "There's diff in scores."
|
) < 1e-02, "There's diff in scores."
|
||||||
assert diff_label_ids[scores > score_threshold].max(
|
assert diff_label_ids[scores > score_threshold].max(
|
||||||
) < 1e-04, "There's diff in label_ids."
|
) < 1e-04, "There's diff in label_ids."
|
||||||
|
|
||||||
|
|
||||||
# result = model.predict(im1)
|
|
||||||
# with open("mask_rcnn_baseline.pkl", "wb") as f:
|
|
||||||
# pickle.dump([np.array(result.boxes), np.array(result.scores), np.array(result.label_ids)], f)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
test_detection_mask_rcnn()
|
test_detection_mask_rcnn()
|
||||||
|
test_detection_mask_rcnn1()
|
||||||
|
@@ -36,6 +36,12 @@ def test_detection_picodet():
|
|||||||
model = fd.vision.detection.PicoDet(
|
model = fd.vision.detection.PicoDet(
|
||||||
model_file, params_file, config_file, runtime_option=rc.test_option)
|
model_file, params_file, config_file, runtime_option=rc.test_option)
|
||||||
|
|
||||||
|
preprocessor = fd.vision.detection.PaddleDetPreprocessor(config_file)
|
||||||
|
postprocessor = fd.vision.detection.PaddleDetPostprocessor()
|
||||||
|
|
||||||
|
rc.test_option.set_model_path(model_file, params_file)
|
||||||
|
runtime = fd.Runtime(rc.test_option);
|
||||||
|
|
||||||
# compare diff
|
# compare diff
|
||||||
im1 = cv2.imread("./resources/000000014439.jpg")
|
im1 = cv2.imread("./resources/000000014439.jpg")
|
||||||
for i in range(2):
|
for i in range(2):
|
||||||
@@ -65,5 +71,54 @@ def test_detection_picodet():
|
|||||||
# with open("picodet_baseline.pkl", "wb") as f:
|
# with open("picodet_baseline.pkl", "wb") as f:
|
||||||
# pickle.dump([np.array(result.boxes), np.array(result.scores), np.array(result.label_ids)], f)
|
# pickle.dump([np.array(result.boxes), np.array(result.scores), np.array(result.label_ids)], f)
|
||||||
|
|
||||||
|
def test_detection_picodet1():
|
||||||
|
model_url = "https://bj.bcebos.com/paddlehub/fastdeploy/picodet_l_320_coco_lcnet.tgz"
|
||||||
|
input_url1 = "https://gitee.com/paddlepaddle/PaddleDetection/raw/release/2.4/demo/000000014439.jpg"
|
||||||
|
result_url = "https://bj.bcebos.com/fastdeploy/tests/data/picodet_baseline.pkl"
|
||||||
|
fd.download_and_decompress(model_url, "resources")
|
||||||
|
fd.download(input_url1, "resources")
|
||||||
|
fd.download(result_url, "resources")
|
||||||
|
model_path = "resources/picodet_l_320_coco_lcnet"
|
||||||
|
|
||||||
|
model_file = os.path.join(model_path, "model.pdmodel")
|
||||||
|
params_file = os.path.join(model_path, "model.pdiparams")
|
||||||
|
config_file = os.path.join(model_path, "infer_cfg.yml")
|
||||||
|
|
||||||
|
preprocessor = fd.vision.detection.PaddleDetPreprocessor(config_file)
|
||||||
|
postprocessor = fd.vision.detection.PaddleDetPostprocessor()
|
||||||
|
|
||||||
|
rc.test_option.set_model_path(model_file, params_file)
|
||||||
|
runtime = fd.Runtime(rc.test_option);
|
||||||
|
|
||||||
|
# compare diff
|
||||||
|
im1 = cv2.imread("./resources/000000014439.jpg")
|
||||||
|
for i in range(2):
|
||||||
|
input_tensors = preprocessor.run([im1])
|
||||||
|
output_tensors = runtime.infer({"image": input_tensors[0], "scale_factor": input_tensors[1]})
|
||||||
|
results = postprocessor.run(output_tensors)
|
||||||
|
result = results[0]
|
||||||
|
with open("resources/picodet_baseline.pkl", "rb") as f:
|
||||||
|
boxes, scores, label_ids = pickle.load(f)
|
||||||
|
pred_boxes = np.array(result.boxes)
|
||||||
|
pred_scores = np.array(result.scores)
|
||||||
|
pred_label_ids = np.array(result.label_ids)
|
||||||
|
|
||||||
|
diff_boxes = np.fabs(boxes - pred_boxes)
|
||||||
|
diff_scores = np.fabs(scores - pred_scores)
|
||||||
|
diff_label_ids = np.fabs(label_ids - pred_label_ids)
|
||||||
|
|
||||||
|
print(diff_boxes.max(), diff_scores.max(), diff_label_ids.max())
|
||||||
|
with open("resources/dump_result.pkl", "wb") as f:
|
||||||
|
pickle.dump([pred_boxes, pred_scores, pred_label_ids], f)
|
||||||
|
|
||||||
|
score_threshold = 0.0
|
||||||
|
assert diff_boxes[scores > score_threshold].max(
|
||||||
|
) < 1e-01, "There's diff in boxes."
|
||||||
|
assert diff_scores[scores > score_threshold].max(
|
||||||
|
) < 1e-03, "There's diff in scores."
|
||||||
|
assert diff_label_ids[scores > score_threshold].max(
|
||||||
|
) < 1e-04, "There's diff in label_ids."
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
test_detection_picodet()
|
test_detection_picodet()
|
||||||
|
test_detection_picodet1()
|
||||||
|
@@ -66,5 +66,52 @@ def test_detection_yolox():
|
|||||||
# with open("ppyolox_baseline.pkl", "wb") as f:
|
# with open("ppyolox_baseline.pkl", "wb") as f:
|
||||||
# pickle.dump([np.array(result.boxes), np.array(result.scores), np.array(result.label_ids)], f)
|
# pickle.dump([np.array(result.boxes), np.array(result.scores), np.array(result.label_ids)], f)
|
||||||
|
|
||||||
|
def test_detection_yolox_1():
|
||||||
|
model_url = "https://bj.bcebos.com/paddlehub/fastdeploy/yolox_s_300e_coco.tgz"
|
||||||
|
input_url1 = "https://gitee.com/paddlepaddle/PaddleDetection/raw/release/2.4/demo/000000014439.jpg"
|
||||||
|
result_url = "https://bj.bcebos.com/fastdeploy/tests/data/ppyolox_baseline.pkl"
|
||||||
|
fd.download_and_decompress(model_url, "resources")
|
||||||
|
fd.download(input_url1, "resources")
|
||||||
|
fd.download(result_url, "resources")
|
||||||
|
model_path = "resources/yolox_s_300e_coco"
|
||||||
|
|
||||||
|
model_file = os.path.join(model_path, "model.pdmodel")
|
||||||
|
params_file = os.path.join(model_path, "model.pdiparams")
|
||||||
|
config_file = os.path.join(model_path, "infer_cfg.yml")
|
||||||
|
|
||||||
|
preprocessor = fd.vision.detection.PaddleDetPreprocessor(config_file)
|
||||||
|
postprocessor = fd.vision.detection.PaddleDetPostprocessor()
|
||||||
|
|
||||||
|
rc.test_option.set_model_path(model_file, params_file)
|
||||||
|
runtime = fd.Runtime(rc.test_option);
|
||||||
|
|
||||||
|
# compare diff
|
||||||
|
im1 = cv2.imread("./resources/000000014439.jpg")
|
||||||
|
for i in range(3):
|
||||||
|
input_tensors = preprocessor.run([im1])
|
||||||
|
output_tensors = runtime.infer({"image": input_tensors[0], "scale_factor": input_tensors[1]})
|
||||||
|
results = postprocessor.run(output_tensors)
|
||||||
|
result = results[0]
|
||||||
|
with open("resources/ppyolox_baseline.pkl", "rb") as f:
|
||||||
|
boxes, scores, label_ids = pickle.load(f)
|
||||||
|
pred_boxes = np.array(result.boxes)
|
||||||
|
pred_scores = np.array(result.scores)
|
||||||
|
pred_label_ids = np.array(result.label_ids)
|
||||||
|
|
||||||
|
diff_boxes = np.fabs(boxes - pred_boxes)
|
||||||
|
diff_scores = np.fabs(scores - pred_scores)
|
||||||
|
diff_label_ids = np.fabs(label_ids - pred_label_ids)
|
||||||
|
|
||||||
|
print(diff_boxes.max(), diff_scores.max(), diff_label_ids.max())
|
||||||
|
|
||||||
|
score_threshold = 0.0
|
||||||
|
assert diff_boxes[scores > score_threshold].max(
|
||||||
|
) < 1e-01, "There's diff in boxes."
|
||||||
|
assert diff_scores[scores > score_threshold].max(
|
||||||
|
) < 1e-02, "There's diff in scores."
|
||||||
|
assert diff_label_ids[scores > score_threshold].max(
|
||||||
|
) < 1e-04, "There's diff in label_ids."
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
test_detection_yolox()
|
test_detection_yolox()
|
||||||
|
test_detection_yolox_1()
|
||||||
|
@@ -65,5 +65,56 @@ def test_detection_ppyolo():
|
|||||||
# with open("ppyolo_baseline.pkl", "wb") as f:
|
# with open("ppyolo_baseline.pkl", "wb") as f:
|
||||||
# pickle.dump([np.array(result.boxes), np.array(result.scores), np.array(result.label_ids)], f)
|
# pickle.dump([np.array(result.boxes), np.array(result.scores), np.array(result.label_ids)], f)
|
||||||
|
|
||||||
|
def test_detection_ppyolo1():
|
||||||
|
model_url = "https://bj.bcebos.com/paddlehub/fastdeploy/ppyolov2_r101vd_dcn_365e_coco.tgz"
|
||||||
|
input_url1 = "https://gitee.com/paddlepaddle/PaddleDetection/raw/release/2.4/demo/000000014439.jpg"
|
||||||
|
result_url = "https://bj.bcebos.com/fastdeploy/tests/data/ppyolo_baseline.pkl"
|
||||||
|
fd.download_and_decompress(model_url, "resources")
|
||||||
|
fd.download(input_url1, "resources")
|
||||||
|
fd.download(result_url, "resources")
|
||||||
|
model_path = "resources/ppyolov2_r101vd_dcn_365e_coco"
|
||||||
|
|
||||||
|
model_file = os.path.join(model_path, "model.pdmodel")
|
||||||
|
params_file = os.path.join(model_path, "model.pdiparams")
|
||||||
|
config_file = os.path.join(model_path, "infer_cfg.yml")
|
||||||
|
|
||||||
|
preprocessor = fd.vision.detection.PaddleDetPreprocessor(config_file)
|
||||||
|
postprocessor = fd.vision.detection.PaddleDetPostprocessor()
|
||||||
|
|
||||||
|
option = rc.test_option
|
||||||
|
option.use_paddle_backend()
|
||||||
|
option.set_model_path(model_file, params_file)
|
||||||
|
runtime = fd.Runtime(option);
|
||||||
|
|
||||||
|
# compare diff
|
||||||
|
im1 = cv2.imread("./resources/000000014439.jpg")
|
||||||
|
for i in range(2):
|
||||||
|
input_tensors = preprocessor.run([im1])
|
||||||
|
output_tensors = runtime.infer({"image": input_tensors[0], "scale_factor": input_tensors[1], "im_shape": input_tensors[2]})
|
||||||
|
results = postprocessor.run(output_tensors)
|
||||||
|
result = results[0]
|
||||||
|
with open("resources/ppyolo_baseline.pkl", "rb") as f:
|
||||||
|
boxes, scores, label_ids = pickle.load(f)
|
||||||
|
pred_boxes = np.array(result.boxes)
|
||||||
|
pred_scores = np.array(result.scores)
|
||||||
|
pred_label_ids = np.array(result.label_ids)
|
||||||
|
|
||||||
|
diff_boxes = np.fabs(boxes - pred_boxes)
|
||||||
|
diff_scores = np.fabs(scores - pred_scores)
|
||||||
|
diff_label_ids = np.fabs(label_ids - pred_label_ids)
|
||||||
|
|
||||||
|
print(diff_boxes.max(), diff_scores.max(), diff_label_ids.max())
|
||||||
|
with open("resources/dump_result.pkl", "wb") as f:
|
||||||
|
pickle.dump([pred_boxes, pred_scores, pred_label_ids], f)
|
||||||
|
|
||||||
|
score_threshold = 0.0
|
||||||
|
assert diff_boxes[scores > score_threshold].max(
|
||||||
|
) < 1e-01, "There's diff in boxes."
|
||||||
|
assert diff_scores[scores > score_threshold].max(
|
||||||
|
) < 1e-03, "There's diff in scores."
|
||||||
|
assert diff_label_ids[scores > score_threshold].max(
|
||||||
|
) < 1e-04, "There's diff in label_ids."
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
test_detection_ppyolo()
|
test_detection_ppyolo()
|
||||||
|
test_detection_ppyolo1()
|
||||||
|
@@ -60,9 +60,53 @@ def test_detection_ppyoloe():
|
|||||||
assert diff_label_ids[scores > score_threshold].max(
|
assert diff_label_ids[scores > score_threshold].max(
|
||||||
) < 1e-04, "There's diff in label_ids."
|
) < 1e-04, "There's diff in label_ids."
|
||||||
|
|
||||||
|
def test_detection_ppyoloe1():
|
||||||
|
model_url = "https://bj.bcebos.com/paddlehub/fastdeploy/ppyoloe_crn_l_300e_coco.tgz"
|
||||||
|
input_url1 = "https://gitee.com/paddlepaddle/PaddleDetection/raw/release/2.4/demo/000000014439.jpg"
|
||||||
|
result_url = "https://bj.bcebos.com/fastdeploy/tests/data/ppyoloe_baseline.pkl"
|
||||||
|
fd.download_and_decompress(model_url, "resources")
|
||||||
|
fd.download(input_url1, "resources")
|
||||||
|
fd.download(result_url, "resources")
|
||||||
|
model_path = "resources/ppyoloe_crn_l_300e_coco"
|
||||||
|
|
||||||
|
model_file = os.path.join(model_path, "model.pdmodel")
|
||||||
|
params_file = os.path.join(model_path, "model.pdiparams")
|
||||||
|
config_file = os.path.join(model_path, "infer_cfg.yml")
|
||||||
|
|
||||||
|
preprocessor = fd.vision.detection.PaddleDetPreprocessor(config_file)
|
||||||
|
postprocessor = fd.vision.detection.PaddleDetPostprocessor()
|
||||||
|
|
||||||
|
rc.test_option.set_model_path(model_file, params_file)
|
||||||
|
runtime = fd.Runtime(rc.test_option);
|
||||||
|
|
||||||
|
# compare diff
|
||||||
|
im1 = cv2.imread("./resources/000000014439.jpg")
|
||||||
|
for i in range(2):
|
||||||
|
input_tensors = preprocessor.run([im1])
|
||||||
|
output_tensors = runtime.infer({"image": input_tensors[0], "scale_factor": input_tensors[1]})
|
||||||
|
results = postprocessor.run(output_tensors)
|
||||||
|
result = results[0]
|
||||||
|
with open("resources/ppyoloe_baseline.pkl", "rb") as f:
|
||||||
|
boxes, scores, label_ids = pickle.load(f)
|
||||||
|
pred_boxes = np.array(result.boxes)
|
||||||
|
pred_scores = np.array(result.scores)
|
||||||
|
pred_label_ids = np.array(result.label_ids)
|
||||||
|
|
||||||
|
diff_boxes = np.fabs(boxes - pred_boxes)
|
||||||
|
diff_scores = np.fabs(scores - pred_scores)
|
||||||
|
diff_label_ids = np.fabs(label_ids - pred_label_ids)
|
||||||
|
|
||||||
|
print(diff_boxes.max(), diff_scores.max(), diff_label_ids.max())
|
||||||
|
|
||||||
|
score_threshold = 0.0
|
||||||
|
assert diff_boxes[scores > score_threshold].max(
|
||||||
|
) < 1e-01, "There's diff in boxes."
|
||||||
|
assert diff_scores[scores > score_threshold].max(
|
||||||
|
) < 1e-02, "There's diff in scores."
|
||||||
|
assert diff_label_ids[scores > score_threshold].max(
|
||||||
|
) < 1e-04, "There's diff in label_ids."
|
||||||
|
|
||||||
# with open("ppyoloe_baseline.pkl", "wb") as f:
|
|
||||||
# pickle.dump([np.array(result.boxes), np.array(result.scores), np.array(result.label_ids)], f)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
test_detection_ppyoloe()
|
test_detection_ppyoloe()
|
||||||
|
test_detection_ppyoloe1()
|
||||||
|
Reference in New Issue
Block a user