Skip to content

Commit

Permalink
[Bug Fix] Fixed MattingResult bug (#593)
Browse files Browse the repository at this point in the history
* add onnx_ort_runtime demo

* rm in requirements

* support batch eval

* fixed MattingResults bug
  • Loading branch information
wjj19950828 authored Nov 15, 2022
1 parent 0e0838d commit 37ee101
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions fastdeploy/vision/common/result.cc
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ void MattingResult::Reserve(int size) {
if (contain_foreground) {
FDASSERT((shape.size() == 3),
"Please initial shape (h,w,c) before call Reserve.");
int c = static_cast<int>(shape[3]);
int c = static_cast<int>(shape[2]);
foreground.reserve(size * c);
}
}
Expand All @@ -382,7 +382,7 @@ void MattingResult::Resize(int size) {
if (contain_foreground) {
FDASSERT((shape.size() == 3),
"Please initial shape (h,w,c) before call Resize.");
int c = static_cast<int>(shape[3]);
int c = static_cast<int>(shape[2]);
foreground.resize(size * c);
}
}
Expand Down
8 changes: 7 additions & 1 deletion tests/models/test_rvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import numpy as np
import runtime_config as rc


def test_matting_rvm_cpu():
model_url = "https://bj.bcebos.com/paddlehub/fastdeploy/rvm.tgz"
input_url = "https://bj.bcebos.com/paddlehub/fastdeploy/video.mp4"
Expand All @@ -38,7 +39,8 @@ def test_matting_rvm_cpu():
break
result = model.predict(frame)
# compare diff
expect_alpha = np.load("resources/rvm/result_alpha_" + str(frame_id) + ".npy")
expect_alpha = np.load("resources/rvm/result_alpha_" + str(frame_id) +
".npy")
result_alpha = np.array(result.alpha).reshape(1920, 1080)
diff = np.fabs(expect_alpha - result_alpha)
thres = 1e-05
Expand All @@ -51,3 +53,7 @@ def test_matting_rvm_cpu():
cap.release()
cv2.destroyAllWindows()
break


if __name__ == "__main__":
test_matting_rvm_cpu()

0 comments on commit 37ee101

Please sign in to comment.