Skip to content

Commit e37cdce

Browse files
authored
ML: export_image_annotations_to_yolo_dataset: continue, but log errors, even when there are copy errors. (#871)
1 parent ae03749 commit e37cdce

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

SerialPrograms/Source/ML/DataLabeling/ML_AnnotationIO.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ void export_image_annotations_to_yolo_dataset(
193193
fs::create_directories(target_label_folder);
194194

195195
std::set<std::string> missing_labels;
196+
bool copy_error = false;
196197
for(size_t i = 0; i < image_paths.size(); i++){
197198
const auto& image_path = image_paths[i];
198199
const fs::path image_file(image_path);
@@ -209,13 +210,13 @@ void export_image_annotations_to_yolo_dataset(
209210
try{
210211
fs::copy_file(image_file, target_image_file);
211212
}catch (fs::filesystem_error&){
212-
QMessageBox box;
213-
box.critical(nullptr, "Cannot Copy File",
214-
QString::fromStdString(
215-
"Cannot copy from " + image_file.string() + " to " + target_image_file.string() +
216-
". Probably permission issue, source image is broken or target image path already exists due to image folder having same image filenames"
217-
));
218-
return;
213+
std::string message = "Cannot copy from " + image_file.string() + " to " + target_image_file.string() +
214+
". Probably permission issue, source image is broken or target image path already exists due to image folder having same image filenames";
215+
std::cerr << message << std::endl;
216+
copy_error = true;
217+
// QMessageBox box;
218+
// box.critical(nullptr, "Cannot Copy File", QString::fromStdString(message));
219+
// return;
219220
}
220221

221222
std::string json_content;
@@ -289,6 +290,12 @@ void export_image_annotations_to_yolo_dataset(
289290
}
290291
}
291292

293+
if (copy_error){
294+
QMessageBox box;
295+
box.critical(nullptr, "Cannot Copy File", "There was an issue with copying at least one file. See the logs for more details.");
296+
return;
297+
}
298+
292299
cout << "Found labels -> count: " << endl;
293300
for(const auto& p : label_counts){
294301
cout << "- " << p.first << ": " << p.second << endl;

0 commit comments

Comments
 (0)