Skip to content

Commit 43fbeca

Browse files
committed
Changed bindings. Testing with Libraries...
1 parent 66a3354 commit 43fbeca

3 files changed

Lines changed: 35 additions & 22 deletions

File tree

binding.gyp

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
'sources': ['src/api.cc'],
55

66
'libraries' : [
7-
"<!@(pkg-config --libs protobuf)"
7+
"<!@(pkg-config --libs protobuf)",
8+
"<!@(find $(pwd)/src/lib -iname \*.lo)"
89
],
910

1011
'include_dirs' : [
@@ -22,21 +23,23 @@
2223
"conditions": [
2324
[ "OS==\"mac\"", {
2425
"xcode_settings": {
25-
"OTHER_CFLAGS": [
26-
"-mmacosx-version-min=10.7",
27-
"-std=c++11",
28-
"-stdlib=libc++",
29-
"<!@(pkg-config --cflags opencv)",
30-
],
31-
"GCC_ENABLE_CPP_RTTI": "YES",
32-
"GCC_ENABLE_CPP_EXCEPTIONS": "YES"
33-
}
26+
"OTHER_CFLAGS": [
27+
"-mmacosx-version-min=10.7",
28+
"-std=c++11",
29+
"-stdlib=libc++",
30+
"<!@(pkg-config --cflags protobuf)",
31+
],
32+
"GCC_ENABLE_CPP_RTTI": "YES",
33+
"GCC_ENABLE_CPP_EXCEPTIONS": "YES"
34+
}
3435
}]
3536
],
3637
'cflags': [
37-
"<!@(pkg-config --cflags protobuf)"
38+
"<!@(pkg-config --cflags protobuf)",
39+
"-frtti",
3840
],
3941
'cflags!': [
42+
"-fno-rtti",
4043
"-fno-exceptions"
4144
]
4245
}]

index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ var bindings = require('bindings');
44
var addon = bindings('node-tensorflow');
55

66
addon.version();
7+
8+
addon.test();

src/api.cc

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ using tensorflow::int32;
3434
// input the model expects. If you train your own model, or use something
3535
// other than GoogLeNet you'll need to update these.
3636
TF_DEFINE_string(image,
37-
"tensorflow/examples/label_image/data/grace_hopper.jpg",
37+
"data/grace_hopper.jpg",
3838
"The image to classify (JPEG or PNG).");
3939
TF_DEFINE_string(graph,
40-
"tensorflow/examples/label_image/data/googlenet_graph.pb",
40+
"data/googlenet_graph.pb",
4141
"The location of the GraphDef file containing the protobuf"
4242
" definition of the network.");
4343
TF_DEFINE_string(labels,
44-
"tensorflow/examples/label_image/data/googlenet_labels.txt",
44+
"data/googlenet_labels.txt",
4545
"A text file containing the labels of all the categories, one"
4646
" per line.");
4747
TF_DEFINE_int32(input_width, 224, "Width of the image the network expects.");
@@ -216,14 +216,14 @@ Status CheckTopLabel(const std::vector<Tensor>& outputs, int expected,
216216
return Status::OK();
217217
}
218218

219-
int main(int argc, char* argv[]) {
219+
int runTests() {
220220
// We need to call this to set up global state for TensorFlow.
221-
tensorflow::port::InitMain(argv[0], &argc, &argv);
222-
Status s = tensorflow::ParseCommandLineFlags(&argc, argv);
223-
if (!s.ok()) {
224-
LOG(ERROR) << "Error parsing command line flags: " << s.ToString();
225-
return -1;
226-
}
221+
// tensorflow::port::InitMain(argv[0], &argc, &argv);
222+
// Status s = tensorflow::ParseCommandLineFlags(&argc, argv);
223+
// if (!s.ok()) {
224+
// LOG(ERROR) << "Error parsing command line flags: " << s.ToString();
225+
// return -1;
226+
// }
227227

228228
// First we load and initialize the model.
229229
std::unique_ptr<tensorflow::Session> session;
@@ -285,8 +285,13 @@ int main(int argc, char* argv[]) {
285285

286286
using namespace v8;
287287

288+
NAN_METHOD(RunTest) {
289+
printf("\nRunning Test\n");
290+
runTests();
291+
}
292+
288293
NAN_METHOD(Version) {
289-
printf("%s", TF_VERSION_STRING);
294+
printf("%s\n", TF_VERSION_STRING);
290295
}
291296

292297
NAN_METHOD(Print) {
@@ -299,6 +304,9 @@ NAN_MODULE_INIT(Init) {
299304

300305
Nan::Set(target, Nan::New("version").ToLocalChecked(),
301306
Nan::GetFunction(Nan::New<FunctionTemplate>(Version)).ToLocalChecked());
307+
308+
Nan::Set(target, Nan::New("test").ToLocalChecked(),
309+
Nan::GetFunction(Nan::New<FunctionTemplate>(RunTest)).ToLocalChecked());
302310
}
303311

304312
NODE_MODULE(myaddon, Init);

0 commit comments

Comments
 (0)