本文整理汇总了Python中libdvid.DVIDNodeService.create_labelblk方法的典型用法代码示例。如果您正苦于以下问题:Python DVIDNodeService.create_labelblk方法的具体用法?Python DVIDNodeService.create_labelblk怎么用?Python DVIDNodeService.create_labelblk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类libdvid.DVIDNodeService
的用法示例。
在下文中一共展示了DVIDNodeService.create_labelblk方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_labels_3d_volsync
# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import create_labelblk [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() )
示例2: test_labels_3d
# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import create_labelblk [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() )
示例3: test_labels_3d
# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import create_labelblk [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() )
示例4: foreach_write_labels3d
# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import create_labelblk [as 别名]
def foreach_write_labels3d(self, label_name, seg_chunks, roi_name=None, mutateseg="auto"):
"""Writes RDD of label volumes to DVID.
For each subvolume ID, this function writes the subvolume
ROI not including the border. The data is actually sent
compressed to minimize network latency.
Args:
label_name (str): name of already created DVID labelblk
seg_chunks (RDD): (key, (subvolume, label volume)
roi_name (str): restrict write to within this ROI
mutateseg (str): overwrite previous seg ("auto", "yes", "no"
"auto" will check existence of labels beforehand)
"""
# copy local context to minimize sent data
server = self.dvid_server
uuid = self.uuid
from libdvid import DVIDNodeService
# create labels type
node_service = DVIDNodeService(str(server), str(uuid))
success = node_service.create_labelblk(str(label_name))
# check whether seg should be mutated
mutate = False
if (not success and mutateseg == "auto") or mutateseg == "yes":
mutate = True
def writer(subvolume_seg):
from libdvid import DVIDNodeService
import numpy
# write segmentation
(key, (subvolume, segcomp)) = subvolume_seg
# uncompress data
seg = segcomp.deserialize()
# get sizes of subvolume
size1 = subvolume.roi.x2 - subvolume.roi.x1
size2 = subvolume.roi.y2 - subvolume.roi.y1
size3 = subvolume.roi.z2 - subvolume.roi.z1
border = subvolume.border
# extract seg ignoring borders (z,y,x)
seg = seg[border : size3 + border, border : size2 + border, border : size1 + border]
# put in x,y,z and send (copy the slice to make contiguous)
seg = numpy.copy(seg.transpose((2, 1, 0)))
@auto_retry(3, pause_between_tries=600.0, logging_name=__name__)
def put_labels():
node_service = DVIDNodeService(str(server), str(uuid))
# send data from roi start position
node_service.put_labels3D(
str(label_name),
seg,
(subvolume.roi.x1, subvolume.roi.y1, subvolume.roi.z1),
compress=True,
roi=str(roi_name),
mutate=mutate,
)
put_labels()
return seg_chunks.foreach(writer)
示例5: DVIDNodeService
# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import create_labelblk [as 别名]
logging.info('UUID:\n{}'.format(uuid))
# get node service
node_service = DVIDNodeService(server_address, uuid)
# get dataset size and store in dvid
shape = image_provider.getImageShape(args.ilpFilename, args.labelImagePath)
time_range = image_provider.getTimeRange(args.ilpFilename, args.labelImagePath)
if args.timeRange is not None:
time_range = (max(time_range[0], args.timeRange[0]), min(time_range[1], args.timeRange[1]))
logging.info('Uploading time range {} to {}'.format(time_range, server_address))
keyvalue_store = "config"
node_service.create_keyvalue(keyvalue_store)
settings = { "shape": shape, "time_range": time_range }
node_service.put(keyvalue_store, "imageInfo", json.dumps(settings))
# upload all frames
for frame in range(time_range[0], time_range[1]):
logging.info("Uploading frame {}".format(frame))
label_image = image_provider.getLabelImageForFrame(args.ilpFilename, args.labelImagePath, frame)
raw_image = image_provider.getImageDataAtTimeFrame(args.rawFilename, args.rawPath, frame)
raw_name = "raw-{}".format(frame)
seg_name = "seg-{}".format(frame)
node_service.create_grayscale8(raw_name)
node_service.put_gray3D(raw_name, dataToBlock(raw_image, dtype=np.uint8), (0,0,0))
node_service.create_labelblk(seg_name)
node_service.put_labels3D(seg_name, dataToBlock(label_image, dtype=np.uint64), (0,0,0))
# TODO: upload classifier
示例6: bench_reloadmeta
# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import create_labelblk [as 别名]
if res.status_code != 200:
return False, "reload command failed"
return True, None
bench_reloadmeta(uuid)
# run tests on grayscale interface (will delete when finished)
print "*************Testing Grayscale*************\n"
volumetests(ns, uuid, "grayscale", grayscale)
print "************End Testing Grayscale**********\n\n\n"
print "*************Testing Labels*************\n\n\n"
# create new repo for convenience
res, uuid = createrepo()
ns = DVIDNodeService(DVIDLOCATION, uuid)
ns.create_labelblk("labels")
# run tests on labelblk interface (will delete when finished)
volumetests(ns, uuid, "labels", labels)
print "************End Testing Labels**********\n\n\n"
# TODO run tests on labelk array interface
# Test key value
print "*************Testing KeyValue*************\n\n\n"
res, uuid = createrepo()
ns = DVIDNodeService(DVIDLOCATION, uuid)
name = "files"
ns.create_keyvalue(name)
# add files to master
ns.put(name, "m1", "data1")