Skip to content

Commit 9ed9171

Browse files
committed
update181229
1 parent 329e153 commit 9ed9171

12 files changed

+73
-60
lines changed

CMakeLists.txt

+10-9
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ set(
1010
CUDA_NVCC_FLAGS
1111
${CUDA_NVCC_FLAGS};
1212
-O3
13-
-gencode arch=compute_53,code=sm_53
14-
-gencode arch=compute_62,code=sm_62
13+
-gencode arch=compute_53,code=sm_53 #tegra tx1
14+
-gencode arch=compute_61,code=sm_61 #gtx 1060
15+
-gencode arch=compute_62,code=sm_62 #tegra tx2
1516
)
1617

1718
# setup project output paths
@@ -32,8 +33,8 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_OUTPUT_DIR}/lib)
3233
# build C/C++ interface
3334
include_directories(${PROJECT_INCLUDE_DIR} ${GIE_PATH}/include)
3435
include_directories(${PROJECT_INCLUDE_DIR}
35-
/home/nvidia/caffe/include
36-
/home/nvidia/caffe/build/include
36+
/home/chen/caffe/include
37+
/home/chen/caffe/build/include
3738
)
3839

3940

@@ -42,11 +43,11 @@ file(GLOB inferenceIncludes *.h )
4243

4344
cuda_add_library(sysDetectSpeed SHARED ${inferenceSources})
4445
target_link_libraries(sysDetectSpeed
45-
/home/nvidia/caffe/build/lib/libcaffe.so
46-
/usr/lib/aarch64-linux-gnu/libglog.so
47-
/usr/lib/aarch64-linux-gnu/libgflags.so.2
48-
/usr/lib/aarch64-linux-gnu/libboost_system.so
49-
/usr/lib/aarch64-linux-gnu/libGLEW.so.1.13
46+
/home/chen/caffe/build/lib/libcaffe.so
47+
/usr/lib/x86_64-linux-gnu/libglog.so
48+
/usr/lib/x86_64-linux-gnu/libgflags.so.2
49+
/usr/lib/x86_64-linux-gnu/libboost_system.so
50+
/usr/lib/x86_64-linux-gnu/libGLEW.so.1.13
5051
)
5152

5253

activation_kernels.cu

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Company: Systhesis
2+
* Company: Synthesis
33
* Author: Chen
44
* Date: 2018/06/04
55
*/

activations.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Company: Systhesis
2+
* Company: Synthesis
33
* Author: Chen
44
* Date: 2018/06/04
55
*/

blas.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Company: Systhesis
2+
* Company: Synthesis
33
* Author: Chen
44
* Date: 2018/06/04
55
*/

blas_kernels.cu

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Company: Systhesis
2+
* Company: Synthesis
33
* Author: Chen
44
* Date: 2018/06/04
55
*/

box.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Company: Systhesis
2+
* Company: Synthesis
33
* Author: Chen
44
* Date: 2018/06/04
55
*/

cuda.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Company: Systhesis
2+
* Company: Synthesis
33
* Author: Chen
44
* Date: 2018/06/04
55
*/

cuda.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Company: Systhesis
2+
* Company: Synthesis
33
* Author: Chen
44
* Date: 2018/06/04
55
*/

detectnet/detectnet.cpp

+48-38
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
/*
3-
* Company: Systhesis
3+
* Company: Synthesis
44
* Author: Chen
55
* Date: 2018/06/04
66
*/
@@ -22,11 +22,12 @@
2222
using namespace caffe;
2323
using namespace cv;
2424

25-
//YOLOV3
26-
const string& model_file = "/home/nvidia/projects/caffe-yolov3/data/networks/yolov3/yolov3.prototxt";
27-
const string& weights_file = "/home/nvidia/projects/caffe-yolov3/data/networks/yolov3/yolov3.caffemodel";
25+
const int timeIters = 10;
2826

29-
const char* imgFilename = "/home/nvidia/projects/caffe-yolov3/data/images/dog.jpg";
27+
//YOLOV3
28+
const string& model_file = "/home/chen/projects/caffe-yolov3/data/yolov3/yolov3.prototxt";//modify your model file path
29+
const string& weights_file = "/home/chen/projects/caffe-yolov3/data/yolov3/yolov3.caffemodel";//modify your weights file path
30+
const char* imgFilename = "/home/chen/projects/caffe-yolov3/data/images/dog.jpg"; //modify your images file path
3031

