Skip to content

Commit

Permalink
mesh works
Browse files Browse the repository at this point in the history
  • Loading branch information
jingpengw committed Sep 27, 2019
1 parent a9785c3 commit 2388dce
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
11 changes: 9 additions & 2 deletions chunkflow/flow/create_bounding_boxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
from cloudvolume.lib import Vec, Bbox

def create_bounding_boxes(chunk_size:tuple, overlap: tuple=(0,0,0),
start:tuple=None, layer_path: str=None, mip:int=0, grid_size: tuple=None):
start:tuple=None, layer_path: str=None, mip:int=0,
grid_size: tuple=None, verbose: bool=True):
if layer_path:
vol = CloudVolume(layer_path, mip=mip)
# dataset shape as z,y,x
Expand All @@ -31,7 +32,13 @@ def create_bounding_boxes(chunk_size:tuple, overlap: tuple=(0,0,0),
for g, s in zip(grid_size, stride):
if g > 1:
assert s > 0


if verbose:
print('\nstart: ', start)
print('stride: ', stride)
print('grid size: ', grid_size)
print('chunk_size: ', chunk_size, '\n')

bboxes = []
for (z, y, x) in tqdm(product(range(grid_size[0]), range(grid_size[1]),
range(grid_size[2]))):
Expand Down
16 changes: 9 additions & 7 deletions chunkflow/flow/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from time import time
import numpy as np
import click
from copy import deepcopy

from cloudvolume.lib import Bbox
from chunkflow.lib.aws.sqs_queue import SQSQueue
Expand All @@ -30,7 +29,10 @@

# global dict to hold the operators and parameters
state = {'operators': {}}
INITIAL_TASK = {'skip': False, 'log': {'timer': {}}}

def get_initial_task():
return {'skip': False, 'log': {'timer': {}}}

DEFAULT_CHUNK_NAME = 'chunk'

def handle_task_skip(task, name):
Expand Down Expand Up @@ -75,7 +77,7 @@ def process_commands(operators, verbose, mip):
into the other, similar to how a pipe on unix works.
"""
# It turns out that a tuple will not work correctly!
stream = [ deepcopy(INITIAL_TASK), ]
stream = [ get_initial_task(), ]

# Pipe it through all stream operators.
for operator in operators:
Expand Down Expand Up @@ -132,13 +134,13 @@ def new_func(stream, *args, **kwargs):
def generate_tasks(layer_path, mip, start, overlap, chunk_size, grid_size, queue_name):
"""Generate tasks."""
bboxes = create_bounding_boxes(chunk_size, overlap=overlap, layer_path=layer_path,
start=start, mip=mip, grid_size=grid_size)
start=start, mip=mip, grid_size=grid_size, verbose=state['verbose'])
if queue_name is not None:
queue = SQSQueue(queue_name)
queue.send_message_list(bboxes)
else:
for bbox in bboxes:
task = deepcopy(INITIAL_TASK)
task = get_initial_task()
task['bbox'] = bbox
task['log']['bbox'] = bbox.to_filename()
yield task
Expand All @@ -160,7 +162,7 @@ def fetch_task(queue_name, visibility_timeout):
print('get task: ', bbox_str)
bbox = Bbox.from_filename(bbox_str)
# record the task handle to delete after the processing
task = deepcopy(INITIAL_TASK)
task = get_initial_task()
task['queue'] = queue
task['task_handle'] = task_handle
task['bbox'] = bbox
Expand Down Expand Up @@ -527,7 +529,7 @@ def log_summary(log_dir, output_size):
df = load_log(log_dir)
print_log_statistics(df, output_size=output_size)

task = deepcopy(INITIAL_TASK)
task = get_initial_task()
yield task


Expand Down
7 changes: 4 additions & 3 deletions chunkflow/flow/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,13 @@ def __call__(self, seg: np.ndarray):

bbox = seg.bbox

if self.verbose:
print('remove dust segments')
seg = self._remove_dust(seg)
if self.verbose:
print('only keep selected segment ids, and remove others.')
seg = self._only_keep_selected(seg)

if self.verbose:
print('remove dust segments')
seg = self._remove_dust(seg)

if self.verbose:
print('computing meshes from segmentation...')
Expand Down

0 comments on commit 2388dce

Please sign in to comment.