Comments (2)
还有一个疑问,使用默认的模型识别率很低,如果重新训练是只能用自己后面打算识别的这些素材,还是可以去下载其他素材
from dddd_trainer.
一个简单的示例,生成10万张长度为4-6的包含数字和大小写字符串的验证码图片
from captcha.image import ImageCaptcha
import numpy as np
from PIL import Image
import random
import os
import hashlib
number = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u',
'v', 'w', 'x', 'y', 'z']
ALPHABET = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U',
'V', 'W', 'X', 'Y', 'Z']
def random_captcha_text(char_set=None, captcha_size=None):
if char_set is None:
char_set = number + alphabet + ALPHABET
if captcha_size is None:
captcha_size = random.randint(4, 6) # 随机长度从4到6
captcha_text = random.choices(char_set, k=captcha_size)
return captcha_text
def gen_captcha_text_and_image():
# 随机选择难度参数,例如图片宽度和高度
width, height = random.randint(100, 200), random.randint(50, 100)
image = ImageCaptcha(width=width, height=height)
captcha_text = random_captcha_text()
captcha_text = ''.join(captcha_text)
hash_obj = hashlib.sha256(captcha_text.encode('utf-8'))
hash_hex = hash_obj.hexdigest()
filename = f"{captcha_text}_{hash_hex}.jpg"
file_path = os.path.join("dist", filename)
captcha = image.generate(captcha_text)
# 写到文件
with open(file_path, 'wb') as f:
f.write(captcha.getbuffer())
captcha_image = Image.open(captcha)
captcha_image = np.array(captcha_image)
return captcha_text, captcha_image
if __name__ == '__main__':
if not os.path.exists('dist'):
os.makedirs('dist')
for _ in range(100000):
gen_captcha_text_and_image()
from dddd_trainer.
Related Issues (20)
- 有可以提供参考的训练时长吗 HOT 3
- 清晰空心数字无法识别 HOT 2
- 是否支持滑块验证码学习? HOT 4
- 导出时报错:TypeError: export() got an unexpected keyword argument '_retain_param_name'
- CtrlC中断训练后,重新执行训练命令后报错
- 请问CPU训练只有阶段数据没有模型数据为何 HOT 2
- 能放出来同花顺客户端训练的权重吗?
- 这个报错是啥意思 HOT 2
- 因磁盘满而中断后,无法自动恢复 HOT 1
- Mac也是按这个步骤来吗,改成CPU训练就可以了嘛 HOT 6
- 电脑是2060显卡能搞吗 HOT 4
- 断点恢复训练问题
- 可以提供坐标点选的训练吗 HOT 1
- 将ddddocr换成其他CNN比如mobilenetv2会变成NAN
- 训练了一天英文数字验证码,正确率真的感人,是我电脑不行吗....
- 训练测试集一段时间报错
- StopIteration 問題
- 希望能出一版colab上可以运行的ipynb代码
- acc准确率始终是0
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dddd_trainer.