3132
uint64_t current_timestamp() {
3233
struct timeval te;
@@ -47,7 +48,7 @@ void sig_handler(int signo)
4748

4849
int main( int argc, char** argv )
4950
{
50-
printf("detectnet-camera\n args (%i): ", argc);
51+
printf("detectnet\n args (%i): ", argc);
5152

5253
for( int i=0; i < argc; i++ )
5354
printf("%i [%s] ", i, argv[i]);
@@ -77,39 +78,48 @@ int main( int argc, char** argv )
7778

7879
int size = input_data_blobs->channels()*input_data_blobs->width()*input_data_blobs->height();
7980

80-
uint64_t beginDataTime = current_timestamp();
81-
//load image
82-
image im = load_image_color((char*)imgFilename,0,0);
83-
image sized = letterbox_image(im,input_data_blobs->width(),input_data_blobs->height());
84-
cuda_push_array(input_data_blobs->mutable_gpu_data(),sized.data,size);
85-
86-
uint64_t endDataTime = current_timestamp();
87-
88-
//YOLOV3 objection detection implementation with Caffe
89-
uint64_t beginDetectTime = current_timestamp();
90-
91-
net->Forward();
92-
93-
vector<Blob<float>*> blobs;
94-
blobs.clear();
95-
Blob<float>* out_blob1 = net->output_blobs()[1];
96-
blobs.push_back(out_blob1);
97-
Blob<float>* out_blob2 = net->output_blobs()[2];
98-
blobs.push_back(out_blob2);
99-
Blob<float>* out_blob3 = net->output_blobs()[0];
100-
blobs.push_back(out_blob3);
101-
102-
printf("output blob1 shape c= %d, h = %d, w = %d\n",out_blob1->channels(),out_blob1->height(),out_blob1->width());
103-
printf("output blob2 shape c= %d, h = %d, w = %d\n",out_blob2->channels(),out_blob2->height(),out_blob2->width());
104-
printf("output blob3 shape c= %d, h = %d, w = %d\n",out_blob3->channels(),out_blob3->height(),out_blob3->width());
105-
81+
uint64_t dataTime = 0;
82+
uint64_t networkTime = 0;
83+
image im,sized;
10684
int nboxes = 0;
107-
detection *dets = get_detections(blobs,im.w,im.h,&nboxes);
108-
109-
uint64_t endDetectTime = current_timestamp();
110-
printf("object-detection: finished processing data operation (%zu)ms\n", endDataTime - beginDataTime);
111-
printf("object-detection: finished processing yolov3 network (%zu)ms\n", endDetectTime - beginDetectTime);
112-
85+
detection *dets = NULL;
86+
for(int i=0;i<timeIters;++i){
87+
uint64_t beginDataTime = current_timestamp();
88+
//load image
89+
im = load_image_color((char*)imgFilename,0,0);
90+
sized = letterbox_image(im,input_data_blobs->width(),input_data_blobs->height());
91+
cuda_push_array(input_data_blobs->mutable_gpu_data(),sized.data,size);
92+
93+
uint64_t endDataTime = current_timestamp();
94+
dataTime += (endDataTime - beginDataTime);
95+
96+
//YOLOV3 objection detection implementation with Caffe
97+
98+
net->Forward();
99+
100+
vector<Blob<float>*> blobs;
101+
blobs.clear();
102+
Blob<float>* out_blob1 = net->output_blobs()[1];
103+
blobs.push_back(out_blob1);
104+
Blob<float>* out_blob2 = net->output_blobs()[2];
105+
blobs.push_back(out_blob2);
106+
Blob<float>* out_blob3 = net->output_blobs()[0];
107+
blobs.push_back(out_blob3);
108+
109+
//printf("output blob1 shape c= %d, h = %d, w = %d\n",out_blob1->channels(),out_blob1->height(),out_blob1->width());
110+
//printf("output blob2 shape c= %d, h = %d, w = %d\n",out_blob2->channels(),out_blob2->height(),out_blob2->width());
111+
//printf("output blob3 shape c= %d, h = %d, w = %d\n",out_blob3->channels(),out_blob3->height(),out_blob3->width());
112+
113+
//int nboxes = 0;
114+
//printf("img width =%d, height = %d\n",im.w,im.h);
115+
dets = get_detections(blobs,im.w,im.h,&nboxes);
116+
117+
uint64_t endDetectTime = current_timestamp();
118+
networkTime += (endDetectTime - endDataTime);
119+
}
120+
121+
printf("object-detection: total iters = %d done, processing data operation avergae time is (%zu)ms\n", timeIters,dataTime/timeIters);
122+
printf("object-detection: total iters = %d done, processing network yolov3 avergae time is (%zu)ms\n", timeIters,networkTime/timeIters);
113123

114124
//show detection results
115125
Mat img = imread(imgFilename);

image.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Company: Systhesis
2+
* Company: Synthesis
33
* Author: Chen
44
* Date: 2018/06/07
55
*/

yolo_layer.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Company: Systhesis
2+
* Company: Synthesis
33
* Author: Chen
44
* Date: 2018/06/04
55
*/
@@ -35,17 +35,17 @@ layer make_yolo_layer(int batch,int w,int h,int n,int total,int classes)
3535
l.biases[i] = biases[i];
3636
}
3737
l.mask = (int*)calloc(n,sizeof(int));
38-
if(l.w == 13){
38+
if(l.w == netW / 32){
3939
int j = 6;
4040
for(int i =0;i<l.n;++i)
4141
l.mask[i] = j++;
4242
}
43-
if(l.w == 26){
43+
if(l.w == netW / 16){
4444
int j = 3;
4545
for(int i =0;i<l.n;++i)
4646
l.mask[i] = j++;
4747
}
48-
if(l.w == 52){
48+
if(l.w == netW / 8){
4949
int j = 0;
5050
for(int i =0;i<l.n;++i)
5151
l.mask[i] = j++;
@@ -111,8 +111,10 @@ int yolo_num_detections(layer l,float thresh)
111111
if(l.output[obj_index] > thresh)
112112
++count;
113113
}
114+
114115
}
115116
}
117+
//printf("count = %d\n",count);
116118
return count;
117119
}
118120

yolo_layer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Company: Systhesis
2+
* Company: Synthesis
33
* Author: Chen
44
* Date: 2018/06/04
55
*/

0 commit comments

Comments
 (0)