def _assert_and_prepare_model_files(self): model_dir = self._model_dir model_files = [ 'label_cn.txt', '%s-%04d.params' % (self._model_file_prefix, self._model_epoch), '%s-symbol.json' % self._model_file_prefix, ] file_prepared = True for f in model_files: f = os.path.join(model_dir, f) if not os.path.exists(f): file_prepared = False break if file_prepared: return get_model_file(model_dir)
def _assert_and_prepare_model_files(self, root): model_dir = self._model_dir model_files = ['label_cn.txt', '%s-%04d.params' % (self.MODEL_FILE_PREFIX, self._model_epoch), '%s-symbol.json' % self.MODEL_FILE_PREFIX] file_prepared = True for f in model_files: f = os.path.join(model_dir, f) if not os.path.exists(f): file_prepared = False break if file_prepared: return if os.path.exists(model_dir): os.removedirs(model_dir) get_model_file(root)
def _assert_and_prepare_model_files(self, model_fp, root): if model_fp is not None and not os.path.isfile(model_fp): raise FileNotFoundError('can not find model file %s' % model_fp) if model_fp is not None: self._model_fp = model_fp return root = os.path.join(root, MODEL_VERSION) self._model_dir = os.path.join(root, self._model_name) fps = glob('%s/%s*.ckpt' % (self._model_dir, self._model_file_prefix)) if len(fps) > 1: raise ValueError( 'multiple ckpt files are found in %s, not sure which one should be used' % self._model_dir) elif len(fps) < 1: logger.warning('no ckpt file is found in %s' % self._model_dir) get_model_file(self._model_dir) # download the .zip file and unzip fps = glob('%s/%s*.ckpt' % (self._model_dir, self._model_file_prefix)) self._model_fp = fps[0]