Skip to content

Commit f4176ac

Browse files
jw098Gin890
authored andcommitted
ML: Move data annotation file to the same folder as the image files
1 parent 7e7f015 commit f4176ac

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

SerialPrograms/Source/ML/Programs/ML_LabelImages.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@ void LabelImages::load_image_related_data(const std::string& image_path, size_t
183183
const std::string anno_filename = std::filesystem::path(image_path).filename().replace_extension(".json").string();
184184

185185
// ensure the folder exists
186-
std::filesystem::create_directory(ML_ANNOTATION_PATH());
187-
m_annotation_file_path = ML_ANNOTATION_PATH() + anno_filename;
186+
// std::filesystem::create_directory(ML_ANNOTATION_PATH());
187+
m_annotation_file_path = image_path + anno_filename; // ML_ANNOTATION_PATH() + anno_filename;
188188
if (!std::filesystem::exists(m_annotation_file_path)){
189189
cout << "Annotataion output path, " << m_annotation_file_path << " does not exist yet" << endl;
190190
return;
@@ -641,7 +641,7 @@ std::pair<double, double> LabelImages::pixel_to_float(size_t x, size_t y) const{
641641
void LabelImages::export_to_yolov5_dataset(const std::string& image_folder_path, const std::string& dataset_path){
642642
m_yolo_config_file_path = dataset_path;
643643

644-
export_image_annotations_to_yolo_dataset(image_folder_path, ML_ANNOTATION_PATH(), dataset_path);
644+
export_image_annotations_to_yolo_dataset(image_folder_path, image_folder_path, dataset_path); // image_folder_path, ML_ANNOTATION_PATH(), dataset_path);
645645
}
646646

647647

SerialPrograms/Source/ML/Programs/ML_LabelImages.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class LabelImages : public PanelInstance, public ConfigOption::Listener {
6464

6565
// Load image related data:
6666
// - Image SAM embedding data file, which has the same file path but with a name suffix ".embedding"
67-
// - Existing annotation file, which is stored in a pre-defined ML_ANNOTATION_PATH() and with the same filename as
67+
// - Existing annotation file, which is stored in the same folder as the image and with the same filename as
6868
// the image but with name extension replaced to be ".json".
6969
void load_image_related_data(const std::string& image_path, const size_t source_image_width, const size_t source_image_height);
7070

SerialPrograms/Source/ML/Programs/ML_LabelImagesWidget.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,9 @@ LabelImages_Widget::LabelImages_Widget(
151151
this->m_program.save_annotation_to_file();
152152

153153
// ensure the folder exists
154-
std::filesystem::create_directory(ML_ANNOTATION_PATH());
155-
QDesktopServices::openUrl(QUrl(QString::fromStdString("file:///" + ML_ANNOTATION_PATH())));
154+
// std::filesystem::create_directory(ML_ANNOTATION_PATH());
155+
// QDesktopServices::openUrl(QUrl(QString::fromStdString("file:///" + ML_ANNOTATION_PATH())));
156+
QDesktopServices::openUrl(QUrl(QString::fromStdString("file:///" + m_image_display_widget->image_folder_path())));
156157
});
157158
connect(save_anno_button, &QPushButton::clicked, this, [this](bool){
158159
this->m_program.save_annotation_to_file();

0 commit comments

Comments
 (0)