Fix incorrect path handling (#731)
* Fix incorrect save dir path handling for ML format. Save dir path was split by incorrect os.dependent separator '/' which was the cause of labels being saved to parent folder. * Implement path normalization for command arguments. Renamed 'predefined_classes_file' parameter to 'class_file'.
This commit is contained in:
@@ -97,7 +97,7 @@ class CreateMLReader:
|
||||
self.json_path = json_path
|
||||
self.shapes = []
|
||||
self.verified = False
|
||||
self.filename = file_path.split("/")[-1:][0]
|
||||
self.filename = os.path.basename(file_path)
|
||||
try:
|
||||
self.parse_json()
|
||||
except ValueError:
|
||||
|
||||
+2
-5
@@ -39,18 +39,15 @@ class LabelFile(object):
|
||||
self.verified = False
|
||||
|
||||
def save_create_ml_format(self, filename, shapes, image_path, image_data, class_list, line_color=None, fill_color=None, database_src=None):
|
||||
img_folder_path = os.path.dirname(image_path)
|
||||
img_folder_name = os.path.split(img_folder_path)[-1]
|
||||
img_folder_name = os.path.basename(os.path.dirname(image_path))
|
||||
img_file_name = os.path.basename(image_path)
|
||||
output_file_path = "/".join(filename.split("/")[:-1])
|
||||
output_file = output_file_path + "/" + img_folder_name + JSON_EXT
|
||||
|
||||
image = QImage()
|
||||
image.load(image_path)
|
||||
image_shape = [image.height(), image.width(),
|
||||
1 if image.isGrayscale() else 3]
|
||||
writer = CreateMLWriter(img_folder_name, img_file_name,
|
||||
image_shape, shapes, output_file, local_img_path=image_path)
|
||||
image_shape, shapes, filename, local_img_path=image_path)
|
||||
writer.verified = self.verified
|
||||
writer.write()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user