Skip to content

Commit

Permalink
[*] httplib
Browse files Browse the repository at this point in the history
  • Loading branch information
acgist committed Mar 21, 2024
1 parent 274d939 commit e47eb65
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 11 deletions.
16 changes: 15 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,28 @@ jobs:
################################
# cpp-httplib
################################
sudo apt install libcpp-httplib-dev
git clone https://github.com/yhirose/cpp-httplib.git
cd cpp-httplib
git checkout v0.15.3
mkdir build
cd build
cmake ..
make -j 8
make install
cd ../../
################################
# libtorch
################################
wget https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.2.1%2Bcpu.zip
unzip libtorch-cxx11-abi-shared-with-deps-2.2.1+cpu.zip
################################
# 输出目录
################################
ls -lh
- name: Deploy lifuren
run: |
# 输出目录
pwd
# 输出版本
gcc -v
g++ -v
Expand Down
9 changes: 1 addition & 8 deletions boot/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
project(lifurentest VERSION 1.0.0 LANGUAGES C CXX)

aux_source_directory(${SOURCE_DIR} SOURCE_FILES)

file(GLOB SUB_SOURCE_FILES "src/source/*/*.cpp")

add_executable(${PROJECT_NAME} src/Main.cpp ${SOURCE_FILES} ${SUB_SOURCE_FILES})
add_executable(${PROJECT_NAME} src/Main.cpp)

target_link_libraries(
${PROJECT_NAME} PUBLIC
lifurencore
httplib::httplib
${FLTK_LIBRARIES}
)

target_include_directories(
Expand All @@ -20,7 +14,6 @@ target_include_directories(

set(
HEADER_FILES
${HEADER_DIR}/Core.hpp
${HEADER_DIR}/Fltk.hpp
${HEADER_DIR}/OpenCV.hpp
${HEADER_DIR}/LibTorch.hpp
Expand Down
4 changes: 2 additions & 2 deletions boot/test/src/source/libtorch/GenderHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ lifuren::GenderImpl::GenderImpl(std::vector<int>& cfg, int num_classes, bool bat
torch::Tensor lifuren::GenderImpl::forward(torch::Tensor x) {
x = this->features->forward(x);
x = this->avgPool(x);
x = torch::flatten(x,1);
x = torch::flatten(x, 1);
x = this->classifier->forward(x);
return torch::log_softmax(x, 1);
}
Expand All @@ -41,7 +41,7 @@ void lifuren::GenderHandler::trainAndVal(
std::string path_train = (data_path / "train").u8string();
std::string path_val = (data_path / "val").u8string();
auto data_loader_val = lifuren::datasets::loadImageDataset(batch_size, path_train, image_type);
auto data_loader_train = lifuren::datasets::loadImageDataset(batch_size, path_val, image_type);
auto data_loader_train = lifuren::datasets::loadImageDataset(batch_size, path_val, image_type);
// size_t valSize = data_loader_val.size().value();
// size_t trainSize = data_loader_train.size().value();
for (size_t epoch = 1; epoch <= num_epochs; ++epoch) {
Expand Down
11 changes: 11 additions & 0 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ file(GLOB SUB_SOURCE_FILES "src/source/*/*.cpp")

add_library(${PROJECT_NAME} STATIC ${SOURCE_FILES} ${SUB_SOURCE_FILES})

if(CMAKE_HOST_WIN32)
target_link_libraries(
${PROJECT_NAME} PUBLIC
spdlog::spdlog
Expand All @@ -14,6 +15,16 @@ target_link_libraries(
${OpenCV_LIBS}
${TORCH_LIBRARIES}
)
else()
target_link_libraries(
${PROJECT_NAME} PUBLIC
spdlog::spdlog
yaml-cpp
nlohmann_json::nlohmann_json
${OpenCV_LIBS}
${TORCH_LIBRARIES}
)
endif()

target_include_directories(
${PROJECT_NAME} PUBLIC
Expand Down

0 comments on commit e47eb65

Please sign in to comment.