From 047ec10e0d4549282437e608c85470062b7ab2dc Mon Sep 17 00:00:00 2001 From: hardik22317 Date: Fri, 25 Jun 2021 15:27:52 +0530 Subject: [PATCH] composeee added --- config.yaml | 15 +++++++++++++++ config/config.yaml | 12 ++++++------ docker/Dockerfile | 2 +- docker/docker-compose.yml | 20 ++++++++++++++++++++ handler.cpp | 38 +++++++++++++++++++++++++++++++------- run.sh | 2 ++ 6 files changed, 75 insertions(+), 14 deletions(-) create mode 100644 config.yaml create mode 100644 docker/docker-compose.yml diff --git a/config.yaml b/config.yaml new file mode 100644 index 0000000..b86db07 --- /dev/null +++ b/config.yaml @@ -0,0 +1,15 @@ +classes1 : 39 #number of classes +conf_thresh1 : 0.3 #threshold on the condifence of the bbox +net1 : ../demo/yolo4x_fp16.rt +classes2 : 39 #number of classes +conf_thresh2 : 0.3 #threshold on the condifence of the bbox +net2 : ../demo/yolo4x_fp16.rt +classes3 : 39 #number of classes +conf_thresh3 : 0.3 #threshold on the condifence of the bbox +net3 : ../demo/yolo4x_fp16.rt +classes4 : 39 #number of classes +conf_thresh4 : 0.3 #threshold on the condifence of the bbox +net4 : ../demo/yolo4x_fp16.rt +classes5 : 39 #number of classes +conf_thresh5 : 0.3 #threshold on the condifence of the bbox +net5 : ../demo/yolo4x_fp16.rt diff --git a/config/config.yaml b/config/config.yaml index 0a7b143..b86db07 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -1,15 +1,15 @@ -classes1 : 13 #number of classes +classes1 : 39 #number of classes conf_thresh1 : 0.3 #threshold on the condifence of the bbox net1 : ../demo/yolo4x_fp16.rt -classes2 : 13 #number of classes +classes2 : 39 #number of classes conf_thresh2 : 0.3 #threshold on the condifence of the bbox net2 : ../demo/yolo4x_fp16.rt -classes3 : 13 #number of classes +classes3 : 39 #number of classes conf_thresh3 : 0.3 #threshold on the condifence of the bbox net3 : ../demo/yolo4x_fp16.rt -classes4 : 13 #number of classes +classes4 : 39 #number of classes conf_thresh4 : 0.3 #threshold on the condifence of the bbox net4 : ../demo/yolo4x_fp16.rt -classes5 : 13 #number of classes +classes5 : 39 #number of classes conf_thresh5 : 0.3 #threshold on the condifence of the bbox -net5 : ../demo/yolo4x_fp16.rt \ No newline at end of file +net5 : ../demo/yolo4x_fp16.rt diff --git a/docker/Dockerfile b/docker/Dockerfile index 4cea43d..39b77cb 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -28,4 +28,4 @@ COPY --chown=baggageai:baggageai . files/ WORKDIR /home/baggageai/files RUN chmod 777 run.sh -#ENTRYPOINT ["./run.sh"] +ENTRYPOINT ["./run.sh"] diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 0000000..f9df105 --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,20 @@ +version: '3.7' +services: + baggageai-server-tkdnn: + image: baggageai:server-tkdnn + ports: + - 8080:8080 + volumes: + - BAI_logs:/home/baggageai/log + environment: + - NVIDIA_VISIBLE_DEVICES=all + restart: on-failure + deploy: + replicas: 1 #Keep replicas 1 only for GPU + restart_policy: + condition: on-failure + max_attempts: 3 + +volumes: + BAI_logs: + external: true diff --git a/handler.cpp b/handler.cpp index 8188dbb..7a5a3d7 100644 --- a/handler.cpp +++ b/handler.cpp @@ -114,10 +114,10 @@ cv::Mat image_to_mat(image img) int w=0; int channels; const char *config_filename = "config/config.yaml"; - const char * net1="config/yolo4x_fp16.rt"; - const char * net2="config/yolo4x_fp16.rt"; - const char * net3="config/yolo4x2_fp16.rt"; - const char * net4="config/yolo4x2_fp16.rt"; + const char * net1="config/yolo4x_fp32.rt"; + const char * net2="config/yolo4x_fp32.rt"; + const char * net3="config/yolo4x_fp32.rt"; + const char * net4="config/yolo4x_fp32.rt"; const char * net5="config/yolo4x_fp16.rt"; int classes1 , classes2 , classes3 , classes4 , classes5,len; char * img_data; @@ -132,6 +132,8 @@ cv::Mat image_to_mat(image img) tk::dnn::DetectionNN *detNN3; tk::dnn::Yolo3Detection yolo4; tk::dnn::DetectionNN *detNN4; + tk::dnn::Yolo3Detection yolo5; + tk::dnn::DetectionNN *detNN5; unsigned char * sockData; std::vector batch_frames; @@ -140,11 +142,13 @@ cv::Mat image_to_mat(image img) std::vector classesNames2; std::vector classesNames3; std::vector classesNames4; + std::vector classesNames5; std::vector images; std::vector detected_bbox1; std::vector detected_bbox2; std::vector detected_bbox3; std::vector detected_bbox4; + std::vector detected_bbox5; //read parametersi handler::handler(utility::string_t url):m_listener(url) { @@ -171,6 +175,9 @@ string name_from_path(string path) detNN4 = &yolo4; detNN4->init(net4, classes4, 1, conf_thresh4); classesNames4=detNN4-> classesNames; + detNN5 = &yolo5; + detNN5->init(net5, classes5, 1, conf_thresh5); + classesNames5=detNN5-> classesNames; return;} @@ -193,9 +200,9 @@ string name_from_path(string path) ustring = {v.begin(),v.end()}; len = ustring.size(); }).wait(); - //printSize(ustring); - BOOST_LOG_TRIVIAL(info) << "[" << name_from_path(string(__FILE__)) << " " << __LINE__ << "] " << "Detection Started"; unsigned char *idata; +try { //printSize(ustring); + BOOST_LOG_TRIVIAL(info) << "[" << name_from_path(string(__FILE__)) << " " << __LINE__ << "] " << "Detection Started"; sockData = (unsigned char *)ustring.c_str(); idata = stbi_load_from_memory(sockData, len, &w, &h, &channels, 0); im = load_image_file(idata, channels, 0, 0, w, h); @@ -275,7 +282,24 @@ string name_from_path(string path) detection["prob"] = json::value::number(d4.prob); jsonArray.push_back(detection); } - try{ + detected_bbox5.clear(); + batch_dnn_input.clear(); + batch_dnn_input.push_back(frame.clone()); + detNN5->update(batch_dnn_input,1); + detected_bbox5 = detNN5->detected; + + for(auto d5:detected_bbox5){ + std::cout<<"5"<<" "<