Skip to content

Commit 2b1cae9

Browse files
committed
Merged changes from aul12/cppflow
- Reduced number of memmory leaks - Avoid using of unnecessary pointers To mantain the original structure, aul12/cppflow structure has been modified to match the original serizba/cppflow structure
1 parent bcd5e98 commit 2b1cae9

File tree

12 files changed

+37
-83
lines changed

12 files changed

+37
-83
lines changed

CMakeLists.txt

Lines changed: 0 additions & 57 deletions
This file was deleted.

examples/coco/CMakeLists.txt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
add_executable(coco_example main.cpp ../../src/Model.cpp ../../src/Tensor.cpp)
2-
find_package(OpenCV REQUIRED )
3-
target_include_directories(coco_example PRIVATE ../../include)
4-
target_link_libraries (coco_example ${LIBS} ${OpenCV_LIBS})
1+
cmake_minimum_required(VERSION 3.10)
2+
project(example)
3+
4+
set(CMAKE_CXX_STANDARD 17)
5+
add_executable(example main.cpp ../../src/Model.cpp ../../src/Tensor.cpp)
6+
find_package( OpenCV REQUIRED )
7+
target_include_directories(example PRIVATE ../../include)
8+
target_link_libraries (example -ltensorflow ${OpenCV_LIBS})

examples/coco/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// Created by sergio on 16/05/19.
33
//
44

5-
#include "../../src/Model.h"
6-
#include "../../src/Tensor.h"
5+
#include "../../include/Model.h"
6+
#include "../../include/Tensor.h"
77
#include <opencv2/opencv.hpp>
88
#include <numeric>
99
#include <iomanip>

examples/load_model/CMakeLists.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
cmake_minimum_required(VERSION 3.10)
2+
project(example)
3+
14
set(CMAKE_CXX_STANDARD 17)
2-
add_executable(load_model_example main.cpp ../../src/Model.cpp ../../src/Tensor.cpp)
3-
target_include_directories(load_model_example PRIVATE ../../include)
4-
target_link_libraries (load_model_example ${LIBS})
5+
add_executable(example main.cpp ../../src/Model.cpp ../../src/Tensor.cpp)
6+
target_include_directories(example PRIVATE ../../include)
7+
target_link_libraries (example -ltensorflow)

examples/load_model/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// Created by sergio on 16/05/19.
33
//
44

5-
#include "../../src/Model.h"
6-
#include "../../src/Tensor.h"
5+
#include "../../include/Model.h"
6+
#include "../../include/Tensor.h"
77

88
#include <numeric>
99
#include <iomanip>

examples/mnist/CMakeLists.txt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
find_package(OpenCV REQUIRED )
2-
add_executable(nmist_example main.cpp ../../src/Model.cpp ../../src/Tensor.cpp)
3-
target_include_directories(nmist_example PRIVATE ../../include)
4-
target_link_libraries (nmist_example ${LIBS} ${OpenCV_LIBS})
1+
cmake_minimum_required(VERSION 3.10)
2+
project(example)
3+
4+
set(CMAKE_CXX_STANDARD 17)
5+
find_package( OpenCV REQUIRED )
6+
add_executable(example main.cpp ../../src/Model.cpp ../../src/Tensor.cpp)
7+
target_include_directories(example PRIVATE ../../include)
8+
target_link_libraries (example -ltensorflow ${OpenCV_LIBS})

examples/mnist/main.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// Created by sergio on 12/05/19.
33
//
44

5-
#include "../../src/Model.h"
6-
#include "../../src/Tensor.h"
5+
#include "../../include/Model.h"
6+
#include "../../include/Tensor.h"
77
#include <opencv2/opencv.hpp>
88
#include <algorithm>
99
#include <iterator>
@@ -12,8 +12,8 @@
1212
int main() {
1313

1414
// Create model
15-
Model m("model.pb");
16-
m.restore("checkpoint/train.ckpt");
15+
Model m("../model.pb");
16+
m.restore("../checkpoint/train.ckpt");
1717

1818
// Create Tensors
1919
Tensor input(m, "input");
@@ -24,7 +24,7 @@ int main() {
2424
cv::Mat img, scaled;
2525

2626
// Read image
27-
img = cv::imread("images/"+std::to_string(i)+".png");
27+
img = cv::imread("../images/"+std::to_string(i)+".png");
2828

2929
// Scale image to range 0-1
3030
img.convertTo(scaled, CV_64F, 1.f/255);

examples/mnist/model.pb

0 Bytes
Binary file not shown.

src/Model.h renamed to include/Model.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
#ifndef CPPFLOW_MODEL_H
66
#define CPPFLOW_MODEL_H
77

8+
#include <cstring>
9+
#include <algorithm>
810
#include <string>
911
#include <vector>
1012
#include <iostream>
1113
#include <fstream>
1214
#include <tuple>
13-
#include "c_api.h"
15+
#include <tensorflow/c/c_api.h>
1416
#include "Tensor.h"
1517

1618
class Tensor;

src/Tensor.h renamed to include/Tensor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <algorithm>
1212
#include <numeric>
1313
#include <cstring>
14-
#include "c_api.h"
14+
#include <tensorflow/c/c_api.h>
1515
#include "Model.h"
1616

1717
class Model;

0 commit comments

Comments
 (0)