def combobox_browse_callback(self, hObject): currentVal = hObject.currentText() file_list = utils.select_files(currentVal, depth='root') self.layout2_widgets[0].clear() for f in file_list: item = QListWidgetItem(f) file_type = os.path.splitext(f)[1] if not file_type: item.setIcon(QIcon(pyIcons.fileIO.folder)) elif file_type == '.py': item.setIcon(QIcon(pyIcons.fileIO.python)) elif file_type == '.html': item.setIcon(QIcon(pyIcons.fileIO.html)) elif file_type == '.ipynb': item.setIcon(QIcon(pyIcons.fileIO.ipynb)) elif file_type == '.yaml': item.setIcon(QIcon(pyIcons.fileIO.yaml)) elif file_type == '.json': item.setIcon(QIcon(pyIcons.fileIO.json)) elif set([file_type ]).issubset(set(['.png', '.jpg', '.svg', '.gif'])): item.setIcon(QIcon(pyIcons.fileIO.image)) elif set([file_type]).issubset(set(['.xlsx', '.csv', '.xls'])): item.setIcon(QIcon(pyIcons.fileIO.excel)) elif set([file_type]).issubset(set(['.txt', '.md'])): item.setIcon(QIcon(pyIcons.fileIO.txt)) else: pass self.layout2_widgets[0].addItem(item) self.layout2_widgets[0].setIconSize(QSize(16, 16))
def combobox_ext_callback(self, hObject): current_dir = self.layout1_widgets[1].currentText() file_ext = hObject.currentText() file_list = utils.select_files(current_dir, ext=[file_ext], depth='root') self.set_browser_listbox(self.layout2_widgets[0], file_list)
def get_last_model(**kwargs): log_dir = get_varargin(kwargs, 'log_dir', cfg.FILEIO.LOG_DIR) and_key = get_varargin(kwargs, 'and_key', ['.ckpt']) or_key = get_varargin(kwargs, 'or_key', None) # List .h5 files in model_dir directory file_list = utils.select_files(log_dir, and_key=and_key, or_key=or_key) return sorted(file_list)[-1]
def on_epoch_end(self, epoch, logs=None): self.progress.current = epoch+1 self.progress() logging.info('loss: {:.4f} - accuracy: {:.4f}'\ ' - val_loss: {:.4f} - val_accuracy: {:.4f}'\ .format(logs['loss'], logs['accuracy'], logs['val_loss'], logs['val_accuracy'])) if epoch+1 == self.params['epochs']: logger.logPC_usage() logger.log_nvidia_smi_info() # # Delete ckpts file, only keep n-latest files last_model = get_last_model() ckpts_dir = Path(last_model).parent ckpts_filelist = sorted(utils.select_files(ckpts_dir,and_key = ['.ckpt']) , reverse = True) epoch_list = sorted(np.unique([get_epoch_number(e) for e in ckpts_filelist]), reverse = True) if len(epoch_list) > cfg.TRAIN.MAX_CKPTS_FILES: cut_epoch = epoch_list[cfg.TRAIN.MAX_CKPTS_FILES-1] for f in ckpts_filelist: if get_epoch_number(f) < cut_epoch: os.remove(f)
def combobox_browse_callback(self, hObject): currentVal = hObject.currentText() file_list = utils.select_files(currentVal, depth='root') self.set_browser_listbox(self.layout2_widgets[0], file_list)