mirror of
https://github.com/wassname/sloth.git
synced 2026-07-10 03:15:11 +08:00
Merge branch 'master' of https://i14git.anthropomatik.kit.edu/labeltool
This commit is contained in:
@@ -6,6 +6,14 @@ try:
|
||||
import cPickle as pickle
|
||||
except:
|
||||
import pickle
|
||||
try:
|
||||
import json
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
import yaml
|
||||
except:
|
||||
pass
|
||||
|
||||
class AnnotationContainerFactory:
|
||||
def __init__(self, containers):
|
||||
@@ -119,6 +127,36 @@ class PickleContainer(AnnotationContainer):
|
||||
pickle.dump(self.annotations(), f)
|
||||
self.filename_ = fname
|
||||
|
||||
class JSONContainer(AnnotationContainer):
|
||||
"""
|
||||
Simple container which writes the annotations to disk in JSON format.
|
||||
"""
|
||||
|
||||
def load(self, fname):
|
||||
f = open(fname, "r")
|
||||
self.annotations_ = json.load(f)
|
||||
self.filename_ = fname
|
||||
|
||||
def save(self, fname):
|
||||
f = open(fname, "w")
|
||||
json.dump(self.annotations(), f, indent=4)
|
||||
self.filename_ = fname
|
||||
|
||||
class YAMLContainer(AnnotationContainer):
|
||||
"""
|
||||
Simple container which writes the annotations to disk in YAML format.
|
||||
"""
|
||||
|
||||
def load(self, fname):
|
||||
f = open(fname, "r")
|
||||
self.annotations_ = yaml.load(f)
|
||||
self.filename_ = fname
|
||||
|
||||
def save(self, fname):
|
||||
f = open(fname, "w")
|
||||
yaml.dump(self.annotations(), f, indent=4)
|
||||
self.filename_ = fname
|
||||
|
||||
class FeretContainer(AnnotationContainer):
|
||||
"""
|
||||
Container for Feret labels.
|
||||
|
||||
@@ -15,6 +15,8 @@ INSERTERS = {
|
||||
}
|
||||
|
||||
CONTAINERS = (
|
||||
('*.json': 'sloth.annotations.container.JSONContainer'),
|
||||
('*.yaml': 'sloth.annotations.container.YAMLContainer'),
|
||||
)
|
||||
|
||||
PLUGINS = (
|
||||
|
||||
Reference in New Issue
Block a user