From 89d1087d776d4a749bff22d9b6131d0d7382c11b Mon Sep 17 00:00:00 2001 From: sushidelivery Date: Fri, 12 Jan 2024 18:01:09 +0100 Subject: [PATCH 01/18] WIP-ADD: adding the label check --- include/config.hh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/include/config.hh b/include/config.hh index 4acc3d38..e082b17e 100644 --- a/include/config.hh +++ b/include/config.hh @@ -30,6 +30,8 @@ #include #include #include +#include +#include namespace ttool { @@ -341,20 +343,41 @@ namespace ttool */ ConfigData GetConfigData() { + std::vector fileNames; // Create a copy of the ConfigData object ConfigData configData = this->m_ConfigData; // Prefix the model files with the m_TToolRootPath for (auto& modelFile : configData.ModelFiles) { modelFile = std::string(m_TToolRootPath) + "/" + modelFile; + fileNames.push_back(modelFile); } // Prefix the acit files with the m_TToolRootPath for (auto& acitFile : configData.AcitFiles) { acitFile = std::string(m_TToolRootPath) + "/" + acitFile; + fileNames.push_back(acitFile); } // Prefix the classifier model path with the m_TToolRootPath configData.ClassifierModelPath = std::string(m_TToolRootPath) + "/" + configData.ClassifierModelPath; + + for (const auto& label : configData.ClassifierLabels) + { + bool labelMatches = false; + for (const auto& filePath : fileNames) + { + if (filePath.find(label) != std::string::npos) + { + labelMatches = true; + break; + } + } + + if (!labelMatches) + { + std::cout << "Label \"" << label << "\" does not match any file paths" << std::endl; + } + } return configData; } From 5f270fec330fdc4da6f549803010f8b76ad20eb2 Mon Sep 17 00:00:00 2001 From: sushidelivery Date: Mon, 15 Jan 2024 17:46:36 +0100 Subject: [PATCH 02/18] UPDATE: updated the existing code for label check --- include/config.hh | 51 ++++++++++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/include/config.hh b/include/config.hh index e082b17e..2ac85959 100644 --- a/include/config.hh +++ b/include/config.hh @@ -32,6 +32,7 @@ #include #include #include +#include namespace ttool { @@ -205,6 +206,36 @@ namespace ttool LoadConfigFile(); } + /** + * @brief Check if the labels in the config file match the file paths of model files and acit files + * + */ + + void CheckClassifierLabelsConfig() + { + std::filesystem::path rootPath(m_TToolRootPath); + std::unordered_set filePaths; + + for (const auto& modelFile : m_ConfigData.ModelFiles) { + filePaths.insert((rootPath / modelFile).string()); + } + for (const auto& acitFile : m_ConfigData.AcitFiles) { + filePaths.insert((rootPath / acitFile).string()); + } + + for (const auto& label : m_ConfigData.ClassifierLabels) { + bool labelMatches = std::any_of(filePaths.begin(), filePaths.end(), + [&label](const std::string& filePath) { + return filePath.find(label) != std::string::npos; + }); + + if (!labelMatches) { + throw std::runtime_error("Label mismatch error: Label \"" + label + "\" does not match any file paths"); + } + } + + } + /** * @brief Read the config file and set the values to the ConfigData object * @@ -247,6 +278,8 @@ namespace ttool m_ConfigData.setValue("classifierMean",classifierMean); m_ConfigData.setValue("classifierStd", classifierStd); + // check the classifier labels match + CheckClassifierLabelsConfig(); return fs.release(); } @@ -360,24 +393,6 @@ namespace ttool } // Prefix the classifier model path with the m_TToolRootPath configData.ClassifierModelPath = std::string(m_TToolRootPath) + "/" + configData.ClassifierModelPath; - - for (const auto& label : configData.ClassifierLabels) - { - bool labelMatches = false; - for (const auto& filePath : fileNames) - { - if (filePath.find(label) != std::string::npos) - { - labelMatches = true; - break; - } - } - - if (!labelMatches) - { - std::cout << "Label \"" << label << "\" does not match any file paths" << std::endl; - } - } return configData; } From f806674a861a87461563cb4de8e6df57803a3d71 Mon Sep 17 00:00:00 2001 From: sushidelivery Date: Mon, 15 Jan 2024 18:19:52 +0100 Subject: [PATCH 03/18] ADD-WIP: added acit files check --- include/config.hh | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/include/config.hh b/include/config.hh index 2ac85959..524ea9df 100644 --- a/include/config.hh +++ b/include/config.hh @@ -207,10 +207,40 @@ namespace ttool } /** - * @brief Check if the labels in the config file match the file paths of model files and acit files + * @brief Check if the ACIT files are valid * */ + void CheckAcitFiles() + { + for (const auto& acitFile : m_ConfigData.AcitFiles) { + try { + cv::FileStorage fs(acitFile, cv::FileStorage::READ); + if (!fs.isOpened()) { + std::cerr << "Could not open file: " << acitFile << std::endl; + continue; + } + + std::string acitFileName; + fs["name"] >> acitFileName; + fs.release(); + + std::filesystem::path path(acitFile); + std::string folderName = path.parent_path().filename().string(); + + if (folderName != acitFileName) { + std::cerr << "Mismatch in " << acitFile << ": Folder name (" << folderName + << ") does not match ACIT file name (" << acitFileName << ")" << std::endl; + } + } catch (const std::exception& e) { + std::cerr << "Error processing file " << acitFile << ": " << e.what() << std::endl; + } + } + } + /** + * @brief Check if the labels in the config file match the file paths of model files and acit files + * + */ void CheckClassifierLabelsConfig() { std::filesystem::path rootPath(m_TToolRootPath); @@ -279,6 +309,7 @@ namespace ttool m_ConfigData.setValue("classifierStd", classifierStd); // check the classifier labels match + CheckAcitFiles(); CheckClassifierLabelsConfig(); return fs.release(); } From 6d123a71c3775c9035d7daf2450255f8640395ec Mon Sep 17 00:00:00 2001 From: sushidelivery Date: Tue, 16 Jan 2024 17:30:58 +0100 Subject: [PATCH 04/18] UPDATE: updated the check acit files --- include/config.hh | 59 ++++++++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 24 deletions(-) diff --git a/include/config.hh b/include/config.hh index 524ea9df..5daef88d 100644 --- a/include/config.hh +++ b/include/config.hh @@ -33,6 +33,7 @@ #include #include #include +#include namespace ttool { @@ -207,32 +208,44 @@ namespace ttool } /** - * @brief Check if the ACIT files are valid + * @brief Check if the acit names match the folder names * */ - void CheckAcitFiles() + void CheckAcitFiles(const std::string& TToolRootPath) { - for (const auto& acitFile : m_ConfigData.AcitFiles) { - try { - cv::FileStorage fs(acitFile, cv::FileStorage::READ); - if (!fs.isOpened()) { - std::cerr << "Could not open file: " << acitFile << std::endl; - continue; - } - std::string acitFileName; - fs["name"] >> acitFileName; - fs.release(); + std::filesystem::path rootPath = std::filesystem::current_path() / TToolRootPath; - std::filesystem::path path(acitFile); - std::string folderName = path.parent_path().filename().string(); + std::string line; + std::string toolheadNameTagStart = " filePaths; for (const auto& modelFile : m_ConfigData.ModelFiles) { - filePaths.insert((rootPath / modelFile).string()); + filePaths.insert( modelFile); } for (const auto& acitFile : m_ConfigData.AcitFiles) { - filePaths.insert((rootPath / acitFile).string()); + filePaths.insert(acitFile); } for (const auto& label : m_ConfigData.ClassifierLabels) { @@ -309,12 +321,11 @@ namespace ttool m_ConfigData.setValue("classifierStd", classifierStd); // check the classifier labels match - CheckAcitFiles(); CheckClassifierLabelsConfig(); return fs.release(); } - /** + /** * @brief Print the config file to the console * */ From e65b13b252d18839321e408c2ca024ee236f83ee Mon Sep 17 00:00:00 2001 From: sushidelivery Date: Tue, 16 Jan 2024 17:31:35 +0100 Subject: [PATCH 05/18] ADD: added check acit files into ttool constructor --- include/ttool.hh | 1 + 1 file changed, 1 insertion(+) diff --git a/include/ttool.hh b/include/ttool.hh index 97277abd..3bc7b495 100644 --- a/include/ttool.hh +++ b/include/ttool.hh @@ -50,6 +50,7 @@ namespace ttool TTool(std::string ttoolRootPath, std::string configFile, std::string cameraCalibFile) { InitializeConfig(ttoolRootPath, configFile); + m_ConfigPtr->CheckAcitFiles(ttoolRootPath); m_CameraCalibFile = cameraCalibFile; From 36e1f86726c8937115b9165d52eeadd4908cf87b Mon Sep 17 00:00:00 2001 From: sushidelivery Date: Fri, 12 Jan 2024 13:34:15 +0100 Subject: [PATCH 06/18] REFACTOR: changed the format of label map and renamed it --- ai/torchscripts/labels.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 ai/torchscripts/labels.txt diff --git a/ai/torchscripts/labels.txt b/ai/torchscripts/labels.txt new file mode 100644 index 00000000..78939c45 --- /dev/null +++ b/ai/torchscripts/labels.txt @@ -0,0 +1,11 @@ +auger_drill_bit_34_235 +chain_swordsaw_blade_200 +spade_drill_bit_25_150 +brad_point_drill_bit_20_150 +chain_saw_blade_f_250 +self_feeding_bit_40_90 +circular_saw_blade_makita_190 +self_feeding_bit_50_90 +twist_drill_bit_32_165 +saber_saw_blade_makita_t_300 +auger_drill_bit_20_235 \ No newline at end of file From a1103bebb6945b074bdaad669e71e73466c54437 Mon Sep 17 00:00:00 2001 From: sushidelivery Date: Fri, 12 Jan 2024 15:13:37 +0100 Subject: [PATCH 07/18] ADD: added classifier cmake for labels --- CMakeLists.txt | 1 + cmake/classifier.cmake | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 cmake/classifier.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 9978676e..5d7d610c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,7 @@ set(__TTOOL_CONFIG_PATH__ "${CMAKE_CURRENT_SOURCE_DIR}/assets/config.yml") set(__TTOOL_ROOT_PATH__ "${CMAKE_CURRENT_SOURCE_DIR}") include(cmake/dataset.cmake) +include(cmake/classifier.cmake) file(GLOB glsl_SOURCES src/shader/*.glsl) source_group("shader" FILES ${glsl_SOURCES}) diff --git a/cmake/classifier.cmake b/cmake/classifier.cmake new file mode 100644 index 00000000..7b7bba64 --- /dev/null +++ b/cmake/classifier.cmake @@ -0,0 +1,8 @@ + +if(UNIX AND NOT APPLE) + set(LOADER_CMD "${PROJECT_SOURCE_DIR}/util/load_labels_2_config.py") + execute_process( + COMMAND chmod +x ${LOADER_CMD} + COMMAND ${LOADER_CMD} -s ${CMAKE_CURRENT_SOURCE_DIR} -c ${__TTOOL_CONFIG_PATH__} + ) +endif() From ce6a3045caf5e0af85dd0f80eea0cc1cb94ebf3b Mon Sep 17 00:00:00 2001 From: sushidelivery Date: Fri, 12 Jan 2024 15:14:24 +0100 Subject: [PATCH 08/18] ADD: added python script to load the labels to config --- util/load_labels_2_config.py | 86 ++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100755 util/load_labels_2_config.py diff --git a/util/load_labels_2_config.py b/util/load_labels_2_config.py new file mode 100755 index 00000000..96ed49d3 --- /dev/null +++ b/util/load_labels_2_config.py @@ -0,0 +1,86 @@ +#!/usr/bin/env python3 + +import os +import sys +import argparse + + +def _log_process(msg): + print("[PROCESS:util/load_dataset_2_config.py] {}".format(msg)) +def _log_info(msg): + print("\033[95m[INFO:util/load_dataset_2_config.py] {}\033[00m".format(msg)) +def _log_error(msg): + print("\033[91m[ERROR:util/load_dataset_2_config.py] {}\033[00m".format(msg)) +def _log_warning(msg): + print("\033[93m[WARNING:util/load_dataset_2_config.py] {}\033[00m".format(msg)) +def _log_success(msg): + print("\033[92m[SUCCESS:util/load_dataset_2_config.py] {}\033[00m".format(msg)) + + +def main(source_path: str, config_path: str) -> None: + _log_process("Loading the labels file...") + + try: + classifier_labels_path_key: str = 'classifierLabelsPath:' + classifier_labels: str = 'classifierLabels:' + with open(config_path, "r") as f: + config_lines = f.readlines() + + labels_path = None + for line in config_lines: + if classifier_labels_path_key in line: + _, labels_path = line.split(':', 1) + labels_path = labels_path.strip().strip('\"') + break + + if not labels_path: + raise ValueError(f"{classifier_labels_path_key} not found in the configuration file") + + with open(os.path.join(source_path, labels_path), "r") as f: + labels = [line.strip() for line in f if line.strip()] + + start_idx = -1 + end_idx = -1 + for i, line in enumerate(config_lines): + if line.strip() == classifier_labels: + start_idx = i + end_idx = start_idx + 1 + while end_idx < len(config_lines) and config_lines[end_idx].strip().startswith('-'): + end_idx += 1 + break + + new_labels_section = [f'{classifier_labels}\n'] + \ + [f" - \"{label}\"\n" for label in labels] + + if start_idx != -1: + config_lines = config_lines[:start_idx] + new_labels_section + config_lines[end_idx:] + else: + config_lines.extend(['\n'] + new_labels_section) + + with open(config_path, "w") as f: + f.writelines(config_lines) + + except FileNotFoundError as e:( + _log_error(f"Error: File not found - {e}")) + except ValueError as e:( + _log_error(f"Error: {e}")) + except Exception as e:( + _log_error(f"An unexpected error occurred: {e}")) + + + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description="Load the labels into the TTool config.yml file.") + parser.add_argument("-s", "--source", help="Path to the project source directory.") + parser.add_argument("-c", "--config", help="Path to the TTool config.yml file.") + + args = parser.parse_args() + + if not os.path.isdir(args.source): + _log_error("The path to the project source directory is not valid.") + sys.exit() + if not os.path.isfile(args.config): + _log_error("The path to the config file is not valid.") + sys.exit() + + main(source_path=args.source, config_path=args.config) From 96611d4f1c3586335d0c78a3456a9206b0d7e609 Mon Sep 17 00:00:00 2001 From: sushidelivery Date: Fri, 12 Jan 2024 15:15:33 +0100 Subject: [PATCH 09/18] ADD: added classifier label file path --- assets/config.yml | 118 +++++++++++++++++++++++++--------------------- 1 file changed, 64 insertions(+), 54 deletions(-) diff --git a/assets/config.yml b/assets/config.yml index 56359de9..413e97ab 100644 --- a/assets/config.yml +++ b/assets/config.yml @@ -6,10 +6,8 @@ histOffset: 100 histRad: 40 searchRad: 25 classifierModelPath: "ai/torchscripts/efficientnet.pt" +classifierLabelsPath: "ai/torchscripts/labels.txt" -# The order of classifierLabels is determined by the classifier during training -# the classifier once trained output a .pt (weights) and a .txt file for the order -# see the .txt file in ai/torchscripts to see the order to recreate here below classifierLabels: - "auger_drill_bit_34_235" - "chain_swordsaw_blade_200" @@ -22,61 +20,73 @@ classifierLabels: - "twist_drill_bit_32_165" - "saber_saw_blade_makita_t_300" - "auger_drill_bit_20_235" + classifierImageSize: 384 classifierImageChannels: 3 classifierMean: - - 0.485 - - 0.456 - - 0.406 + - 0.485 + - 0.456 + - 0.406 classifierStd: - - 0.229 - - 0.224 - - 0.225 + - 0.229 + - 0.224 + - 0.225 groundTruthPoses: - - [ -7.73640037e-01, 4.15423065e-01, -4.78431463e-01, -5.23223341e-01, - -8.44716668e-01, 1.12603128e-01, -3.57363552e-01, 3.37440640e-01, - 8.70876431e-01, 0., 0., 2.20000029e-01 ] - - [ 9.50834990e-01, 2.37247661e-01, -1.99040413e-01, 2.44926587e-02, - -6.98316872e-01, -7.15365469e-01, -3.08712870e-01, 6.75321281e-01, - -6.69801235e-01, -2.26506889e-02, 2.32661795e-02, 1.76990986e-01 ] - - [ 9.84866619e-01, -4.03894819e-02, 1.68541461e-01, -1.62771076e-01, - 1.18437737e-01, 9.79524612e-01, -5.95245212e-02, -9.92136419e-01, - 1.10068895e-01, 0., 0., 1.39999986e-01 ] - - [ -5.42542815e-01, 8.39947045e-01, -1.11253709e-02, 5.06054997e-01, - 3.16238910e-01, -8.02426398e-01, -6.70481861e-01, -4.40981954e-01, - -5.96643448e-01, -1.26680557e-03, 4.37926613e-02, 2.52720535e-01 ] - - [ 8.19440663e-01, 5.45331001e-01, -1.76395491e-01, 1.42224208e-01, - -4.91604596e-01, -8.59123707e-01, -5.55223823e-01, 6.78913355e-01, - -4.80406970e-01, 1.67723373e-02, 2.61279512e-02, 1.92897707e-01 ] - - [ 9.53821719e-01, 2.47012243e-01, 1.70877323e-01, 2.97439009e-01, - -6.97671890e-01, -6.51752949e-01, -4.17775214e-02, 6.72493160e-01, - -7.38922477e-01, -2.76020560e-02, 3.86725217e-02, 1.33150429e-01 ] - - [ -8.07440519e-01, 4.48605478e-01, -3.83105516e-01, -5.85106611e-01, - -6.91857159e-01, 4.23044086e-01, -7.52737448e-02, 5.65754294e-01, - 8.21124077e-01, -5.82594611e-03, 2.99568456e-02, 1.46538332e-01 ] - - [ -8.28246951e-01, 2.30366185e-01, 5.10807216e-01, 2.39123389e-01, - -6.79095149e-01, 6.94000125e-01, 5.06760836e-01, 6.96950197e-01, - 5.07382751e-01, -2.56683957e-02, 2.72371043e-02, 1.72090665e-01 ] - - [ -9.45800602e-01, 2.85116285e-01, 1.55401364e-01, -8.82991254e-02, - -6.86366022e-01, 7.21853733e-01, 3.12482119e-01, 6.69024289e-01, - 6.74335539e-01, -2.39054989e-02, 4.05580476e-02, 1.38083279e-01 ] + - [ -7.73640037e-01, 4.15423065e-01, -4.78431463e-01, -5.23223341e-01, + -8.44716668e-01, 1.12603128e-01, -3.57363552e-01, 3.37440640e-01, + 8.70876431e-01, 0., 0., 2.20000029e-01 ] + - [ 9.50834990e-01, 2.37247661e-01, -1.99040413e-01, 2.44926587e-02, + -6.98316872e-01, -7.15365469e-01, -3.08712870e-01, 6.75321281e-01, + -6.69801235e-01, -2.26506889e-02, 2.32661795e-02, 1.76990986e-01 ] + - [ 9.84866619e-01, -4.03894819e-02, 1.68541461e-01, -1.62771076e-01, + 1.18437737e-01, 9.79524612e-01, -5.95245212e-02, -9.92136419e-01, + 1.10068895e-01, 0., 0., 1.39999986e-01 ] + - [ 9.84866619e-01, -4.03894819e-02, 1.68541461e-01, -1.62771076e-01, + 1.18437737e-01, 9.79524612e-01, -5.95245212e-02, -9.92136419e-01, + 1.10068895e-01, 0., 0., 1.39999986e-01 ] + - [ 8.19440663e-01, 5.45331001e-01, -1.76395491e-01, 1.42224208e-01, + -4.91604596e-01, -8.59123707e-01, -5.55223823e-01, 6.78913355e-01, + -4.80406970e-01, 1.67723373e-02, 2.61279512e-02, 1.92897707e-01 ] + - [ 9.84866619e-01, -4.03894819e-02, 1.68541461e-01, -1.62771076e-01, + 1.18437737e-01, 9.79524612e-01, -5.95245212e-02, -9.92136419e-01, + 1.10068895e-01, 0., 0., 1.39999986e-01 ] + - [ 8.19440663e-01, 5.45331001e-01, -1.76395491e-01, 1.42224208e-01, + -4.91604596e-01, -8.59123707e-01, -5.55223823e-01, 6.78913355e-01, + -4.80406970e-01, 1.67723373e-02, 2.61279512e-02, 1.92897707e-01 ] + + - [ 9.53821719e-01, 2.47012243e-01, 1.70877323e-01, 2.97439009e-01, + -6.97671890e-01, -6.51752949e-01, -4.17775214e-02, 6.72493160e-01, + -7.38922477e-01, -2.76020560e-02, 3.86725217e-02, 1.33150429e-01 ] + - [ -8.07440519e-01, 4.48605478e-01, -3.83105516e-01, -5.85106611e-01, + -6.91857159e-01, 4.23044086e-01, -7.52737448e-02, 5.65754294e-01, + 8.21124077e-01, -5.82594611e-03, 2.99568456e-02, 1.46538332e-01 ] + - [ -8.28246951e-01, 2.30366185e-01, 5.10807216e-01, 2.39123389e-01, + -6.79095149e-01, 6.94000125e-01, 5.06760836e-01, 6.96950197e-01, + 5.07382751e-01, -2.56683957e-02, 2.72371043e-02, 1.72090665e-01 ] + - [ -9.45800602e-01, 2.85116285e-01, 1.55401364e-01, -8.82991254e-02, + -6.86366022e-01, 7.21853733e-01, 3.12482119e-01, 6.69024289e-01, + 6.74335539e-01, -2.39054989e-02, 4.05580476e-02, 1.38083279e-01 ] modelFiles: - - "assets/toolheads/saber_saw_blade_makita_t_300/model.obj" - - "assets/toolheads/twist_drill_bit_32_165/model.obj" - - "assets/toolheads/circular_saw_blade_makita_190/model.obj" - - "assets/toolheads/chain_saw_blade_f_250/model.obj" - - "assets/toolheads/auger_drill_bit_20_235/model.obj" - - "assets/toolheads/brad_point_drill_bit_20_150/model.obj" - - "assets/toolheads/spade_drill_bit_25_150/model.obj" - - "assets/toolheads/self_feeding_bit_40_90/model.obj" - - "assets/toolheads/self_feeding_bit_50_90/model.obj" + - "/assets/toolheads/saber_saw_blade_makita_t_300/model.obj" + - "/assets/toolheads/twist_drill_bit_32_165/model.obj" + - "/assets/toolheads/circular_saw_blade_makita_190/model.obj" + - "/assets/toolheads/chain_saw_blade_f_250/model.obj" + - "/assets/toolheads/auger_drill_bit_20_235/model.obj" + - "/assets/toolheads/chain_swordsaw_blade_200/model.obj" + - "/assets/toolheads/auger_drill_bit_34_235/model.obj" + - "/assets/toolheads/brad_point_drill_bit_20_150/model.obj" + - "/assets/toolheads/spade_drill_bit_25_150/model.obj" + - "/assets/toolheads/self_feeding_bit_40_90/model.obj" + - "/assets/toolheads/self_feeding_bit_50_90/model.obj" acitFiles: - - "assets/toolheads/saber_saw_blade_makita_t_300/metadata.acit" - - "assets/toolheads/twist_drill_bit_32_165/metadata.acit" - - "assets/toolheads/circular_saw_blade_makita_190/metadata.acit" - - "assets/toolheads/chain_saw_blade_f_250/metadata.acit" - - "assets/toolheads/auger_drill_bit_20_235/metadata.acit" - - "assets/toolheads/brad_point_drill_bit_20_150/metadata.acit" - - "assets/toolheads/spade_drill_bit_25_150/metadata.acit" - - "assets/toolheads/self_feeding_bit_40_90/metadata.acit" - - "assets/toolheads/self_feeding_bit_50_90/metadata.acit" + - "/assets/toolheads/saber_saw_blade_makita_t_300/metadata.acit" + - "/assets/toolheads/twist_drill_bit_32_165/metadata.acit" + - "/assets/toolheads/circular_saw_blade_makita_190/metadata.acit" + - "/assets/toolheads/chain_saw_blade_f_250/metadata.acit" + - "/assets/toolheads/auger_drill_bit_20_235/metadata.acit" + - "/assets/toolheads/chain_swordsaw_blade_200/metadata.acit" + - "/assets/toolheads/auger_drill_bit_34_235/metadata.acit" + - "/assets/toolheads/brad_point_drill_bit_20_150/metadata.acit" + - "/assets/toolheads/spade_drill_bit_25_150/metadata.acit" + - "/assets/toolheads/self_feeding_bit_40_90/metadata.acit" + - "/assets/toolheads/self_feeding_bit_50_90/metadata.acit" From 86423b48388bca79a59c63835001658dc089e3af Mon Sep 17 00:00:00 2001 From: sushidelivery Date: Fri, 12 Jan 2024 15:24:54 +0100 Subject: [PATCH 10/18] REMOVE: removed the label map file --- ai/torchscripts/label_map.txt | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 ai/torchscripts/label_map.txt diff --git a/ai/torchscripts/label_map.txt b/ai/torchscripts/label_map.txt deleted file mode 100644 index 55bdf464..00000000 --- a/ai/torchscripts/label_map.txt +++ /dev/null @@ -1,11 +0,0 @@ -auger_drill_bit_34_235: 0 -chain_swordsaw_blade_200: 1 -spade_drill_bit_25_150: 2 -brad_point_drill_bit_20_150: 3 -chain_saw_blade_f_250: 4 -self_feeding_bit_40_90: 5 -circular_saw_blade_makita_190: 6 -self_feeding_bit_50_90: 7 -twist_drill_bit_32_165: 8 -saber_saw_blade_makita_t_300: 9 -auger_drill_bit_20_235: 10 \ No newline at end of file From 81400467746a2e9d80e55f4a1e84a3ad1b3fedbc Mon Sep 17 00:00:00 2001 From: sushidelivery Date: Fri, 12 Jan 2024 15:40:10 +0100 Subject: [PATCH 11/18] REFACTOR: updated the label --- ai/torchscripts/labels.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ai/torchscripts/labels.txt b/ai/torchscripts/labels.txt index 78939c45..f95eeb9b 100644 --- a/ai/torchscripts/labels.txt +++ b/ai/torchscripts/labels.txt @@ -1,4 +1,4 @@ -auger_drill_bit_34_235 +auger_drill_bit_35_235 chain_swordsaw_blade_200 spade_drill_bit_25_150 brad_point_drill_bit_20_150 From 337ccfb702766ae599f8b13844340642df0590da Mon Sep 17 00:00:00 2001 From: sushidelivery Date: Mon, 15 Jan 2024 14:38:40 +0100 Subject: [PATCH 12/18] ADD: added the success log --- util/load_labels_2_config.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/util/load_labels_2_config.py b/util/load_labels_2_config.py index 96ed49d3..80c187ba 100755 --- a/util/load_labels_2_config.py +++ b/util/load_labels_2_config.py @@ -60,6 +60,8 @@ def main(source_path: str, config_path: str) -> None: with open(config_path, "w") as f: f.writelines(config_lines) + _log_success("The labels were successfully loaded into the assets/config.yml file.") + except FileNotFoundError as e:( _log_error(f"Error: File not found - {e}")) except ValueError as e:( From 011bc63bae5826a289fab88fefd3efc5ad5315e5 Mon Sep 17 00:00:00 2001 From: sushidelivery Date: Mon, 15 Jan 2024 14:42:51 +0100 Subject: [PATCH 13/18] FIX: fixed the indentation --- util/load_labels_2_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/load_labels_2_config.py b/util/load_labels_2_config.py index 80c187ba..8c8839da 100755 --- a/util/load_labels_2_config.py +++ b/util/load_labels_2_config.py @@ -50,7 +50,7 @@ def main(source_path: str, config_path: str) -> None: break new_labels_section = [f'{classifier_labels}\n'] + \ - [f" - \"{label}\"\n" for label in labels] + [f" - \"{label}\"\n" for label in labels] if start_idx != -1: config_lines = config_lines[:start_idx] + new_labels_section + config_lines[end_idx:] From 60386abf5d9d6ee66690bc7e9d92970b6350030c Mon Sep 17 00:00:00 2001 From: sushidelivery Date: Mon, 15 Jan 2024 15:44:28 +0100 Subject: [PATCH 14/18] FIX: fixed the config file indentation --- assets/config.yml | 78 +++++++++++++++++++++++------------------------ 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/assets/config.yml b/assets/config.yml index 413e97ab..cdb9b5ed 100644 --- a/assets/config.yml +++ b/assets/config.yml @@ -24,69 +24,69 @@ classifierLabels: classifierImageSize: 384 classifierImageChannels: 3 classifierMean: - - 0.485 - - 0.456 - - 0.406 + - 0.485 + - 0.456 + - 0.406 classifierStd: - - 0.229 - - 0.224 - - 0.225 + - 0.229 + - 0.224 + - 0.225 groundTruthPoses: - - [ -7.73640037e-01, 4.15423065e-01, -4.78431463e-01, -5.23223341e-01, + - [ -7.73640037e-01, 4.15423065e-01, -4.78431463e-01, -5.23223341e-01, -8.44716668e-01, 1.12603128e-01, -3.57363552e-01, 3.37440640e-01, 8.70876431e-01, 0., 0., 2.20000029e-01 ] - - [ 9.50834990e-01, 2.37247661e-01, -1.99040413e-01, 2.44926587e-02, + - [ 9.50834990e-01, 2.37247661e-01, -1.99040413e-01, 2.44926587e-02, -6.98316872e-01, -7.15365469e-01, -3.08712870e-01, 6.75321281e-01, -6.69801235e-01, -2.26506889e-02, 2.32661795e-02, 1.76990986e-01 ] - - [ 9.84866619e-01, -4.03894819e-02, 1.68541461e-01, -1.62771076e-01, + - [ 9.84866619e-01, -4.03894819e-02, 1.68541461e-01, -1.62771076e-01, 1.18437737e-01, 9.79524612e-01, -5.95245212e-02, -9.92136419e-01, 1.10068895e-01, 0., 0., 1.39999986e-01 ] - - [ 9.84866619e-01, -4.03894819e-02, 1.68541461e-01, -1.62771076e-01, + - [ 9.84866619e-01, -4.03894819e-02, 1.68541461e-01, -1.62771076e-01, 1.18437737e-01, 9.79524612e-01, -5.95245212e-02, -9.92136419e-01, 1.10068895e-01, 0., 0., 1.39999986e-01 ] - - [ 8.19440663e-01, 5.45331001e-01, -1.76395491e-01, 1.42224208e-01, + - [ 8.19440663e-01, 5.45331001e-01, -1.76395491e-01, 1.42224208e-01, -4.91604596e-01, -8.59123707e-01, -5.55223823e-01, 6.78913355e-01, -4.80406970e-01, 1.67723373e-02, 2.61279512e-02, 1.92897707e-01 ] - - [ 9.84866619e-01, -4.03894819e-02, 1.68541461e-01, -1.62771076e-01, + - [ 9.84866619e-01, -4.03894819e-02, 1.68541461e-01, -1.62771076e-01, 1.18437737e-01, 9.79524612e-01, -5.95245212e-02, -9.92136419e-01, 1.10068895e-01, 0., 0., 1.39999986e-01 ] - - [ 8.19440663e-01, 5.45331001e-01, -1.76395491e-01, 1.42224208e-01, + - [ 8.19440663e-01, 5.45331001e-01, -1.76395491e-01, 1.42224208e-01, -4.91604596e-01, -8.59123707e-01, -5.55223823e-01, 6.78913355e-01, -4.80406970e-01, 1.67723373e-02, 2.61279512e-02, 1.92897707e-01 ] - - [ 9.53821719e-01, 2.47012243e-01, 1.70877323e-01, 2.97439009e-01, + - [ 9.53821719e-01, 2.47012243e-01, 1.70877323e-01, 2.97439009e-01, -6.97671890e-01, -6.51752949e-01, -4.17775214e-02, 6.72493160e-01, -7.38922477e-01, -2.76020560e-02, 3.86725217e-02, 1.33150429e-01 ] - - [ -8.07440519e-01, 4.48605478e-01, -3.83105516e-01, -5.85106611e-01, + - [ -8.07440519e-01, 4.48605478e-01, -3.83105516e-01, -5.85106611e-01, -6.91857159e-01, 4.23044086e-01, -7.52737448e-02, 5.65754294e-01, 8.21124077e-01, -5.82594611e-03, 2.99568456e-02, 1.46538332e-01 ] - - [ -8.28246951e-01, 2.30366185e-01, 5.10807216e-01, 2.39123389e-01, + - [ -8.28246951e-01, 2.30366185e-01, 5.10807216e-01, 2.39123389e-01, -6.79095149e-01, 6.94000125e-01, 5.06760836e-01, 6.96950197e-01, 5.07382751e-01, -2.56683957e-02, 2.72371043e-02, 1.72090665e-01 ] - - [ -9.45800602e-01, 2.85116285e-01, 1.55401364e-01, -8.82991254e-02, + - [ -9.45800602e-01, 2.85116285e-01, 1.55401364e-01, -8.82991254e-02, -6.86366022e-01, 7.21853733e-01, 3.12482119e-01, 6.69024289e-01, 6.74335539e-01, -2.39054989e-02, 4.05580476e-02, 1.38083279e-01 ] modelFiles: - - "/assets/toolheads/saber_saw_blade_makita_t_300/model.obj" - - "/assets/toolheads/twist_drill_bit_32_165/model.obj" - - "/assets/toolheads/circular_saw_blade_makita_190/model.obj" - - "/assets/toolheads/chain_saw_blade_f_250/model.obj" - - "/assets/toolheads/auger_drill_bit_20_235/model.obj" - - "/assets/toolheads/chain_swordsaw_blade_200/model.obj" - - "/assets/toolheads/auger_drill_bit_34_235/model.obj" - - "/assets/toolheads/brad_point_drill_bit_20_150/model.obj" - - "/assets/toolheads/spade_drill_bit_25_150/model.obj" - - "/assets/toolheads/self_feeding_bit_40_90/model.obj" - - "/assets/toolheads/self_feeding_bit_50_90/model.obj" + - "/assets/toolheads/saber_saw_blade_makita_t_300/model.obj" + - "/assets/toolheads/twist_drill_bit_32_165/model.obj" + - "/assets/toolheads/circular_saw_blade_makita_190/model.obj" + - "/assets/toolheads/chain_saw_blade_f_250/model.obj" + - "/assets/toolheads/auger_drill_bit_20_235/model.obj" + - "/assets/toolheads/chain_swordsaw_blade_200/model.obj" + - "/assets/toolheads/auger_drill_bit_34_235/model.obj" + - "/assets/toolheads/brad_point_drill_bit_20_150/model.obj" + - "/assets/toolheads/spade_drill_bit_25_150/model.obj" + - "/assets/toolheads/self_feeding_bit_40_90/model.obj" + - "/assets/toolheads/self_feeding_bit_50_90/model.obj" acitFiles: - - "/assets/toolheads/saber_saw_blade_makita_t_300/metadata.acit" - - "/assets/toolheads/twist_drill_bit_32_165/metadata.acit" - - "/assets/toolheads/circular_saw_blade_makita_190/metadata.acit" - - "/assets/toolheads/chain_saw_blade_f_250/metadata.acit" - - "/assets/toolheads/auger_drill_bit_20_235/metadata.acit" - - "/assets/toolheads/chain_swordsaw_blade_200/metadata.acit" - - "/assets/toolheads/auger_drill_bit_34_235/metadata.acit" - - "/assets/toolheads/brad_point_drill_bit_20_150/metadata.acit" - - "/assets/toolheads/spade_drill_bit_25_150/metadata.acit" - - "/assets/toolheads/self_feeding_bit_40_90/metadata.acit" - - "/assets/toolheads/self_feeding_bit_50_90/metadata.acit" + - "/assets/toolheads/saber_saw_blade_makita_t_300/metadata.acit" + - "/assets/toolheads/twist_drill_bit_32_165/metadata.acit" + - "/assets/toolheads/circular_saw_blade_makita_190/metadata.acit" + - "/assets/toolheads/chain_saw_blade_f_250/metadata.acit" + - "/assets/toolheads/auger_drill_bit_20_235/metadata.acit" + - "/assets/toolheads/chain_swordsaw_blade_200/metadata.acit" + - "/assets/toolheads/auger_drill_bit_34_235/metadata.acit" + - "/assets/toolheads/brad_point_drill_bit_20_150/metadata.acit" + - "/assets/toolheads/spade_drill_bit_25_150/metadata.acit" + - "/assets/toolheads/self_feeding_bit_40_90/metadata.acit" + - "/assets/toolheads/self_feeding_bit_50_90/metadata.acit" From 15d42352799f6cf1f0a93d84cb1c83c9256f0ea9 Mon Sep 17 00:00:00 2001 From: sushidelivery Date: Mon, 15 Jan 2024 15:44:52 +0100 Subject: [PATCH 15/18] FIX: fixed the label --- ai/torchscripts/labels.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ai/torchscripts/labels.txt b/ai/torchscripts/labels.txt index f95eeb9b..78939c45 100644 --- a/ai/torchscripts/labels.txt +++ b/ai/torchscripts/labels.txt @@ -1,4 +1,4 @@ -auger_drill_bit_35_235 +auger_drill_bit_34_235 chain_swordsaw_blade_200 spade_drill_bit_25_150 brad_point_drill_bit_20_150 From 5210283f13f33d92df67939b3bbc8f600b5330fc Mon Sep 17 00:00:00 2001 From: sushidelivery Date: Mon, 15 Jan 2024 15:45:29 +0100 Subject: [PATCH 16/18] FIX: fixed the indentation for labels --- util/load_labels_2_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/load_labels_2_config.py b/util/load_labels_2_config.py index 8c8839da..80c187ba 100755 --- a/util/load_labels_2_config.py +++ b/util/load_labels_2_config.py @@ -50,7 +50,7 @@ def main(source_path: str, config_path: str) -> None: break new_labels_section = [f'{classifier_labels}\n'] + \ - [f" - \"{label}\"\n" for label in labels] + [f" - \"{label}\"\n" for label in labels] if start_idx != -1: config_lines = config_lines[:start_idx] + new_labels_section + config_lines[end_idx:] From 344160c43b9f899992a506eed4298c15c9220d7a Mon Sep 17 00:00:00 2001 From: Andrea Settimi Date: Fri, 19 Jan 2024 14:29:21 +0100 Subject: [PATCH 17/18] FIX: set zenodo dataset bleeding edge by default --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5d7d610c..87a496e0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.21) project(TTool VERSION "0.1.0" LANGUAGES CXX) # zenodo direct doi link (to change if dataset us updated) -set(TTOOL_DSET_DOI "https://zenodo.org/record/10014284" CACHE INTERNAL "") +set(TTOOL_DSET_DOI "https://zenodo.org/doi/10.5281/zenodo.7956930" CACHE INTERNAL "") # Not sur it is a good idea, it will fail on installed version (NR) set(__TTOOL_CONFIG_PATH__ "${CMAKE_CURRENT_SOURCE_DIR}/assets/config.yml") From 3fb440483c6818c9926edd11799ef9fc75406554 Mon Sep 17 00:00:00 2001 From: sushidelivery Date: Fri, 19 Jan 2024 15:34:38 +0100 Subject: [PATCH 18/18] UPDATE: moved the check function into initilize config --- include/config.hh | 2 -- include/ttool.hh | 3 ++- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/include/config.hh b/include/config.hh index 5daef88d..223f7b70 100644 --- a/include/config.hh +++ b/include/config.hh @@ -320,8 +320,6 @@ namespace ttool m_ConfigData.setValue("classifierMean",classifierMean); m_ConfigData.setValue("classifierStd", classifierStd); - // check the classifier labels match - CheckClassifierLabelsConfig(); return fs.release(); } diff --git a/include/ttool.hh b/include/ttool.hh index 3bc7b495..547faac4 100644 --- a/include/ttool.hh +++ b/include/ttool.hh @@ -50,7 +50,6 @@ namespace ttool TTool(std::string ttoolRootPath, std::string configFile, std::string cameraCalibFile) { InitializeConfig(ttoolRootPath, configFile); - m_ConfigPtr->CheckAcitFiles(ttoolRootPath); m_CameraCalibFile = cameraCalibFile; @@ -436,6 +435,8 @@ namespace ttool m_ConfigFile = configFile; m_ConfigPtr = std::make_shared(configFile); m_ConfigPtr->SetTToolRootPath(ttoolRootPath); + m_ConfigPtr->CheckAcitFiles(ttoolRootPath); + m_ConfigPtr->CheckClassifierLabelsConfig(); } /**