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


Python DVIDNodeService.get_labels3D方法代码示例

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


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

示例1: test_labelarray_put_volumes

# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import get_labels3D [as 别名]
    def test_labelarray_put_volumes(self):
        node_service = DVIDNodeService(TEST_DVID_SERVER, self.uuid, "[email protected]", "test_labelarray_put_volumes")
        node_service.create_labelarray("test_labelarray64_put", 64)
        data = numpy.random.randint(0, 10, (128,128,128)).astype(numpy.uint64)
        assert data.flags['C_CONTIGUOUS']

        node_service.put_labelblocks3D( "test_labelarray64_put", data, (0,0,0) )
        retrieved_data = node_service.get_labels3D( "test_labelarray64_put", (30,31,32), (20,20,20) )
        assert (retrieved_data == data[20:50, 20:51, 20:52]).all()
    
        retrieved_data = node_service.get_labels3D( "test_labelarray64_put", (64,64,64), (0,0,0) )
        assert (retrieved_data == data[:64,:64,:64]).all()
    
        retrieved_data = node_service.get_labels3D( "test_labelarray64_put", (128,128,128), (0,0,0) )
        assert (retrieved_data == data).all()
开发者ID:janelia-flyem,项目名称:libdvid-cpp,代码行数:17,代码来源:test_node_service.py

示例2: get_labels2

# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import get_labels3D [as 别名]
 def get_labels2():
     # fetch second label volume
     node_service2 = DVIDNodeService(str(server2), str(uuid2))
     # retrieve data from roi start position
     return node_service2.get_labels3D(
         str(label_name2), (size1, size2, size3), (subvolume.roi[0], subvolume.roi[1], subvolume.roi[2])
     )
开发者ID:stuarteberg,项目名称:DVIDSparkServices,代码行数:9,代码来源:sparkdvid.py

示例3: test_labels_3d_volsync

# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import get_labels3D [as 别名]
 def test_labels_3d_volsync(self):
     node_service = DVIDNodeService(TEST_DVID_SERVER, self.uuid)
     node_service.create_labelblk("test_labels_3d2", "test_labels_3d2_vol")
     data = numpy.random.randint(0, 2**63-1, (128,128,128)).astype(numpy.uint64)
     node_service.put_labels3D( "test_labels_3d2", data, (0,0,0) )
     retrieved_data = node_service.get_labels3D( "test_labels_3d2", (30,30,30), (20,20,20) )
     self.assertTrue( (retrieved_data == data[20:50, 20:50, 20:50]).all() )
开发者ID:gnayuy,项目名称:libdvid-cpp,代码行数:9,代码来源:test_node_service.py

示例4: test_labelarray_put_single_block

# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import get_labels3D [as 别名]
 def test_labelarray_put_single_block(self):
     node_service = DVIDNodeService(TEST_DVID_SERVER, self.uuid, "[email protected]", "test_labelarray_put_single_block")
     node_service.create_labelarray("test_labelarray64", 64)
     data = numpy.random.randint(0, 10, (64,64,64)).astype(numpy.uint64)
     node_service.put_labelblocks3D( "test_labelarray64", data, (0,0,64) )
     retrieved_data = node_service.get_labels3D( "test_labelarray64", (64,64,64), (0,0,64) )
     assert (retrieved_data == data[:64,:64,:64]).all()
开发者ID:janelia-flyem,项目名称:libdvid-cpp,代码行数:9,代码来源:test_node_service.py

示例5: test_labels_3d

# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import get_labels3D [as 别名]
 def test_labels_3d(self):
     node_service = DVIDNodeService(TEST_DVID_SERVER, self.uuid)
     node_service.create_labelblk("test_labels_3d")
     data = numpy.random.randint(0, 2**63-1, (128,128,128)).astype(numpy.uint64)
     assert data.flags['C_CONTIGUOUS']
     node_service.put_labels3D( "test_labels_3d", data, (0,0,0) )
     retrieved_data = node_service.get_labels3D( "test_labels_3d", (30,31,32), (20,20,20) )
     self.assertTrue( (retrieved_data == data[20:50, 20:51, 20:52]).all() )
开发者ID:podgorskiy,项目名称:libdvid-cpp,代码行数:10,代码来源:test_node_service.py

示例6: get_segmask

# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import get_labels3D [as 别名]
 def get_segmask():
     node_service = DVIDNodeService(str(pdconf["dvid-server"]), str(pdconf["uuid"]))
     # retrieve data from roi start position
     return node_service.get_labels3D(
         str(pdconf["segmentation-name"]),
         (size1, size2, size3),
         (subvolume.roi[0] - border, subvolume.roi[1] - border, subvolume.roi[2] - border),
     )
开发者ID:stuarteberg,项目名称:DVIDSparkServices,代码行数:10,代码来源:Segmentor.py

示例7: get_labels

# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import get_labels3D [as 别名]
 def get_labels():
     # extract labels 64
     node_service = DVIDNodeService(str(server), str(uuid))
     # retrieve data from roi start position
     return node_service.get_labels3D(
         str(label_name),
         (size1, size2, size3),
         (subvolume.roi[0], subvolume.roi[1], subvolume.roi[2]),
         roi=str(roiname),
     )
开发者ID:stuarteberg,项目名称:DVIDSparkServices,代码行数:12,代码来源:sparkdvid.py

示例8: test_labelarray_get_volumes

# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import get_labels3D [as 别名]
    def test_labelarray_get_volumes(self):
        node_service = DVIDNodeService(TEST_DVID_SERVER, self.uuid, "[email protected]", "test_labelarray_get_volumes")
        node_service.create_labelarray("test_labelarray64_get", 64)
        data = numpy.random.randint(0, 10, (128,128,128)).astype(numpy.uint64)
        assert data.flags['C_CONTIGUOUS']

        # Try reading from empty data (before anything is loaded in the instance)
        # Should be all zeros
        retrieved_data = node_service.get_labels3D( "test_labelarray64_get", (64,128,128), (0,0,0) )
        assert (retrieved_data == 0).all()
    
        # Now populate the instance with some data
        node_service.put_labelblocks3D( "test_labelarray64_get", data, (0,0,0) )
        retrieved_data = node_service.get_labels3D( "test_labelarray64_get", (30,31,32), (20,20,20) )
        assert (retrieved_data == data[20:50, 20:51, 20:52]).all()
    
        # First with the ordinary GET
        retrieved_data = node_service.get_labels3D( "test_labelarray64_get", (64,64,64), (0,0,0) )
        assert (retrieved_data == data[:64,:64,:64]).all()
    
        retrieved_data = node_service.get_labels3D( "test_labelarray64_get", (128,128,128), (0,0,0) )
        assert (retrieved_data == data).all()

        # Again with the blockwise GET
        retrieved_data = node_service.get_labelarray_blocks3D( "test_labelarray64_get", (64,64,64), (0,0,0) )
        assert (retrieved_data == data[:64,:64,:64]).all()
    
        retrieved_data = node_service.get_labelarray_blocks3D( "test_labelarray64_get", (128,128,128), (0,0,0) )
        assert (retrieved_data == data).all()

        # Try the requests-based alternative (request raw via requests.get, then inflate afterwards)
        r = requests.get(f'http://{TEST_DVID_SERVER}/api/node/{self.uuid}/test_labelarray64_get/blocks/128_128_128/0_0_0?compression=blocks')
        r.raise_for_status()
        inflated_data = DVIDNodeService.inflate_labelarray_blocks3D_from_raw(r.content, (128, 128, 128), (0,0,0))
        assert (inflated_data == data).all()

        # What happens if we request a block that doesn't exist on the server?
        missing = node_service.get_labelarray_blocks3D( "test_labelarray64_get", (128,128,128), (1024, 1024, 1024), scale=6 )
        assert missing.shape == (128,128,128)
        assert (missing == 0).all()
开发者ID:janelia-flyem,项目名称:libdvid-cpp,代码行数:42,代码来源:test_node_service.py

示例9: getLabelImageForFrame

# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import get_labels3D [as 别名]
    def getLabelImageForFrame(self, Resource, PathInResource, timeframe):
        """
        Loads label image data from local resource file in hdf5 format.
        PathInResource provides the internal image path 
        Return numpy array of image data at timeframe.
        """

        if (self.shape == None):
            self.getImageShape(Resource, PathInResource)

        node_service = DVIDNodeService(Resource, PathInResource)
        seg_frame = np.array(node_service.get_labels3D(self._getSegmentationName(timeframe),
                            tuple(self.shape), (0,0,0))).astype(np.uint32)
        return seg_frame
