diff --git a/SerialPrograms/Source/ML/Programs/ML_LabelImages.cpp b/SerialPrograms/Source/ML/Programs/ML_LabelImages.cpp index a9035eb67d..20a1cdacd2 100644 --- a/SerialPrograms/Source/ML/Programs/ML_LabelImages.cpp +++ b/SerialPrograms/Source/ML/Programs/ML_LabelImages.cpp @@ -181,10 +181,10 @@ void LabelImages::load_image_related_data(const std::string& image_path, size_t // see if we can load the previously created labels const std::string anno_filename = std::filesystem::path(image_path).filename().replace_extension(".json").string(); + const std::string image_folder_path = std::filesystem::path(image_path).parent_path().string() + "/"; - // ensure the folder exists - std::filesystem::create_directory(ML_ANNOTATION_PATH()); - m_annotation_file_path = ML_ANNOTATION_PATH() + anno_filename; + // std::filesystem::create_directory(ML_ANNOTATION_PATH()); + m_annotation_file_path = image_folder_path + anno_filename; // ML_ANNOTATION_PATH() + anno_filename; if (!std::filesystem::exists(m_annotation_file_path)){ cout << "Annotataion output path, " << m_annotation_file_path << " does not exist yet" << endl; return; @@ -641,7 +641,7 @@ std::pair LabelImages::pixel_to_float(size_t x, size_t y) const{ void LabelImages::export_to_yolov5_dataset(const std::string& image_folder_path, const std::string& dataset_path){ m_yolo_config_file_path = dataset_path; - export_image_annotations_to_yolo_dataset(image_folder_path, ML_ANNOTATION_PATH(), dataset_path); + export_image_annotations_to_yolo_dataset(image_folder_path, image_folder_path, dataset_path); // image_folder_path, ML_ANNOTATION_PATH(), dataset_path); } diff --git a/SerialPrograms/Source/ML/Programs/ML_LabelImages.h b/SerialPrograms/Source/ML/Programs/ML_LabelImages.h index ca5607dbe2..41318c4c8c 100644 --- a/SerialPrograms/Source/ML/Programs/ML_LabelImages.h +++ b/SerialPrograms/Source/ML/Programs/ML_LabelImages.h @@ -64,7 +64,7 @@ class LabelImages : public PanelInstance, public ConfigOption::Listener { // Load image related data: // - Image SAM embedding data file, which has the same file path but with a name suffix ".embedding" - // - Existing annotation file, which is stored in a pre-defined ML_ANNOTATION_PATH() and with the same filename as + // - Existing annotation file, which is stored in the same folder as the image and with the same filename as // the image but with name extension replaced to be ".json". void load_image_related_data(const std::string& image_path, const size_t source_image_width, const size_t source_image_height); diff --git a/SerialPrograms/Source/ML/Programs/ML_LabelImagesWidget.cpp b/SerialPrograms/Source/ML/Programs/ML_LabelImagesWidget.cpp index 5249dc734d..b567289711 100644 --- a/SerialPrograms/Source/ML/Programs/ML_LabelImagesWidget.cpp +++ b/SerialPrograms/Source/ML/Programs/ML_LabelImagesWidget.cpp @@ -151,8 +151,9 @@ LabelImages_Widget::LabelImages_Widget( this->m_program.save_annotation_to_file(); // ensure the folder exists - std::filesystem::create_directory(ML_ANNOTATION_PATH()); - QDesktopServices::openUrl(QUrl(QString::fromStdString("file:///" + ML_ANNOTATION_PATH()))); + // std::filesystem::create_directory(ML_ANNOTATION_PATH()); + // QDesktopServices::openUrl(QUrl(QString::fromStdString("file:///" + ML_ANNOTATION_PATH()))); + QDesktopServices::openUrl(QUrl(QString::fromStdString("file:///" + m_image_display_widget->image_folder_path()))); }); connect(save_anno_button, &QPushButton::clicked, this, [this](bool){ this->m_program.save_annotation_to_file();