本文整理汇总了Python中progressbar.ETA属性的典型用法代码示例。如果您正苦于以下问题:Python progressbar.ETA属性的具体用法?Python progressbar.ETA怎么用?Python progressbar.ETA使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类progressbar
的用法示例。
在下文中一共展示了progressbar.ETA属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: show_progress
# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import ETA [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
示例2: reset
# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import ETA [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)
示例3: create_progress_bar
# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import ETA [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)
示例4: download
# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import ETA [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)
示例5: deleteHostsByHostgroup
# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import ETA [as 别名]
def deleteHostsByHostgroup(groupname):
hostgroup = zapi.hostgroup.get(output=['groupid'],filter={'name': groupname})
if hostgroup.__len__() != 1:
logger.error('Hostgroup not found: %s\n\tFound this: %s' % (groupname,hostgroup))
groupid = int(hostgroup[0]['groupid'])
hosts = zapi.host.get(output=['name','hostid'],groupids=groupid)
total = len(hosts)
logger.info('Hosts found: %d' % (total))
if ( args.run ):
x = 0
bar = ProgressBar(maxval=total,widgets=[Percentage(), ReverseBar(), ETA(), RotatingMarker(), Timer()]).start()
logger.echo = False
for host in hosts:
x = x + 1
bar.update(x)
logger.debug('(%d/%d) >> Removing >> %s' % (x, total, host))
out = zapi.globo.deleteMonitors(host['name'])
bar.finish()
logger.echo = True
else:
logger.info('No host removed due to --no-run arg. Full list of hosts:')
for host in hosts:
logger.info('%s' % host['name'])
return
示例6: hosts_disable_all
# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import ETA [as 别名]
def hosts_disable_all():
"""
status de host 0 = enabled
status de host 1 = disabled
"""
logger.info('Disabling all hosts, in blocks of 1000')
hosts = zapi.host.get(output=[ 'hostid' ], search={ 'status': 0 })
maxval = int(ceil(hosts.__len__())/1000+1)
bar = ProgressBar(maxval=maxval,widgets=[Percentage(), ReverseBar(), ETA(), RotatingMarker(), Timer()]).start()
i = 0
for i in xrange(maxval):
block = hosts[:1000]
del hosts[:1000]
result = zapi.host.massupdate(hosts=[ x for x in block ], status=1)
i += 1
bar.update(i)
bar.finish()
logger.info('Done')
return
示例7: proxy_passive_to_active
# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import ETA [as 别名]
def proxy_passive_to_active():
"""
status de prxy 5 = active
status de prxy 6 = passive
"""
logger.info('Change all proxys to active')
proxys = zapi.proxy.get(output=[ 'shorten', 'host' ],
filter={ 'status': 6 })
if ( proxys.__len__() == 0 ):
logger.info('Done')
return
bar = ProgressBar(maxval=proxys.__len__(),widgets=[Percentage(), ReverseBar(), ETA(), RotatingMarker(), Timer()]).start()
i = 0
for x in proxys:
i += 1
proxyid = x['proxyid']
result = zapi.proxy.update(proxyid=proxyid, status=5)
logger.echo = False
logger.debug('Changed from passive to active proxy: %s' % (x['host']))
bar.update(i)
bar.finish()
logger.echo = True
logger.info('Done')
return
示例8: create_bar
# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import ETA [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)
示例9: finish
# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import ETA [as 别名]
def finish(self):
"""Make progress bar go to the end.
This is useful when the task takes shorter than the expect time to
finish.
"""
if self._tty:
with self._bar_lock:
# Go to the end of progress bar.
self._bar.update(self._expect_time * 2)
self._bar.finish()
else:
# Format the output like:
# Updating FlimFlam (ETA: 120 seconds)
# -> (actual: 74 seconds)
self._fd.write('{0} -> (actual: {1:.0f} seconds)\n'.format(
' ' * (len(self._message) - len(' ->')),
(datetime.datetime.now() - self._start_time).total_seconds()))
示例10: download_model
# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import ETA [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)
示例11: label_video
# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import ETA [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
示例12: save_best_overlap
# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import ETA [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)))
示例13: save_best_iou
# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import ETA [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)))
示例14: make_tracked_video
# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import ETA [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)
示例15: extract_frames
# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import ETA [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