代码拉取完成,页面将自动刷新
同步操作将从 kerlomz/captcha_trainer 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
# Author: kerlomz <kerlomz@gmail.com>
import os
import json
import PIL.Image as pil_image
charset = "ALPHANUMERIC_LOWER"
trains_path = [
r"D:\TrainSet\***",
]
model = """
# ModelName: Corresponding to the model file in the model directory,
# - such as YourModelName.pb, fill in YourModelName here.
# CharSet: Provides a default optional built-in solution:
# - [ALPHANUMERIC, ALPHANUMERIC_LOWER, ALPHANUMERIC_UPPER,
# -- NUMERIC, ALPHABET_LOWER, ALPHABET_UPPER, ALPHABET, ALPHANUMERIC_LOWER_MIX_CHINESE_3500]
# - Or you can use your own customized character set like: ['a', '1', '2'].
# CharExclude: CharExclude should be a list, like: ['a', '1', '2']
# - which is convenient for users to freely combine character sets.
# - If you don't want to manually define the character set manually,
# - you can choose a built-in character set
# - and set the characters to be excluded by CharExclude parameter.
Model:
Sites: [
]
ModelName: @model_name
ModelType: @size_str
CharSet: @charset
CharExclude: []
CharReplace: {}
ImageWidth: @width
ImageHeight: @height
# Binaryzation: [-1: Off, >0 and < 255: On].
# Smoothing: [-1: Off, >0: On].
# Blur: [-1: Off, >0: On].
# Resize: [WIDTH, HEIGHT]
# - If the image size is too small, the training effect will be poor and you need to zoom in.
Pretreatment:
Binaryzation: -1
Smoothing: -1
Blur: -1
Resize: @resize
Trains:
# TrainsPath: './dataset/@model_name_trains.tfrecords'
# TestPath: './dataset/@model_name_test.tfrecords'
TrainsPath: @trains_path
"""
# - [ALPHANUMERIC, ALPHANUMERIC_LOWER, ALPHANUMERIC_UPPER,
# -- NUMERIC, ALPHABET_LOWER, ALPHABET_UPPER, ALPHABET, ALPHANUMERIC_LOWER_MIX_CHINESE_3500]
trains_path = [i.replace("\\", "/") for i in trains_path]
file_name = os.listdir(trains_path[0])[0]
size = pil_image.open(os.path.join(trains_path[0], file_name)).size
width = size[0]
height = size[1]
size_str = "{}x{}".format(width, height)
if width > 180 or width < 120:
r_height = int(height * 150 / width)
else:
r_height = height
resize = "[{}, {}]".format(width if r_height == height else 150, r_height)
model_name = 'tutorial-mix-CNN5BLSTM-{}'.format(size_str)
trains_path = json.dumps(trains_path, ensure_ascii=False).replace("]", " ]")
result = model.replace("@trains_path", trains_path).replace("@model_name", model_name).replace("@resize", resize).replace("@size_str", size_str).replace("@width", str(width)).replace("@height", str(height)).replace("@charset", charset)
print(result)
with open("model.yaml".format(size_str), "w") as f:
f.write(result)
from make_dataset import run
from trains import main
run()
with open("model.yaml".format(size_str), "w") as f:
f.write("\n".join(result.split("\n")[:-3]).replace("# TrainsPath", " TrainsPath").replace("# TestPath", " TestPath"))
main(None)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。