Skip to content

Commit

Permalink
[Bugfix] Fix Relative Path (#448)
Browse files Browse the repository at this point in the history
  • Loading branch information
wangzijian1010 authored Dec 26, 2024
1 parent 5f4938f commit 4af23c2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ set(CMAKE_CUDA_ARCHITECTURES 89) # For RTX 20xx series
# 启用 CUDA
enable_language(CUDA)
set(LITE_AI_ROOT_DIR ${CMAKE_SOURCE_DIR})
# 将 CMAKE_SOURCE_DIR 传递给代码
add_definitions(-DSOURCE_PATH="${CMAKE_SOURCE_DIR}")

option(ENABLE_TEST "build test examples." OFF)
option(ENABLE_DEBUG_STRING "enable DEBUG string or not" ON)
Expand Down
Binary file added examples/lite/resources/model_matrix.npy
Binary file not shown.
4 changes: 3 additions & 1 deletion lite/ort/cv/face_swap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ void Face_Swap::preprocess(cv::Mat &target_face, std::vector<float> source_image
preprocessed_mat.convertTo(preprocessed_mat,CV_32FC3,1.0 / 255.f);
preprocessed_mat.convertTo(preprocessed_mat,CV_32FC3,1.0 / 1.f,0);

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

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

Expand Down
5 changes: 3 additions & 2 deletions lite/trt/cv/trt_face_swap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ void TRTFaceFusionFaceSwap::preprocess(cv::Mat &target_face, std::vector<float>
cv::cvtColor(preprocessed_mat,preprocessed_mat,cv::COLOR_BGR2RGB);
preprocessed_mat.convertTo(preprocessed_mat,CV_32FC3,1.0 / 255.f);
preprocessed_mat.convertTo(preprocessed_mat,CV_32FC3,1.0 / 1.f,0);

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

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

Expand Down

0 comments on commit 4af23c2

Please sign in to comment.