mirror of
https://github.com/wassname/sloth.git
synced 2026-07-23 13:10:07 +08:00
implement PickleContainer
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
import os
|
||||
import fnmatch
|
||||
from core.exceptions import ImproperlyConfigured
|
||||
try:
|
||||
import cPickle as pickle
|
||||
except:
|
||||
import pickle
|
||||
|
||||
class AnnotationContainerFactory:
|
||||
def __init__(self, containers):
|
||||
@@ -95,3 +99,18 @@ class AnnotationContainer:
|
||||
num += len(frame['annotations'])
|
||||
return num
|
||||
|
||||
class PickleContainer(AnnotationContainer):
|
||||
"""
|
||||
Simple container which just pickles the annotations to disk.
|
||||
"""
|
||||
|
||||
def load(self, fname):
|
||||
f = open(fname, "rb")
|
||||
self.annotations_ = pickle.load(f)
|
||||
self.filename_ = fname
|
||||
|
||||
def save(self, fname):
|
||||
f = open(fname, "wb")
|
||||
pickle.dump(self.annotations(), f)
|
||||
self.filename_ = fname
|
||||
|
||||
|
||||
Reference in New Issue
Block a user