代码拉取完成,页面将自动刷新
同步操作将从 大漠/LaTeX_OCR_PRO 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
import click
from model.utils.data_generator import DataGenerator
from model.img2seq import Img2SeqModel
from model.utils.general import Config
from model.utils.text import Vocab
from model.utils.image import greyscale
from model.utils.text import load_formulas
from model.evaluation.text import score_files
@click.command()
@click.option('--results', default="results/small/", help='Dir to results')
def main(results):
# restore config and model
dir_output = results
config_data = Config(dir_output + "data.json")
config_vocab = Config(dir_output + "vocab.json")
config_model = Config(dir_output + "model.json")
vocab = Vocab(config_vocab)
model = Img2SeqModel(config_model, dir_output, vocab)
model.build_pred()
# model.restore_session(dir_output + "model_weights/")
# load dataset
test_set = DataGenerator(path_formulas=config_data.path_formulas_test,
dir_images=config_data.dir_images_test,
img_prepro=greyscale,
max_iter=config_data.max_iter,
bucket=config_data.bucket_test,
path_matching=config_data.path_matching_test,
max_len=config_data.max_length_formula,
form_prepro=vocab.form_prepro,)
# use model to write predictions in files
config_eval = Config({
"dir_answers": dir_output + "formulas_test/",
"batch_size": 20
})
files, perplexity = model.write_prediction(config_eval, test_set)
scores = score_files(files[0], files[1])
scores["perplexity"] = perplexity
msg = " || ".join(["{} is {:04.2f}".format(k, v) for k, v in scores.items()])
model.logger.info("- Test Txt: {}".format(msg))
if __name__ == "__main__":
main()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。