开发者ID:JaimeIvanCervantes,项目名称:hytra,代码行数:16,代码来源:dvid_image_loader.py

示例10: test_labels_3d

# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import get_labels3D [as 别名]
    def test_labels_3d(self):
        node_service = DVIDNodeService(TEST_DVID_SERVER, self.uuid, "[email protected]", "test_label_app")
        node_service.create_labelblk("test_labels_3d")
        lblksize = node_service.get_blocksize("test_labels_3d")

        self.assertEqual(32, lblksize)
        
        
        node_service.create_labelblk("test_labels_3d64", "", 64)
        lblksize64 = node_service.get_blocksize("test_labels_3d64")
        self.assertEqual(64, lblksize64)
       
        data = numpy.random.randint(0, 2**63-1, (128,128,128)).astype(numpy.uint64)
        assert data.flags['C_CONTIGUOUS']
        node_service.put_labels3D( "test_labels_3d", data, (0,0,0) )
        retrieved_data = node_service.get_labels3D( "test_labels_3d", (30,31,32), (20,20,20) )
        self.assertTrue( (retrieved_data == data[20:50, 20:51, 20:52]).all() )
开发者ID:janelia-flyem,项目名称:libdvid-cpp,代码行数:19,代码来源:test_node_service.py

示例11: open

# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import get_labels3D [as 别名]
from __future__ import print_function
import sys
import json
import numpy as np
from DVIDSparkServices.reconutils.misc import compute_vi
from libdvid import DVIDNodeService

dirpath = sys.argv[1]

with open(dirpath + "/temp_data/config.json") as f:
    config = json.load(f)

node_service = DVIDNodeService(str(config['dvid-info']['dvid-server']), str(config['dvid-info']['uuid']))
test_segmentation_xyz = node_service.get_labels3D(str(config['dvid-info']['segmentation-name']), (256, 256, 256), (0,0,0))

unique_labels = np.unique(test_segmentation_xyz)
if unique_labels.max() > 1e9:
    print("DEBUG: FAIL: Watershed produced very high label values. Max was {}".format(unique_labels.max()))
    sys.exit(1)
if ((unique_labels != np.arange(1, len(unique_labels)+1)).all()): 
    print("DEBUG: FAIL: Watershed produced non-sequential label values.")
    sys.exit(1)

print("DEBUG: Watershed test passed.")
sys.exit(0)
开发者ID:stuarteberg,项目名称:DVIDSparkServices,代码行数:27,代码来源:checkoutput.py

示例12: execute

# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import get_labels3D [as 别名]

