mirror of
https://github.com/wassname/sloth.git
synced 2026-06-27 18:25:49 +08:00
Merge pull request #78 from neingeist/fix-relative-filenames
Add relative image filenames to the label file
This commit is contained in:
@@ -203,7 +203,6 @@ class PickleContainer(AnnotationContainer):
|
||||
"""
|
||||
Overwritten to write pickle files.
|
||||
"""
|
||||
# TODO make all image filenames relative to the label file
|
||||
f = open(fname, "wb")
|
||||
pickle.dump(annotations, f)
|
||||
|
||||
@@ -292,7 +291,6 @@ class OkapiAnnotationContainer(AnnotationContainer):
|
||||
fileitem.frames().push_back(frameitem)
|
||||
container.files().push_back(fileitem)
|
||||
|
||||
# TODO make all image filenames relative to the label file
|
||||
container.WriteToFile(fname)
|
||||
|
||||
|
||||
@@ -312,7 +310,6 @@ class JsonContainer(AnnotationContainer):
|
||||
"""
|
||||
Overwritten to write JSON files.
|
||||
"""
|
||||
# TODO make all image filenames relative to the label file
|
||||
f = open(fname, "w")
|
||||
json.dump(annotations, f, indent=4, separators=(',', ': '), sort_keys=True)
|
||||
|
||||
@@ -356,7 +353,6 @@ class YamlContainer(AnnotationContainer):
|
||||
"""
|
||||
Overwritten to write YAML files.
|
||||
"""
|
||||
# TODO make all image filenames relative to the label file
|
||||
f = open(fname, "w")
|
||||
yaml.dump(annotations, f)
|
||||
|
||||
@@ -417,8 +413,6 @@ class FeretContainer(AnnotationContainer):
|
||||
"""
|
||||
Not implemented yet.
|
||||
"""
|
||||
# TODO make sure the image paths are
|
||||
# relative to the label file's directory
|
||||
raise NotImplemented(
|
||||
"FeretContainer.serializeToFile() is not implemented yet."
|
||||
)
|
||||
|
||||
@@ -384,6 +384,9 @@ class MainWindow(QMainWindow):
|
||||
|
||||
fname = str(fname)
|
||||
|
||||
if os.path.isabs(fname):
|
||||
fname = os.path.relpath(fname, str(path))
|
||||
|
||||
for pattern in image_types:
|
||||
if fnmatch.fnmatch(fname, pattern):
|
||||
return self.labeltool.addImageFile(fname)
|
||||
|
||||
Reference in New Issue
Block a user