Python progressbar.ETA Examples
The following are 30
code examples of progressbar.ETA().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
progressbar
, or try the search function
.
Example #1
Source File: geo_heatmap.py From geo-heatmap with MIT License | 6 votes |
def loadGPXData(self, file_name, date_range): """Loads location data from the given GPX file. Arguments: file_name {string or file} -- The name of the GPX file (or an open file-like object) with the GPX data. date_range {tuple} -- A tuple containing the min-date and max-date. e.g.: (None, None), (None, '2019-01-01'), ('2017-02-11'), ('2019-01-01') """ xmldoc = minidom.parse(file_name) gxtrack = xmldoc.getElementsByTagName("trkpt") w = [Bar(), Percentage(), " ", ETA()] with ProgressBar(max_value=len(gxtrack), widgets=w) as pb: for i, trkpt in enumerate(gxtrack): lat = trkpt.getAttribute("lat") lon = trkpt.getAttribute("lon") coords = (round(float(lat), 6), round(float(lon), 6)) date = trkpt.getElementsByTagName("time")[0].firstChild.data if dateInRange(date[:10], date_range): self.updateCoord(coords) pb.update(i)
Example #2
Source File: timing.py From e2e-nlg-challenge-2017 with Apache License 2.0 | 6 votes |
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)
Example #3
Source File: data_handler.py From cortex with BSD 3-Clause "New" or "Revised" License | 6 votes |
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)
Example #4
Source File: download.py From chainer with MIT License | 6 votes |
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)
Example #5
Source File: zbx_deleteMonitors.py From zabbix-scripts with BSD 3-Clause "New" or "Revised" License | 6 votes |
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
Example #6
Source File: zbx_clone.py From zabbix-scripts with BSD 3-Clause "New" or "Revised" License | 6 votes |
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
Example #7
Source File: zbx_clone.py From zabbix-scripts with BSD 3-Clause "New" or "Revised" License | 6 votes |
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
Example #8
Source File: __init__.py From attention-lvcsr with MIT License | 6 votes |
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)
Example #9
Source File: io.py From django-cloud-deploy with Apache License 2.0 | 6 votes |
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()))
Example #10
Source File: models.py From thingscoop with MIT License | 6 votes |
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)
Example #11
Source File: eval_script.py From Tensorflow_Object_Tracking_Video with MIT License | 6 votes |
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)))
Example #12
Source File: eval_script.py From Tensorflow_Object_Tracking_Video with MIT License | 6 votes |
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)))
Example #13
Source File: Utils_Video.py From Tensorflow_Object_Tracking_Video with MIT License | 6 votes |
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)
Example #14
Source File: Utils_Video.py From Tensorflow_Object_Tracking_Video with MIT License | 6 votes |
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
Example #15
Source File: progress.py From desmod with MIT License | 6 votes |
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
Example #16
Source File: progress.py From desmod with MIT License | 6 votes |
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
Example #17
Source File: geo_heatmap.py From geo-heatmap with MIT License | 6 votes |
def loadJSONData(self, json_file, date_range): """Loads the Google location data from the given json file. Arguments: json_file {file} -- An open file-like object with JSON-encoded Google location data. date_range {tuple} -- A tuple containing the min-date and max-date. e.g.: (None, None), (None, '2019-01-01'), ('2017-02-11'), ('2019-01-01') """ data = json.load(json_file) w = [Bar(), Percentage(), " ", ETA()] with ProgressBar(max_value=len(data["locations"]), widgets=w) as pb: for i, loc in enumerate(data["locations"]): if "latitudeE7" not in loc or "longitudeE7" not in loc: continue coords = (round(loc["latitudeE7"] / 1e7, 6), round(loc["longitudeE7"] / 1e7, 6)) if timestampInRange(loc["timestampMs"], date_range): self.updateCoord(coords) pb.update(i)
Example #18
Source File: search.py From thingscoop with MIT License | 6 votes |
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
Example #19
Source File: geo_heatmap.py From geo-heatmap with MIT License | 6 votes |
def loadKMLData(self, file_name, date_range): """Loads the Google location data from the given KML file. Arguments: file_name {string or file} -- The name of the KML file (or an open file-like object) with the Google location data. date_range {tuple} -- A tuple containing the min-date and max-date. e.g.: (None, None), (None, '2019-01-01'), ('2017-02-11'), ('2019-01-01') """ xmldoc = minidom.parse(file_name) gxtrack = xmldoc.getElementsByTagName("gx:coord") when = xmldoc.getElementsByTagName("when") w = [Bar(), Percentage(), " ", ETA()] with ProgressBar(max_value=len(gxtrack), widgets=w) as pb: for i, number in enumerate(gxtrack): loc = (number.firstChild.data).split() coords = (round(float(loc[1]), 6), round(float(loc[0]), 6)) date = when[i].firstChild.data if dateInRange(date[:10], date_range): self.updateCoord(coords) pb.update(i)
Example #20
Source File: dataset.py From zhusuan with MIT License | 6 votes |
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
Example #21
Source File: utils.py From skl-groups with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self, widgets=None, **kwargs): import progressbar as pb logging.Handler.__init__(self) if widgets is None: class CommaProgress(pb.Widget): def update(self, pbar): return '{:,} of {:,}'.format(pbar.currval, pbar.maxval) widgets = [' ', CommaProgress(), ' (', pb.Percentage(), ') ', pb.Bar(), ' ', pb.ETA()] self.pbar_args = {'widgets': widgets} self.pbar_args.update(kwargs)
Example #22
Source File: eval_script.py From Tensorflow_Object_Tracking_Video with MIT License | 5 votes |
def val_to_data(source): text_lines=[] frames_list=[] frame = None progress = progressbar.ProgressBar(widgets=[progressbar.Bar('=', '[', ']'), ' ',progressbar.Percentage(), ' ',progressbar.ETA()]) with open(source, 'r') as s: for line in s: id_frame, id_class, conf, xmin, ymin, xmax, ymax = line.strip().split(' ') text_lines.append((id_frame, id_class, conf, xmin, ymin, xmax, ymax)) for i in range(0, len(text_lines)): if frame is None: frame = fm.Frame_Info() frame.frame= text_lines[i][0] rect= multiclass_rectangle.Rectangle_Multiclass() # Not all the inserted values are really used rect.load_labeled_rect(0, text_lines[i][2], text_lines[i][2], text_lines[i][3], text_lines[i][4], text_lines[i][5], text_lines[i][6], text_lines[i][1], text_lines[i][1], text_lines[i][1]) frame.append_labeled_rect(rect) else : if frame.frame == text_lines[i][0]: rect= multiclass_rectangle.Rectangle_Multiclass() # Not all the inserted values are really used rect.load_labeled_rect(0, text_lines[i][2], text_lines[i][2], text_lines[i][3], text_lines[i][4], text_lines[i][5], text_lines[i][6], text_lines[i][1], text_lines[i][1], text_lines[i][1]) frame.append_labeled_rect(rect) else : frames_list.append(frame) frame = fm.Frame_Info() frame.frame= text_lines[i][0] rect= multiclass_rectangle.Rectangle_Multiclass() # Not all the inserted values are really used rect.load_labeled_rect(0, text_lines[i][2], text_lines[i][2], text_lines[i][3], text_lines[i][4], text_lines[i][5], text_lines[i][6], text_lines[i][1], text_lines[i][1], text_lines[i][1]) frame.append_labeled_rect(rect) frames_list.append(frame) return frames_list
Example #23
Source File: memory.py From margaritashotgun with MIT License | 5 votes |
def __init__(self, remote_addr, mem_size, progressbar=False, recv_size=1048576, sock_timeout=1): """ :type remote_addr: str :param remote_addr: hostname or ip address of target server :type mem_size: int :param mem_size: target server memory size in bytes :type progressbar: bool :param progressbar: ncurses progress bar toggle :type recv_size: int :param recv_size: transfer socket max receive size :type sock_timeout: int :param sock_timeout: transfer socket receive timeout """ self.mem_size = mem_size self.progressbar = progressbar self.recv_size = recv_size self.sock_timeout = sock_timeout self.padding_percentage = 0.03 self.max_size = self.max_size(mem_size, self.padding_percentage) self.update_interval = 5 self.update_threshold = recv_size * self.update_interval self.remote_addr = remote_addr self.transfered = 0 self.progress = 0 self.widgets = [' {0} '.format(remote_addr), Percentage(), ' ', Bar(), ' ', ETA(), ' ', FileTransferSpeed()] self.sock = None self.outfile = None self.bar = None
Example #24
Source File: job_util.py From osspolice with GNU General Public License v3.0 | 5 votes |
def __init__(self, msg, maxval): try: # see docs for other options self.__widgets = [msg, progressbar.Percentage(), ' ', progressbar.Bar(marker='#', left='[', right=']'), ' ', progressbar.ETA(), ' ', progressbar.FileTransferSpeed()] self.__bar = progressbar.ProgressBar(maxval=maxval, widgets=self.__widgets) except Exception as e: raise Exception("Failed to init progressbar: " + str(e))
Example #25
Source File: filehunt.py From PANhunt with BSD 3-Clause "New" or "Revised" License | 5 votes |
def find_all_regexs_in_files(text_or_zip_files, regexs, search_extensions, hunt_type, gauge_update_function=None): """ Searches files in doc_files list for regular expressions""" if not gauge_update_function: pbar_widgets = ['%s Hunt: ' % hunt_type, progressbar.Percentage(), ' ', progressbar.Bar(marker = progressbar.RotatingMarker()), ' ', progressbar.ETA(), progressbar.FormatLabel(' %ss:0' % hunt_type)] pbar = progressbar.ProgressBar(widgets = pbar_widgets).start() else: gauge_update_function(caption = '%s Hunt: ' % hunt_type) total_files = len(text_or_zip_files) files_completed = 0 matches_found = 0 for afile in text_or_zip_files: matches = afile.check_regexs(regexs, search_extensions) matches_found += len(matches) files_completed += 1 if not gauge_update_function: pbar_widgets[6] = progressbar.FormatLabel(' %ss:%s' % (hunt_type, matches_found)) pbar.update(files_completed * 100.0 / total_files) else: gauge_update_function(value = files_completed * 100.0 / total_files) if not gauge_update_function: pbar.finish() return total_files, matches_found
Example #26
Source File: Utils_Video.py From Tensorflow_Object_Tracking_Video with MIT License | 5 votes |
def make_video_from_frames(out_vid_path, frames): if frames[0] is not None: h, w = frames[0].shape[:2] fourcc = cv2.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(frames)) progress = progressbar.ProgressBar(widgets=[progressbar.Bar('=', '[', ']'), ' ',progressbar.Percentage(), ' ',progressbar.ETA()]) for i in progress(range(0,len(frames))): out.write(frames[i]) out.release() print("Finished Making File Video:%s " % out_vid_path) ####### FOR TENSORBOX ###########
Example #27
Source File: Utils_Video.py From Tensorflow_Object_Tracking_Video with MIT License | 5 votes |
def extract_idl_from_frames(vid_path, video_perc, path_video_folder, folder_path_frames, idl_filename): ####### Creating Folder for the video frames and the idl file for the list if not os.path.exists(path_video_folder): os.makedirs(path_video_folder) print("Created Folder: %s"%path_video_folder) if not os.path.exists(path_video_folder+'/'+folder_path_frames): os.makedirs(path_video_folder+'/'+folder_path_frames) print("Created Folder: %s"% (path_video_folder+'/'+folder_path_frames)) if not os.path.exists(idl_filename): open(idl_filename, 'a') print "Created File: "+ idl_filename list=[] # 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) 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()]) image = vidcap.read() with open(idl_filename, 'w') as f: for i in progress(range(0,total)): #frame_name="%s/%s/fram%d.jpeg"%(path_video_folder,folder_path_frames,i) list.append("%s/%sframe%d.jpeg"%(path_video_folder,folder_path_frames,i)) cv2.imwrite("%s/%sframe%d.jpeg"%(path_video_folder,folder_path_frames,i), image[1]) # save frame as JPEG file image = vidcap.read() print("Finish Reading File Video:%s " % vid_path) return list
Example #28
Source File: pst.py From PANhunt with BSD 3-Clause "New" or "Revised" License | 5 votes |
def get_simple_progressbar(title): pbar_widgets = [title, progressbar.Percentage(), ' ', progressbar.Bar(marker = progressbar.RotatingMarker()), ' ', progressbar.ETA()] pbar = progressbar.ProgressBar(widgets = pbar_widgets).start() return pbar
Example #29
Source File: ttclust.py From TTClust with GNU General Public License v3.0 | 5 votes |
def reorder_cluster(clusters): """ DESCRIPTION Reorder the clusters number to have the first frame belonging to the cluster 1. --- Args : Clusters_labels(list): list of clusters label. """ dict_order = {} for i in range(len(clusters)): dict_order[clusters[i].id] = clusters[i].frames[0] # Evaluate order sorted_clusters = sorted(dict_order.items(), key=operator.itemgetter(1)) for i in range(len(sorted_clusters)): dict_order[sorted_clusters[i][0]] = i + 1 # i+1 == reorder cluster number # reordering for i in range(len(clusters)): clusters[i].id = dict_order[clusters[i].id] # ============================================================================== # FONCTIONS # ============================================================================== # @Gooey(progress_regex=r"\|( |>)*\| ETA: +([0-9]|-)+:([0-9]|-)+:([0-9]|-)+ \|( |<)*\|", # disable_progress_bar_animation=True)
Example #30
Source File: VID_yolo.py From Tensorflow_Object_Tracking_Video with MIT License | 5 votes |
def print_YOLO_DET_result(det_results_list,folder_path_summary_result, file_path_summary_result ): results_list=[] if not os.path.exists(folder_path_summary_result): os.makedirs(folder_path_summary_result) print("Created Folder: %s"%folder_path_summary_result) print("Starting Loading Results ") progress = progressbar.ProgressBar(widgets=[progressbar.Bar('=', '[', ']'), ' ',progressbar.Percentage(), ' ',progressbar.ETA()]) names=['class_name', 'x1','y1','x2','y2','score'] df = pandas.DataFrame(columns=names) mean=0.0 with open(file_path_summary_result, "w") as out_file: for i in progress(range(0,len(det_results_list))): #df.append(pandas.read_csv(det_results_list[i], sep=',',names=names, encoding="utf8")) #results_list.append(pandas.read_csv(det_results_list[i], sep=',',names=names, encoding="utf8")) for line in open(det_results_list[i], "r"): df.loc[i] =tuple(line.strip().split(',')) mean=mean+float(df.loc[i].score) out_file.write(str(tuple(line.strip().split(',')))+ os.linesep) print("Finished Loading Results ") print("Computing Final Mean Reasults..") print "Class: " + df.class_name.max() print "Max Value: " + df.score.max() print "Min Value: " + df.score.min() print "Avg Value: " + str(mean/len(df)) return ######### MAIN ###############