Skip to content

Commit 40848b4

Browse files
author
yq
committed
network cmake
1 parent 1de540f commit 40848b4

7 files changed

+91
-6
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
*.d
33

44
/bin/
5+
/build/
56
.vscode/
67
/data/stripes/
78
/data/results/

CMakeLists.txt

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
2+
project(DOC_REASSEMBLY)
3+
4+
# Find includes and libraries
5+
include_directories(${DOC_REASSEMBLY_SOURCE_DIR}/include)
6+
find_package(Torch REQUIRED)
7+
find_package(OpenCV REQUIRED)
8+
if (APPLE)
9+
# Add tesseract lib directory
10+
link_directories(/usr/local/lib)
11+
endif()
12+
13+
# Set default variables
14+
set(SRC_ROOT_PATH ${DOC_REASSEMBLY_SOURCE_DIR}/src)
15+
set(EXECUTABLE_OUTPUT_PATH ${DOC_REASSEMBLY_SOURCE_DIR}/bin)
16+
set(CMAKE_CXX_STANDARD 11)
17+
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -Wall -g -ggdb -DDEBUG")
18+
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -Wall")
19+
set(CMAKE_BUILD_TYPE Release)
20+
21+
# Debug cmake
22+
# set(CMAKE_VERBOSE_MAKEFILE ON)
23+
24+
# utils
25+
add_library(utils ${SRC_ROOT_PATH}/utils.cpp)
26+
target_link_libraries(utils ${OpenCV_LIBRARIES})
27+
28+
# evaluator
29+
set(EVALUATOR_PATH ${SRC_ROOT_PATH}/evaluator)
30+
add_library(compatibility_net ${EVALUATOR_PATH}/compatibility_net.cpp)
31+
add_executable(train-evaluator ${EVALUATOR_PATH}/train_evaluator.cpp)
32+
target_link_libraries(train-evaluator ${TORCH_LIBRARIES})
33+
34+
# add-noise
35+
add_executable(add-noise ${SRC_ROOT_PATH}/add_noise.cpp)
36+
target_link_libraries(add-noise ${OpenCV_LIBRARIES})
37+
38+
# debug-tool
39+
add_executable(debug-tool ${SRC_ROOT_PATH}/debug_tool.cpp)
40+
target_link_libraries(debug-tool ${OpenCV_LIBRARIES} tesseract utils)
41+
42+
# generator
43+
set(GENERATOR_PATH ${SRC_ROOT_PATH}/generator)
44+
aux_source_directory(${GENERATOR_PATH} GENERATOR_SRC)
45+
add_executable(generator ${GENERATOR_SRC})
46+
target_link_libraries(generator ${OpenCV_LIBRARIES} tesseract utils)
47+
48+
# solver
49+
set(SOLVER_PATH ${SRC_ROOT_PATH}/solver)
50+
aux_source_directory(${SOLVER_PATH} SOLVER_SRC)
51+
add_executable(solver ${SOLVER_SRC})
52+
target_link_libraries(solver ${OpenCV_LIBRARIES} tesseract utils)

autogen.sh

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
echo [cmd] mkdir build
4+
mkdir build
5+
cd build
6+
7+
echo [cmd] cmake -DCMAKE_PREFIX_PATH=/Users/yq/Sources/libtorch ..
8+
cmake -DCMAKE_PREFIX_PATH=/Users/yq/Sources/libtorch ..
9+
10+
echo [cmd] make -j12
11+
make -j12

include/compatibility_net.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
#ifndef COMPATIBILITY_NET_H
22
#define COMPATIBILITY_NET_H
33

4-
#include <iostream>
5-
#include <torch/script.h>
4+
class CompatibilityNet {
65

7-
using namespace std;
6+
public:
7+
CompatibilityNet();
8+
};
89

910
#endif

include/train_evaluator.h

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#ifndef TRAIN_EVALUATOR_H
2+
#define TRAIN_EVALUATOR_H
3+
4+
#include <iostream>
5+
#include <torch/script.h>
6+
7+
#include <compatibility_net.h>
8+
9+
using namespace std;
10+
11+
#endif

src/evaluator/compatibility_net.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include <compatibility_net.h>
22

3-
int main() {
4-
torch::Tensor tensor = torch::rand({2, 3});
5-
cout << tensor << std::endl;
3+
CompatibilityNet::CompatibilityNet() {
4+
65
}

src/evaluator/train_evaluator.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
#include <train_evaluator.h>
3+
4+
int main() {
5+
torch::Tensor tensor = torch::rand({2, 3});
6+
cout << tensor << std::endl;
7+
8+
CompatibilityNet comp_net();
9+
10+
}

0 commit comments

Comments
 (0)