#.........这里部分代码省略.........
#             rollback_pred = True

        for iternum in range(0, num_iters):
            # it might make sense to randomly map partitions for selection
            # in case something pathological is happening -- if original partitioner
            # is randomish than this should be fine
            def subset_part(roi):
                s_id, data = roi
                if (s_id % num_iters) == iternum:
                    return True
                return False
            
            # should preserve partitioner
            distsubvolumes_part = distsubvolumes.filter(subset_part)

            # get grayscale chunks with specified overlap
            gray_chunks = self.sparkdvid_context.map_grayscale8(distsubvolumes_part,
                    self.config_data["dvid-info"]["grayscale"])


            # convert grayscale to compressed segmentation, maintain partitioner
            # save max id as well in substack info
            pred_checkpoint_dir = checkpoint_dir
            if checkpoint_dir != "":
                pred_checkpoint_dir = checkpoint_dir + "/prediter-" + str(iternum)

            # disable prediction checkpointing if rolling back at the iteration level
            # as this will cause unnecessary jobs to execute.  In principle, the
            # prediction could be rolled back as well which would only add some
            # unnecessary overhead to the per iteration rollback
            if rollback_seg:
                pred_checkpoint_dir = ""

            # small hack since segmentor is unaware for current iteration
            # perhaps just declare the segment function to have an arbitrary number of parameters
            if type(segmentor) == Segmentor:
                seg_chunks = segmentor.segment(gray_chunks, pred_checkpoint_dir, rollback_pred)
            else:
                seg_chunks = segmentor.segment(gray_chunks)

            # retrieve previously computed RDD or save current RDD
            if checkpoint_dir != "":
                seg_chunks = self.sparkdvid_context.checkpointRDD(seg_chunks, 
                        checkpoint_dir + "/segiter-" + str(iternum), rollback_seg)  

            # any forced persistence will result in costly
            # pickling, lz4 compressed numpy array should help
            seg_chunks.persist(StorageLevel.MEMORY_AND_DISK_SER)

            seg_chunks_list.append(seg_chunks)

        seg_chunks = seg_chunks_list[0]

        for iter1 in range(1, len(seg_chunks_list)):
            # ?? does this preserve the partitioner (yes, if num partitions is the same)
            # this could cause a serialization problems if there are a large number of iterations (>100)
            seg_chunks = seg_chunks.union(seg_chunks_list[iter1])
            
        # any forced persistence will result in costly
        # pickling, lz4 compressed numpy array should help
        seg_chunks.persist(StorageLevel.MEMORY_AND_DISK_SER)

        # stitch the segmentation chunks
        # (preserves initial partitioning)
        mapped_seg_chunks = segmentor.stitch(seg_chunks)
        
        # no longer need seg chunks
        seg_chunks.unpersist()

        # coalesce to fewer partitions (!!TEMPORARY SINCE THERE ARE WRITE BANDWIDTH LIMITS TO DVID)
        mapped_seg_chunks = mapped_seg_chunks.coalesce(125)

        # write data to DVID
        self.sparkdvid_context.foreach_write_labels3d(self.config_data["dvid-info"]["segmentation-name"], mapped_seg_chunks, self.config_data["dvid-info"]["roi"], self.config_data["options"]["mutateseg"])
        self.logger.write_data("Wrote DVID labels") # write to logger after spark job

        if self.config_data["options"]["debug"]:
            # grab 256 cube from ROI 
            from libdvid import DVIDNodeService
            node_service = DVIDNodeService(str(self.config_data["dvid-info"]["dvid-server"]),
                                           str(self.config_data["dvid-info"]["uuid"]))
            
            substacks, packing_factor = node_service.get_roi_partition(str(self.config_data["dvid-info"]["roi"]),
                                                                       256/self.blocksize)

            label_volume = node_service.get_labels3D( str(self.config_data["dvid-info"]["segmentation-name"]), 
                                                      (256,256,256),
                                                      (substacks[0][0], substacks[0][1], substacks[0][2]),
                                                      compress=True )
             
            # retrieve string
            from DVIDSparkServices.sparkdvid.CompressedNumpyArray import CompressedNumpyArray
            vol_compressed = CompressedNumpyArray(label_volume)
           
            # dump checksum
            import hashlib
            md5 = hashlib.md5()
            md5.update(vol_compressed.serialized_data[0])
            checksum_text = md5.hexdigest()
            print "DEBUG: ", checksum_text
开发者ID:stuarteberg,项目名称:DVIDSparkServices,代码行数:104,代码来源:CreateSegmentation.py

示例13: str

# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import get_labels3D [as 别名]
            return False, str(e)
        try:
            if isgray:
                ns.get_gray3D(name, (10,10,10), (0,0,0))
            else:
                ns.get_label3D(name, (10,10,10), (0,0,0))
        except Exception as e:
            return True, None
        return False, "data info still exists"
    bench_deletedatatype()
      
    
# load data from emdata.janelia.org 7 column medulla
ns = DVIDNodeService("emdata.janelia.org", "8225")
grayscale = ns.get_gray3D("grayscale", (128,128,128), (4800, 3000, 3500))
labels = ns.get_labels3D("groundtruth", (128,128,128), (4800, 3000, 3500))

#grayscale = ns.get_gray3D("grayscale", (32,32,32), (4800, 3000, 3500))
#labels = ns.get_labels3D("groundtruth", (32,32,32), (4800, 3000, 3500))

# run benchmarks

@benchmark
def bench_createrepo():
    """Create new dvid repo.
    """
    return createrepo()
res, uuid = bench_createrepo()

ns = DVIDNodeService(DVIDLOCATION, uuid)
ns.create_grayscale8("grayscale")
开发者ID:janelia-flyem,项目名称:dvid,代码行数:33,代码来源:testGbucket.py


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