Skip to content

Commit

Permalink
Fixed invalid path issue when loading JSON file in Windows environment (
Browse files Browse the repository at this point in the history
  • Loading branch information
CVHub520 committed Mar 26, 2024
1 parent 5b31655 commit 3707e96
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions anylabeling/views/labeling/label_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def load(self, filename):
"points"
] = utils.rectangle_from_diagonal(shape_points)

data["imagePath"] = osp.basename(data["imagePath"])
if data["imageData"] is not None:
image_data = base64.b64decode(data["imageData"])
else:
Expand Down
8 changes: 4 additions & 4 deletions anylabeling/views/labeling/label_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -1567,7 +1567,7 @@ def set_dirty(self):
label_file = osp.splitext(self.image_path)[0] + ".json"
if self.output_dir:
label_file_without_path = osp.basename(label_file)
label_file = osp.join(self.output_dir, label_file_without_path)
label_file = self.output_dir + '/' + label_file_without_path
self.save_labels(label_file)
return
self.dirty = True
Expand Down Expand Up @@ -3031,7 +3031,7 @@ def load_file(self, filename=None): # noqa: C901
if self.output_dir:
image_dir = osp.dirname(filename)
label_file_without_path = osp.basename(label_file)
label_file = osp.join(self.output_dir, label_file_without_path)
label_file = self.output_dir + '/' + label_file_without_path
if QtCore.QFile.exists(label_file) and LabelFile.is_label_file(
label_file
):
Expand Down Expand Up @@ -4637,7 +4637,7 @@ def import_dropped_image_files(self, image_files):
label_file = osp.splitext(file)[0] + ".json"
if self.output_dir:
label_file_without_path = osp.basename(label_file)
label_file = osp.join(self.output_dir, label_file_without_path)
label_file = self.output_dir + '/' + label_file_without_path
item = QtWidgets.QListWidgetItem(file)
item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)
if QtCore.QFile.exists(label_file) and LabelFile.is_label_file(
Expand Down Expand Up @@ -4670,7 +4670,7 @@ def import_image_folder(self, dirpath, pattern=None, load=True):
label_file = osp.splitext(filename)[0] + ".json"
if self.output_dir:
label_file_without_path = osp.basename(label_file)
label_file = osp.join(self.output_dir, label_file_without_path)
label_file = self.output_dir + '/' + label_file_without_path
item = QtWidgets.QListWidgetItem(filename)
item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)
if QtCore.QFile.exists(label_file) and LabelFile.is_label_file(
Expand Down

0 comments on commit 3707e96

Please sign in to comment.