[Application] bugfix for YOLO version 2
authorhyunil park <hyunil46.park@samsung.com>
Mon, 18 Sep 2023 08:15:03 +0000 (17:15 +0900)
committerJijoong Moon <jijoong.moon@samsung.com>
Mon, 18 Sep 2023 15:07:35 +0000 (00:07 +0900)
Training does not proceed because the layer names are different.

- reorg layer name is changed from reorg to reorg_layer

Signed-off-by: hyunil park <hyunil46.park@samsung.com>
Applications/YOLO/jni/main.cpp
Applications/YOLO/jni/reorg_layer.h

index 2d1af0c7cfb90032e5dff09acc7d1dfb85695611..bc3985adbd1fd80b12d0b40e7a890e30f26bbf62 100644 (file)
@@ -45,7 +45,7 @@ const unsigned int BATCH_SIZE = 4;
 const unsigned int EPOCHS = 3;
 const char *TRAIN_DIR_PATH = "/TRAIN_DIR/";
 const char *VALIDATION_DIR_PATH = "/VALID_DIR/";
-const std::string MODEL_INIT_BIN_PATH = "/home/user/MODEL_INIT_BIN_PATH.bin";
+// const std::string MODEL_INIT_BIN_PATH = "/home/user/MODEL_INIT_BIN_PATH.bin";
 
 int trainData_cb(float **input, float **label, bool *last, void *user_data) {
   auto data = reinterpret_cast<nntrainer::util::DirDataLoader *>(user_data);
@@ -215,8 +215,9 @@ ModelHandle YOLO() {
 
   blocks.push_back(yoloBlock("conv_b", "conv13", 64, 1, false));
 
-  blocks.push_back({createLayer("reorg", {withKey("name", "re_organization"),
-                                          withKey("input_layers", "conv_b")})});
+  blocks.push_back(
+    {createLayer("reorg_layer", {withKey("name", "re_organization"),
+                                 withKey("input_layers", "conv_b")})});
 
   blocks.push_back(
     {createLayer("concat", {withKey("name", "concat"),
@@ -277,25 +278,6 @@ int main(int argc, char *argv[]) {
   std::cout << "started computation at " << std::ctime(&start_time)
             << std::endl;
 
-  auto &app_context = nntrainer::AppContext::Global();
-
-  try {
-    app_context.registerFactory(nntrainer::createLayer<custom::ReorgLayer>);
-  } catch (std::invalid_argument &e) {
-    std::cerr << "failed to register reorg layer, reason: " << e.what()
-              << std::endl;
-    return 1;
-  }
-
-  try {
-    app_context.registerFactory(
-      nntrainer::createLayer<custom::YoloV2LossLayer>);
-  } catch (std::invalid_argument &e) {
-    std::cerr << "failed to register loss layer, reason: " << e.what()
-              << std::endl;
-    return 1;
-  }
-
   // set training config and print it
   std::cout << "batch_size: " << BATCH_SIZE << " epochs: " << EPOCHS
             << std::endl;
@@ -315,6 +297,7 @@ int main(int argc, char *argv[]) {
     // compile and initialize model
     model->compile();
     model->initialize();
+    model->save("./yolov2.ini", ml::train::ModelFormat::MODEL_FORMAT_INI);
     // model->load(MODEL_INIT_BIN_PATH);
 
     // create train and validation data
index 5d9f78b5e1b73e5b6f08279c2e321cf37b5a0b3d..9a7c0f2d982cb4a5967b55d59fa4a6b1504ba586 100644 (file)
@@ -75,7 +75,7 @@ public:
    */
   void setProperty(const std::vector<std::string> &values) override{};
 
-  inline static const std::string type = "reorg";
+  inline static const std::string type = "reorg_layer";
 };
 
 } // namespace custom