Esempio n. 1
0
def trange(*args, **kwargs):
    """
    A wrapper for tqdm.trange, automatically setting file=sys.stdout and
    dynamic_ncols=True if not specified.
    """
    if "file" not in kwargs:
        kwargs["file"] = DummyTqdmFile.file
    if "dynamic_ncols" not in kwargs:
        kwargs["dynamic_ncols"] = True
    return _trange(*args, **kwargs)
Esempio n. 2
0
def segment(locs, info, segmentation, kwargs={}, callback=None):
    Y = info[0]['Height']
    X = info[0]['Width']
    n_frames = info[0]['Frames']
    n_seg = n_segments(info, segmentation)
    bounds = _np.linspace(0, n_frames-1, n_seg+1, dtype=_np.uint32)
    segments = _np.zeros((n_seg, Y, X))
    if callback is not None:
        callback(0)
    for i in _trange(n_seg, desc='Generating segments', unit='segments'):
        segment_locs = locs[(locs.frame >= bounds[i]) & (locs.frame < bounds[i+1])]
        _, segments[i] = render(segment_locs, info, **kwargs)
        if callback is not None:
            callback(i+1)
    return bounds, segments
Esempio n. 3
0
def segment(locs, info, segmentation, kwargs={}, callback=None):
    Y = info[0]["Height"]
    X = info[0]["Width"]
    n_frames = info[0]["Frames"]
    n_seg = n_segments(info, segmentation)
    bounds = _np.linspace(0, n_frames - 1, n_seg + 1, dtype=_np.uint32)
    segments = _np.zeros((n_seg, Y, X))
    if callback is not None:
        callback(0)
    for i in _trange(n_seg, desc="Generating segments", unit="segments"):
        #print("Segment",i)
        segment_locs = locs[
            (locs.frame >= bounds[i]) & (locs.frame < bounds[i + 1])
        ]
        _, segments[i] = render(segment_locs, info, **kwargs)
        if callback is not None:
            callback(i + 1)
    return bounds, segments
Esempio n. 4
0
def trange(*args, **kwargs):
    kwargs['ascii'] = True
    return _trange(*args, **kwargs)