Skip to content

Commit 4af23c2

Browse files
[Bugfix] Fix Relative Path (#448)
1 parent 5f4938f commit 4af23c2

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ set(CMAKE_CUDA_ARCHITECTURES 89) # For RTX 20xx series
2626
# 启用 CUDA
2727
enable_language(CUDA)
2828
set(LITE_AI_ROOT_DIR ${CMAKE_SOURCE_DIR})
29+
# 将 CMAKE_SOURCE_DIR 传递给代码
30+
add_definitions(-DSOURCE_PATH="${CMAKE_SOURCE_DIR}")
2931

3032
option(ENABLE_TEST "build test examples." OFF)
3133
option(ENABLE_DEBUG_STRING "enable DEBUG string or not" ON)
1 MB
Binary file not shown.

lite/ort/cv/face_swap.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ void Face_Swap::preprocess(cv::Mat &target_face, std::vector<float> source_image
1919
preprocessed_mat.convertTo(preprocessed_mat,CV_32FC3,1.0 / 255.f);
2020
preprocessed_mat.convertTo(preprocessed_mat,CV_32FC3,1.0 / 1.f,0);
2121

22-
std::vector<float> model_martix = face_utils::load_npy("/home/facefusion-onnxrun/python/model_matrix.npy");
22+
// 使用 CMake 传递的 SOURCE_PATH 宏
23+
std::string model_matrix_path = std::string(SOURCE_PATH) + "/examples/lite/resources/model_matrix.npy";
24+
std::vector<float> model_martix = face_utils::load_npy(model_matrix_path);
2325

2426
processed_source_embeding= face_utils::dot_product(source_image_embeding,model_martix,512);
2527

lite/trt/cv/trt_face_swap.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ void TRTFaceFusionFaceSwap::preprocess(cv::Mat &target_face, std::vector<float>
1717
cv::cvtColor(preprocessed_mat,preprocessed_mat,cv::COLOR_BGR2RGB);
1818
preprocessed_mat.convertTo(preprocessed_mat,CV_32FC3,1.0 / 255.f);
1919
preprocessed_mat.convertTo(preprocessed_mat,CV_32FC3,1.0 / 1.f,0);
20-
21-
std::vector<float> model_martix = face_utils::load_npy("/home/facefusion-onnxrun/python/model_matrix.npy");
20+
// 使用 CMake 传递的 SOURCE_PATH 宏
21+
std::string model_matrix_path = std::string(SOURCE_PATH) + "/examples/lite/resources/model_matrix.npy";
22+
std::vector<float> model_martix = face_utils::load_npy(model_matrix_path);
2223

2324
processed_source_embeding= face_utils::dot_product(source_image_embeding,model_martix,512);
2425

0 commit comments

Comments
 (0)