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


Python progressbar.Bar方法代码示例

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


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

示例1: show_progress

# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import Bar [as 别名]
def show_progress(block_num, block_size, total_size):
    global pbar

    if pbar is None:
        if total_size > 0:
            prefixes = ('', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei', 'Zi', 'Yi')
            power = min(int(math.log(total_size, 2) / 10), len(prefixes) - 1)
            scaled = float(total_size) / (2 ** (10 * power))
            total_size_str = '{:.1f} {}B'.format(scaled, prefixes[power])
            try:
                marker = '█'
            except UnicodeEncodeError:
                marker = '*'
            widgets = [
                progressbar.Percentage(),
                ' ', progressbar.DataSize(),
                ' / ', total_size_str,
                ' ', progressbar.Bar(marker=marker),
                ' ', progressbar.ETA(),
                ' ', progressbar.AdaptiveTransferSpeed(),
            ]
            pbar = progressbar.ProgressBar(widgets=widgets,
                                           max_value=total_size)
        else:
            widgets = [
                progressbar.DataSize(),
                ' ', progressbar.Bar(marker=progressbar.RotatingMarker()),
                ' ', progressbar.Timer(),
                ' ', progressbar.AdaptiveTransferSpeed(),
            ]
            pbar = progressbar.ProgressBar(widgets=widgets,
                                           max_value=progressbar.UnknownLength)

    downloaded = block_num * block_size
    if downloaded < total_size:
        pbar.update(downloaded)
    else:
        pbar.finish()
        pbar = None 
开发者ID:thu-ml,项目名称:zhusuan,代码行数:41,代码来源:dataset.py

示例2: reset

# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import Bar [as 别名]
def reset(self, mode, make_pbar=True, string=''):
        self.mode = mode
        self.u = 0

        if make_pbar:
            widgets = [string, Timer(), ' | ',
                       Percentage(), ' | ', ETA(), Bar()]
            if len([len(loader[self.mode]) for loader
                    in self.loaders.values()]) == 0:
                maxval = 1000
            else:
                maxval = min(len(loader[self.mode])
                             for loader in self.loaders.values())
            self.pbar = ProgressBar(widgets=widgets, maxval=maxval).start()
        else:
            self.pbar = None

        sources = self.loaders.keys()
        self.iterators = dict((source, self.make_iterator(source))
                              for source in sources) 
开发者ID:rdevon,项目名称:cortex,代码行数:22,代码来源:data_handler.py

示例3: create_progress_bar

# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import Bar [as 别名]
def create_progress_bar(dynamic_msg=None):
    # Taken from Andreas Rueckle.
    # usage:
    #   bar = _create_progress_bar('loss')
    #   L = []
    #   for i in bar(iterable):
    #       ...
    #       L.append(...)
    #
    #   bar.dynamic_messages['loss'] = np.mean(L)
    widgets = [
        ' [batch ', progressbar.SimpleProgress(), '] ',
        progressbar.Bar(),
        ' (', progressbar.ETA(), ') '
    ]
    if dynamic_msg is not None:
        widgets.append(progressbar.DynamicMessage(dynamic_msg))
    return progressbar.ProgressBar(widgets=widgets) 
开发者ID:UKPLab,项目名称:e2e-nlg-challenge-2017,代码行数:20,代码来源:timing.py

示例4: knn_masked_data

# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import Bar [as 别名]
def knn_masked_data(trX,trY,missing_data_dir, input_shape, k):
    
    raw_im_data = np.loadtxt(join(script_dir,missing_data_dir,'index.txt'),delimiter=' ',dtype=str)
    raw_mask_data = np.loadtxt(join(script_dir,missing_data_dir,'index_mask.txt'),delimiter=' ',dtype=str)
    # Using 'brute' method since we only want to do one query per classifier
    # so this will be quicker as it avoids overhead of creating a search tree
    knn_m = KNeighborsClassifier(algorithm='brute',n_neighbors=k)
    prob_Y_hat = np.zeros((raw_im_data.shape[0],int(np.max(trY)+1)))
    total_images = raw_im_data.shape[0]
    pbar = progressbar.ProgressBar(widgets=[progressbar.FormatLabel('\rProcessed %(value)d of %(max)d Images '), progressbar.Bar()], maxval=total_images, term_width=50).start()
    for i in range(total_images):
        mask_im=load_image(join(script_dir,missing_data_dir,raw_mask_data[i][0]), input_shape,1).reshape(np.prod(input_shape))
        mask = np.logical_not(mask_im > eps) # since mask is 1 at missing locations
        v_im=load_image(join(script_dir,missing_data_dir,raw_im_data[i][0]), input_shape, 255).reshape(np.prod(input_shape))
        rep_mask = np.tile(mask,(trX.shape[0],1))
        # Corrupt whole training set according to the current mask
        corr_trX = np.multiply(trX, rep_mask)        
        knn_m.fit(corr_trX, trY)
        prob_Y_hat[i,:] = knn_m.predict_proba(v_im.reshape(1,-1))
        pbar.update(i)
    pbar.finish()
    return prob_Y_hat 
开发者ID:HUJI-Deep,项目名称:Generative-ConvACs,代码行数:24,代码来源:knn_missing_data.py

示例5: download

# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import Bar [as 别名]
def download(url, dst_file_path):
    # Download a file, showing progress
    bar_wrap = [None]

    def reporthook(count, block_size, total_size):
        bar = bar_wrap[0]
        if bar is None:
            bar = progressbar.ProgressBar(
                maxval=total_size,
                widgets=[
                    progressbar.Percentage(),
                    ' ',
                    progressbar.Bar(),
                    ' ',
                    progressbar.FileTransferSpeed(),
                    ' | ',
                    progressbar.ETA(),
                ])
            bar.start()
            bar_wrap[0] = bar
        bar.update(min(count * block_size, total_size))

    request.urlretrieve(url, dst_file_path, reporthook=reporthook) 
开发者ID:chainer,项目名称:chainer,代码行数:25,代码来源:download.py

示例6: create_bar

# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import Bar [as 别名]
def create_bar(self):
        """Create a new progress bar.

        Calls `self.get_iter_per_epoch()`, selects an appropriate
        set of widgets and creates a ProgressBar.

        """
        iter_per_epoch = self.get_iter_per_epoch()
        epochs_done = self.main_loop.log.status['epochs_done']

        if iter_per_epoch is None:
            widgets = ["Epoch {}, step ".format(epochs_done),
                       progressbar.Counter(), ' ',
                       progressbar.BouncingBar(), ' ',
                       progressbar.Timer()]
            iter_per_epoch = progressbar.UnknownLength
        else:
            widgets = ["Epoch {}, step ".format(epochs_done),
                       progressbar.Counter(),
                       ' (', progressbar.Percentage(), ') ',
                       progressbar.Bar(), ' ',
                       progressbar.Timer(), ' ', progressbar.ETA()]

        return progressbar.ProgressBar(widgets=widgets,
                                       max_value=iter_per_epoch) 
开发者ID:rizar,项目名称:attention-lvcsr,代码行数:27,代码来源:__init__.py

示例7: download_model

# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import Bar [as 别名]
def download_model(model):
    if model_in_cache(model): return
    model_url = get_model_url(model)
    tmp_zip = tempfile.NamedTemporaryFile(suffix=".zip")
    prompt = "Downloading model {}".format(model)
    def cb(count, block_size, total_size):
        global progress_bar
        if not progress_bar:
            widgets = [prompt, Percentage(), ' ', Bar(), ' ', FileTransferSpeed(), ' ', ETA()]
            progress_bar = ProgressBar(widgets=widgets, maxval=int(total_size)).start()
        progress_bar.update(min(total_size, count * block_size))
    urllib.urlretrieve(model_url, tmp_zip.name, cb)
    z = zipfile.ZipFile(tmp_zip)
    out_path = get_model_local_path(model)
    try:
        os.mkdir(out_path)
    except:
        pass
    for name in z.namelist():
        if name.startswith("_"): continue
        z.extract(name, out_path) 
开发者ID:agermanidis,项目名称:thingscoop,代码行数:23,代码来源:models.py

示例8: label_video

# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import Bar [as 别名]
def label_video(filename, classifier, sample_rate=1, recreate_index=False):
    index_filename = generate_index_path(filename, classifier.model)
    
    if os.path.exists(index_filename) and not recreate_index:
        return read_index_from_path(index_filename)
    
    temp_frame_dir, frames = extract_frames(filename, sample_rate=sample_rate)

    timed_labels = []

    widgets=["Labeling {}: ".format(filename), Percentage(), ' ', Bar(), ' ', ETA()]
    pbar = ProgressBar(widgets=widgets, maxval=len(frames)).start()

    for index, frame in enumerate(frames):
        pbar.update(index)
        labels = classifier.classify_image(frame)
        if not len(labels):
            continue
        t = (1./sample_rate) * index
        timed_labels.append((t, labels))
    
    shutil.rmtree(temp_frame_dir)
    save_index_to_path(index_filename, timed_labels)
    
    return timed_labels 
开发者ID:agermanidis,项目名称:thingscoop,代码行数:27,代码来源:search.py

示例9: save_best_overlap

# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import Bar [as 别名]
def save_best_overlap(val_bbox, output_bbox):

    progress = progressbar.ProgressBar(widgets=[progressbar.Bar('=', '[', ']'), ' ',progressbar.Percentage(), ' ',progressbar.ETA()])
    count_best_bbox=0
    len_val_bbox=len(val_bbox)
    len_output_bbox=len(output_bbox)
    count_missing_boxes=0
    with open("best_overlap.txt", 'a') as d:
        for i in progress(range(0, len(val_bbox))):
            for rect in val_bbox[i].rects:
                if(len(output_bbox[i].rects)>0):
                    selected=multiclass_rectangle.pop_max_overlap(output_bbox[i].rects,rect)
                    count_best_bbox=count_best_bbox+1
                    d.write(str(val_bbox[i].frame)+' '+str(rect.label_chall)+ ' 0.5 '+str(selected.x1)+' '+str(selected.y1)+' '+str(selected.x2)+' '+str(selected.y2) + os.linesep)
                else:
                    count_missing_boxes=count_missing_boxes+1
    print "Total Frame Number: "+ str(len_val_bbox) 
    print "Total Output Bounding Boxes: "+ str(len_output_bbox) 
    print "Total Best Bounding Boxes: "+ str(count_best_bbox) 
    print "Total Missing Bounding Boxes: "+ str(count_missing_boxes) 
    print "Total False Positive Bounding Boxes: "+ str(len_output_bbox-count_best_bbox) 
    print "BBox/Frame Number: "+ str(float(count_best_bbox)/float(len_val_bbox)) 
    print "Missing BBox/Frame Number: "+ str(float(float(count_missing_boxes)/float(len_val_bbox)))
    print "False Positive BBox/Frame Number: "+ str(float(float(len_output_bbox-count_best_bbox)/float(len_val_bbox))) 
开发者ID:DrewNF,项目名称:Tensorflow_Object_Tracking_Video,代码行数:26,代码来源:eval_script.py

示例10: save_best_iou

# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import Bar [as 别名]
def save_best_iou(val_bbox, output_bbox):

    progress = progressbar.ProgressBar(widgets=[progressbar.Bar('=', '[', ']'), ' ',progressbar.Percentage(), ' ',progressbar.ETA()])
    count_best_bbox=0
    len_val_bbox=len(val_bbox)
    len_output_bbox=len(output_bbox)
    count_missing_boxes=0
    with open("best_iou.txt", 'a') as d:
        for i in progress(range(0, len(val_bbox))):
            for rect in val_bbox[i].rects:
                if(len(output_bbox[i].rects)>0):
                    selected=multiclass_rectangle.pop_max_iou(output_bbox[i].rects,rect)
                    count_best_bbox=count_best_bbox+1
                    d.write(str(val_bbox[i].frame)+' '+str(rect.label_chall)+ ' 0.5 '+str(selected.x1)+' '+str(selected.y1)+' '+str(selected.x2)+' '+str(selected.y2) + os.linesep)
                else:
                    count_missing_boxes=count_missing_boxes+1
    print "Total Frame Number: "+ str(len_val_bbox) 
    print "Total Output Bounding Boxes: "+ str(len_output_bbox) 
    print "Total Best Bounding Boxes: "+ str(count_best_bbox) 
    print "Total Missing Bounding Boxes: "+ str(count_missing_boxes) 
    print "Total False Positive Bounding Boxes: "+ str(len_output_bbox-count_best_bbox) 
    print "BBox/Frame Number: "+ str(float(count_best_bbox)/float(len_val_bbox)) 
    print "Missing BBox/Frame Number: "+ str(float(float(count_missing_boxes)/float(len_val_bbox)))
    print "False Positive BBox/Frame Number: "+ str(float(float(len_output_bbox-count_best_bbox)/float(len_val_bbox))) 
开发者ID:DrewNF,项目名称:Tensorflow_Object_Tracking_Video,代码行数:26,代码来源:eval_script.py

示例11: make_tracked_video

# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import Bar [as 别名]
def make_tracked_video(out_vid_path, labeled_video_frames):

    if labeled_video_frames[0] is not None:

        img = cv2.imread(labeled_video_frames[0], True)
        print "Reading Filename: %s"%labeled_video_frames[0]
        h, w = img.shape[:2]
        print "Video Size: width: %d height: %d"%(h, w)
        fourcc = cv2.cv.CV_FOURCC('m', 'p', '4', 'v')
        out = cv2.VideoWriter(out_vid_path,fourcc, 20.0, (w, h), True)
        print("Start Making File Video:%s " % out_vid_path)
        print("%d Frames to Compress"%len(labeled_video_frames))
        progress = progressbar.ProgressBar(widgets=[progressbar.Bar('=', '[', ']'), ' ',progressbar.Percentage(), ' ',progressbar.ETA()])
        for i in progress(range(0,len(labeled_video_frames))):
            if utils_image.check_image_with_pil(labeled_video_frames[i]):
                out.write(img)
                img = cv2.imread(labeled_video_frames[i], True)
        out.release()
        print("Finished Making File Video:%s " % out_vid_path) 
开发者ID:DrewNF,项目名称:Tensorflow_Object_Tracking_Video,代码行数:21,代码来源:Utils_Video.py

示例12: extract_frames

# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import Bar [as 别名]
def extract_frames(vid_path, video_perc):
    list=[]
    frames=[]
    # Opening & Reading the Video
    print("Opening File Video:%s " % vid_path)
    vidcap = cv2.VideoCapture(vid_path)
    if not vidcap.isOpened():
        print "could Not Open :",vid_path
        return
    print("Opened File Video:%s " % vid_path)
    print("Start Reading File Video:%s " % vid_path)
    image = vidcap.read()
    total = int((vidcap.get(cv2.cv.CV_CAP_PROP_FRAME_COUNT)/100)*video_perc)
    print("%d Frames to Read"%total)
    progress = progressbar.ProgressBar(widgets=[progressbar.Bar('=', '[', ']'), ' ',progressbar.Percentage(), ' ',progressbar.ETA()])
    for i in progress(range(0,total)):
        list.append("frame%d.jpg" % i)
        frames.append(image)
        image = vidcap.read()
    print("Finish Reading File Video:%s " % vid_path)
    return frames, list 
开发者ID:DrewNF,项目名称:Tensorflow_Object_Tracking_Video,代码行数:23,代码来源:Utils_Video.py

示例13: _init_progress_bar

# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import Bar [as 别名]
def _init_progress_bar(total_length, destination, message=None):
    if not message:
        message = "Downloading {!r}".format(os.path.basename(destination))

    valid_length = total_length and total_length > 0

    if valid_length and is_dumb_terminal():
        widgets = [message, " ", Percentage()]
        maxval = total_length
    elif valid_length and not is_dumb_terminal():
        widgets = [message, Bar(marker="=", left="[", right="]"), " ", Percentage()]
        maxval = total_length
    elif not valid_length and is_dumb_terminal():
        widgets = [message]
        maxval = UnknownLength
    else:
        widgets = [message, AnimatedMarker()]
        maxval = UnknownLength

    return ProgressBar(widgets=widgets, maxval=maxval) 
开发者ID:ubuntu,项目名称:microk8s,代码行数:22,代码来源:_windows.py

示例14: _get_progressbar_widgets

# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import Bar [as 别名]
def _get_progressbar_widgets(
    sim_index: Optional[int], timescale: TimeValue, know_stop_time: bool
) -> List[progressbar.widgets.WidgetBase]:
    widgets = []

    if sim_index is not None:
        widgets.append(f'Sim {sim_index:3}|')

    magnitude, units = timescale
    if magnitude == 1:
        sim_time_format = f'%(value)6.0f {units}|'
    else:
        sim_time_format = f'{magnitude}x%(value)6.0f {units}|'
    widgets.append(progressbar.FormatLabel(sim_time_format))

    widgets.append(progressbar.Percentage())

    if know_stop_time:
        widgets.append(progressbar.Bar())
    else:
        widgets.append(progressbar.BouncingBar())

    widgets.append(progressbar.ETA())

    return widgets 
开发者ID:SanDisk-Open-Source,项目名称:desmod,代码行数:27,代码来源:progress.py

示例15: _get_overall_pbar

# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import Bar [as 别名]
def _get_overall_pbar(
    num_simulations: int, max_width: int, fd: IO
) -> progressbar.ProgressBar:
    pbar = progressbar.ProgressBar(
        fd=fd,
        min_value=0,
        max_value=num_simulations,
        widgets=[
            progressbar.FormatLabel('%(value)s of %(max_value)s '),
            'simulations (',
            progressbar.Percentage(),
            ') ',
            progressbar.Bar(),
            progressbar.ETA(),
        ],
    )

    if max_width and pbar.term_width > max_width:
        pbar.term_width = max_width

    return pbar 
开发者ID:SanDisk-Open-Source,项目名称:desmod,代码行数:23,代码来源:progress.py


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