yet a captcha library
Project description
pyncer
使用
训练
from datetime import datetime
from pyncer.text import TextPyncer, TextPyncerTrainer
from pyncer.text.util import load_by_filename
from tqdm import tqdm
if __name__ == '__main__':
pyncer = TextPyncer(
path='./captcha.m',
length=5,
charset=['0', '1', '2', '3', '4', '5', '6', '7', '8', '9',],
)
data = load_by_filename('./debug/')
batch_size = 128
trainer = TextPyncerTrainer(
pyncer=pyncer,
train_data = data,
test_data = data,
batch_size=128
)
avg_loss = 0.0
avg_limit = 100
avg_count = 0
for i in range(200):
for j, loss in tqdm(trainer.train()):
avg_loss += loss
c = avg_count + j
if (c % avg_limit) == 0:
print(f'count: {c} | loss:{avg_loss / avg_limit}')
avg_loss = 0.0
avg_count += j
accuracy = trainer.test(10)
print(f'epoch: {i} | accuracy: {accuracy * 100:.2f}%')
if (i % 3) == 2:
pyncer.save()
now = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
print(f'epoch: {i} | save: {now}')
猜验证码
import random
from pyncer.text import TextPyncer
from pyncer.text.util import load_by_filename
if __name__ == '__main__':
pyncer = TextPyncer(
path='./captcha.m',
length=5,
charset=['0', '1', '2', '3', '4', '5', '6', '7', '8', '9',],
)
data = load_by_filename('./debug/')
for _ in range(10):
i = random.randint(0, len(data))
c, p = data[i]
r = pyncer.infer(p)
print(f'{c} <=> {r}')
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyncer-0.0.1.tar.gz
(3.9 kB
view details)
Built Distribution
File details
Details for the file pyncer-0.0.1.tar.gz
.
File metadata
- Download URL: pyncer-0.0.1.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ac53622ba56f138af93cf1f485917fba77efc50abe84545efea41673d68b157 |
|
MD5 | c4801e25e57b6153018ed5ffea339ec6 |
|
BLAKE2b-256 | c92e40dbc3d2b40d8a90a307dcd668886b83bde28a5c59d829e3cb749b82807e |
File details
Details for the file pyncer-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: pyncer-0.0.1-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d1980b33a8956d633e44698f730a15d6f5c71acca9fe9f1ae38435317db99ebb |
|
MD5 | 212d1e644195ccc7298717c08967ca84 |
|
BLAKE2b-256 | e19f410d76ad8d9f5bdb61341d409a799647475082b1ebbbf5ecde7ca7255a6f |