Skip to content
Snippets Groups Projects
Commit cc7ffeb8 authored by Kentaro Wada's avatar Kentaro Wada
Browse files

Fix imagePath which should be relative to labelfile

parent 505391c0
Branches
No related tags found
No related merge requests found
...@@ -43,12 +43,12 @@ class LabelFile(object): ...@@ -43,12 +43,12 @@ class LabelFile(object):
try: try:
with open(filename, 'rb' if PY2 else 'r') as f: with open(filename, 'rb' if PY2 else 'r') as f:
data = json.load(f) data = json.load(f)
imagePath = data['imagePath']
if data['imageData'] is not None: if data['imageData'] is not None:
imageData = b64decode(data['imageData']) imageData = b64decode(data['imageData'])
else: else:
imagePath = os.path.join( # relative path from label file to relative path from cwd
os.path.dirname(filename), data['imagePath']) imagePath = os.path.join(os.path.dirname(filename),
data['imagePath'])
with open(imagePath, 'rb') as f: with open(imagePath, 'rb') as f:
imageData = f.read() imageData = f.read()
lineColor = data['lineColor'] lineColor = data['lineColor']
...@@ -57,7 +57,7 @@ class LabelFile(object): ...@@ -57,7 +57,7 @@ class LabelFile(object):
for s in data['shapes']) for s in data['shapes'])
# Only replace data after everything is loaded. # Only replace data after everything is loaded.
self.shapes = shapes self.shapes = shapes
self.imagePath = imagePath self.imagePath = data['imagePath']
self.imageData = imageData self.imageData = imageData
self.lineColor = lineColor self.lineColor = lineColor
self.fillColor = fillColor self.fillColor = fillColor
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment