当前位置: 首页>>代码示例>>Python>>正文


Python pickle.Unpickler方法代码示例

本文整理汇总了Python中pickle.Unpickler方法的典型用法代码示例。如果您正苦于以下问题:Python pickle.Unpickler方法的具体用法?Python pickle.Unpickler怎么用?Python pickle.Unpickler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pickle的用法示例。


在下文中一共展示了pickle.Unpickler方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: inflate

# 需要导入模块: import pickle [as 别名]
# 或者: from pickle import Unpickler [as 别名]
def inflate(opt = None):
	if opt is not None:
		model3d = HourglassNet3D(opt.nChannels, opt.nStack, opt.nModules, opt.numReductions, ref.nJoints)
		Inflate.nChannels = opt.nChannels
		Inflate.nStack = opt.nStack
		Inflate.nModules = opt.nModules
		Inflate.nRegFrames = opt.nRegFrames
		Inflate.nJoints = ref.nJoints
	else :
		model3d = HourglassNet3D()
	pickle.Unpickler = partial(pickle.Unpickler, encoding="latin1")
	pickle.load = partial(pickle.load, encoding="latin1")
	if opt is not None:
		model = torch.load(opt.Model2D)
	else:
		model = torch.load('models/hgreg-3d.pth') #, map_location=lambda storage, loc: storage)

	Inflate.inflateHourglassNet(model3d, model)

	torch.save(model3d,open('inflatedModel.pth','wb'))

	return model3d 
开发者ID:Naman-ntc,项目名称:3D-HourGlass-Network,代码行数:24,代码来源:inflateScript.py

示例2: meta_validate

# 需要导入模块: import pickle [as 别名]
# 或者: from pickle import Unpickler [as 别名]
def meta_validate(shacl_graph, inference='rdfs', **kwargs):
    shacl_shacl_graph = meta_validate.shacl_shacl_graph
    if shacl_shacl_graph is None:
        from os import path
        import pickle
        import sys
        if getattr( sys, 'frozen', False ) :
                # runs in a pyinstaller bundle
                here_dir = sys._MEIPASS
                pickle_file = path.join(here_dir, "shacl-shacl.pickle")
        else :
                here_dir = path.dirname(__file__)
                pickle_file = path.join(here_dir, "shacl-shacl.pickle")
        with open(pickle_file, 'rb') as shacl_pickle:
            u = pickle.Unpickler(shacl_pickle, fix_imports=False)
            shacl_shacl_store = u.load()
        shacl_shacl_graph = rdflib.Graph(store=shacl_shacl_store, identifier="http://www.w3.org/ns/shacl-shacl")
        meta_validate.shacl_shacl_graph = shacl_shacl_graph
    shacl_graph = load_from_source(shacl_graph, rdf_format=kwargs.pop('shacl_graph_format', None),
                                   multigraph=True)
    _ = kwargs.pop('meta_shacl', None)
    return validate(shacl_graph, shacl_graph=shacl_shacl_graph, inference=inference, **kwargs) 
开发者ID:RDFLib,项目名称:pySHACL,代码行数:24,代码来源:validate.py

示例3: load

# 需要导入模块: import pickle [as 别名]
# 或者: from pickle import Unpickler [as 别名]
def load(f, persistent_load=PersistentNdarrayLoad):
    """Load a file that was dumped to a zip file.

    :param f: The file handle to the zip file to load the object from.
    :type f: file

    :param persistent_load: The persistent loading function to use for
        unpickling. This must be compatible with the `persisten_id` function
        used when pickling.
    :type persistent_load: callable, optional

    .. versionadded:: 0.8
    """
    with closing(zipfile.ZipFile(f, 'r')) as zip_file:
        p = pickle.Unpickler(BytesIO(zip_file.open('pkl').read()))
        p.persistent_load = persistent_load(zip_file)
        return p.load() 
开发者ID:muhanzhang,项目名称:D-VAE,代码行数:19,代码来源:pkl_utils.py

示例4: __init__

# 需要导入模块: import pickle [as 别名]
# 或者: from pickle import Unpickler [as 别名]
def __init__(self, file: BinaryIO, stop: int=-1, start: int =0, ids: Iterable = None):
        """

        :param file:
        :param start: unpickle objects starting from index start
        :param stop: unpickle objects ending with index stop
        :param ids: unpickle objects with indexes in ids
        """
        if ids is None:
            ids = []
        self.file = file
        self.p = pickle.Unpickler(file)
        self.c = 0
        self.stop = stop
        self.start = start
        self.ids = set(ids) 
开发者ID:kwrobel-nlp,项目名称:krnnt,代码行数:18,代码来源:serial_pickle.py

示例5: getClient

# 需要导入模块: import pickle [as 别名]
# 或者: from pickle import Unpickler [as 别名]
def getClient(
        cls, servers, debug=0, pickleProtocol=0,
        pickler=pickle.Pickler, unpickler=pickle.Unpickler,
        pload=None, pid=None
    ):

        if cls.allowTestCache:
            return TestClient(
                servers, debug=debug,
                pickleProtocol=pickleProtocol, pickler=pickler,
                unpickler=unpickler, pload=pload, pid=pid)
        elif config.Memcached.Pools.Default.ClientEnabled:
            return Client(
                servers, debug=debug, pickleProtocol=pickleProtocol,
                pickler=pickler, unpickler=unpickler, pload=pload, pid=pid)
        else:
            return None 
开发者ID:apple,项目名称:ccs-calendarserver,代码行数:19,代码来源:memcacheclient.py

示例6: loads

# 需要导入模块: import pickle [as 别名]
# 或者: from pickle import Unpickler [as 别名]
def loads(data, from_module=None):
    up = pickle.Unpickler(StringIO(data))
    def find_global(module, cls):
        if module == "copy_reg" and cls == "_reconstructor":
            return copy_reg._reconstructor
        if module == "__builtin__":
            return getattr(__builtins__, cls)
        if from_module is not None:
            return getattr(from_module, cls)
        return globals()[cls]
    up.find_global = find_global
    return up.load() 
开发者ID:blackberry,项目名称:ALF,代码行数:14,代码来源:_qemu.py

示例7: inflate

# 需要导入模块: import pickle [as 别名]
# 或者: from pickle import Unpickler [as 别名]
def inflate(opt = None):
	if opt is not None:
		model3d = Pose3D(opt.nChannels, opt.nStack, opt.nModules, opt.numReductions, opt.nRegModules, opt.nRegFrames, ref.nJoints, ref.temporal)
		Inflate.nChannels = opt.nChannels
		Inflate.nStack = opt.nStack
		Inflate.nModules = opt.nModules
		Inflate.nRegFrames = opt.nRegFrames
		Inflate.nJoints = ref.nJoints
		Inflate.scheme = opt.scheme
		Inflate.mult = opt.mult
	else :
		opt = opts().parse()
		Inflate.nChannels = opt.nChannels
		Inflate.nStack = opt.nStack
		Inflate.nModules = opt.nModules
		Inflate.nRegFrames = opt.nRegFrames
		Inflate.nJoints = ref.nJoints
		Inflate.scheme = opt.scheme
		model3d = Pose3D(opt.nChannels, opt.nStack, opt.nModules, opt.numReductions, opt.nRegModules, opt.nRegFrames, ref.nJoints, ref.temporal)
	pickle.Unpickler = partial(pickle.Unpickler, encoding="latin1")
	pickle.load = partial(pickle.load, encoding="latin1")
	if opt is not None:
		model = torch.load(opt.Model2D)
	else:
		model = torch.load('models/xingy.pth') #, map_location=lambda storage, loc: storage)

	Inflate.inflatePose3D(model3d, model)

	torch.save(model3d,open('inflatedModel.pth','wb'))

	return model3d


#inflate() 
开发者ID:Naman-ntc,项目名称:3D-HourGlass-Network,代码行数:36,代码来源:inflateScript.py

