def test_download(self): save_dir = os.path.join(os.path.dirname(__file__), 'models') url = 'https://storage.googleapis.com/chakki/datasets/public/ner/model_en.zip' download(url, save_dir) weights_file = os.path.join(save_dir, 'weights.h5') params_file = os.path.join(save_dir, 'params.json') preprocessor_file = os.path.join(save_dir, 'preprocessor.pickle') self.assertTrue(os.path.exists(weights_file)) self.assertTrue(os.path.exists(params_file)) self.assertTrue(os.path.exists(preprocessor_file))
def test_download(self): url = 'https://s3-ap-northeast-1.amazonaws.com/dev.tech-sketch.jp/chakki/public/conll2003_en.zip' weights_file, params_file, preprocessor_file = download(url) self.assertTrue(os.path.exists(weights_file)) self.assertTrue(os.path.exists(params_file)) self.assertTrue(os.path.exists(preprocessor_file))
def test_download(self): url = 'https://storage.googleapis.com/chakki/datasets/public/ner/model_en.zip' weights_file, params_file, preprocessor_file = download(url) self.assertTrue(os.path.exists(weights_file)) self.assertTrue(os.path.exists(params_file)) self.assertTrue(os.path.exists(preprocessor_file))
import os import anago from anago.utils import download, load_data_and_labels if __name__ == '__main__': dir_path = 'test_dir' url = 'https://s3-ap-northeast-1.amazonaws.com/dev.tech-sketch.jp/chakki/public/conll2003_en.zip' DATA_ROOT = os.path.join(os.path.dirname(__file__), '../data/conll2003/en/ner') test_path = os.path.join(DATA_ROOT, 'test.txt') x_test, y_test = load_data_and_labels(test_path) download(url, dir_path) model = anago.Sequence.load('weights.h5', 'params.json', 'preprocessor.pickle') model.score(x_test, y_test)
def test_download(self): dir_path = 'test_dir' url = 'https://storage.googleapis.com/chakki/datasets/public/models.zip' download(url, dir_path) model = anago.Sequence.load(dir_path) model.eval(self.x_test, self.y_test)