示例8: find_class

# 需要导入模块: import pickle [as 别名]
# 或者: from pickle import Unpickler [as 别名]
def find_class(self, module, name):
            # override superclass
            key = (module, name)
            module, name = _class_locations_map.get(key, key)
            return super(Unpickler, self).find_class(module, name) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:7,代码来源:pickle_compat.py

示例9: load

# 需要导入模块: import pickle [as 别名]
# 或者: from pickle import Unpickler [as 别名]
def load(fh, encoding=None, compat=False, is_verbose=False):
    """load a pickle, with a provided encoding

    if compat is True:
       fake the old class hierarchy
       if it works, then return the new type objects

    Parameters
    ----------
    fh : a filelike object
    encoding : an optional encoding
    compat : provide Series compatibility mode, boolean, default False
    is_verbose : show exception output
    """

    try:
        fh.seek(0)
        if encoding is not None:
            up = Unpickler(fh, encoding=encoding)
        else:
            up = Unpickler(fh)
        up.is_verbose = is_verbose

        return up.load()
    except (ValueError, TypeError):
        raise 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:28,代码来源:pickle_compat.py

示例10: RMUserData_convertFromSQLite

# 需要导入模块: import pickle [as 别名]
# 或者: from pickle import Unpickler [as 别名]
def RMUserData_convertFromSQLite(data):
    if data == None:
        return None

    inputStream = StringIO(data)
    unpickler = pickle.Unpickler(inputStream)
    return unpickler.load() 
开发者ID:sprinkler,项目名称:rainmachine-developer-resources,代码行数:9,代码来源:rmParserUserData.py

示例11: RMParserParams_convertFromSQLite

# 需要导入模块: import pickle [as 别名]
# 或者: from pickle import Unpickler [as 别名]
def RMParserParams_convertFromSQLite(data):
    if data == None:
        return None

    inputStream = StringIO(data)
    unpickler = pickle.Unpickler(inputStream)
    return unpickler.load() 
开发者ID:sprinkler,项目名称:rainmachine-developer-resources,代码行数:9,代码来源:rmParserParams.py

示例12: SafeUnpickler

# 需要导入模块: import pickle [as 别名]
# 或者: from pickle import Unpickler [as 别名]
def SafeUnpickler(data):
    """An unpickler for serialized tuple/lists/strings etc.

    Does not support recovering instances.
    """
    unpickler = pickle.Unpickler(io.StringIO(data))
    unpickler.find_global = None

    return unpickler.load() 
开发者ID:google,项目名称:rekall,代码行数:11,代码来源:utils.py

示例13: RestrictedPickler

# 需要导入模块: import pickle [as 别名]
# 或者: from pickle import Unpickler [as 别名]
def RestrictedPickler(raw):
    if six.PY3:
        return RestrictedUnpickler(io.BytesIO(utils.SmartStr(raw)))

    unpickler = pickle.Unpickler(io.BytesIO(utils.SmartStr(raw)))
    unpickler.find_global = None
    return unpickler 
开发者ID:google,项目名称:rekall,代码行数:9,代码来源:cache.py

示例14: __getitem__

# 需要导入模块: import pickle [as 别名]
# 或者: from pickle import Unpickler [as 别名]
def __getitem__(self, key):
        try:
            value = self.cache[key]
        except KeyError:
            f = StringIO(self.dict[key])
            value = Unpickler(f).load()
            if self.writeback:
                self.cache[key] = value
        return value 
开发者ID:glmcdona,项目名称:meddle,代码行数:11,代码来源:shelve.py

示例15: set_location

# 需要导入模块: import pickle [as 别名]
# 或者: from pickle import Unpickler [as 别名]
def set_location(self, key):
        (key, value) = self.dict.set_location(key)
        f = StringIO(value)
        return (key, Unpickler(f).load()) 
开发者ID:glmcdona,项目名称:meddle,代码行数:6,代码来源:shelve.py


注:本文中的pickle.Unpickler方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。