squirelmail commited on
Commit
c6f2f27
·
verified ·
1 Parent(s): 28db8d3

Upload folder using huggingface_hub

Browse files
README.md CHANGED
@@ -1,3 +1,142 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 🧠 CRNN+CTC Checkpoints
2
+ =======================
3
+
4
+ This directory contains **Keras 3** `save_weights`\-style checkpoints produced during training of a CRNN + CTC model for 5-char uppercase/digit CAPTCHA (image size `H=50`, `W=250`, grayscale).
5
+
6
+ * * *
7
+
8
+ 📁 Contents
9
+ -----------
10
+
11
+ * `captcha_best.weights.h5` — best validation loss (auto-updated during training).
12
+ * `captcha_epNNN.weights.h5` — per-epoch snapshots (e.g., `captcha_ep001.weights.h5` … `captcha_ep022.weights.h5`).
13
+
14
+ All files are _weights only_; they must be loaded into the same model architecture used in training (the tester builds that architecture for you).
15
+
16
+ * * *
17
+
18
+ 📦 Requirements
19
+ ---------------
20
+
21
+ Install from the pinned list in the repo root:
22
+
23
+ # (recommended) fresh virtualenv
24
+ python3 -m venv venv
25
+ source venv/bin/activate
26
+
27
+ # install exact deps
28
+ pip install -r captcha_requirements.txt
29
+
30
+
31
+ **Important:** Keras/TensorFlow versions should match what was used during training. If you trained with TF/Keras nightly or dev builds, test in the same environment to avoid weight-loading shape/key mismatches.
32
+
33
+ * * *
34
+
35
+ 🧪 How to Test
36
+ --------------
37
+
38
+ The tester script re-creates the training graph (CRNN+CTC), loads the selected checkpoint, and runs inference with the _base_ (CTC-free) submodel.
39
+
40
+ ### 1) Single image
41
+
42
+ python3 cek_model_v6.py \
43
+ --weights /workspace/captcha_final.weights.h5 \
44
+ --image /workspace/dataset_500/style7/K9NO2.png
45
+
46
+
47
+ Optional ground truth override:
48
+
49
+ python3 cek_model_v6.py \
50
+ --weights /workspace/captcha_final.weights.h5 \
51
+ --image /workspace/dataset_500/style7/K9NO2.png \
52
+ --gt K9NO2
53
+
54
+
55
+ ### 2) Batch from a dataset
56
+
57
+ python3 cek_model_v6.py \
58
+ --weights /home/infra/models/captcha_ep002.weights.h5 \
59
+ --data-root /datasets/dataset_500 \
60
+ --samples 64
61
+
62
+
63
+ Expected directory layout for `--data-root`:
64
+
65
+ /datasets/dataset_500/
66
+ ├── style0/
67
+ │ ├── A1B2C.png
68
+ │ └── ...
69
+ ├── style1/
70
+ │ └── ...
71
+ └── ...
72
+ └── style59/
73
+
74
+
75
+ **Image format:** grayscale PNG, resized to `50x250` in the script.
76
+ **Labels:** derived from filename (regex `^[A-Z0-9]{5}$`).
77
+
78
+ * * *
79
+
80
+ 🧩 Model Details (for reference)
81
+ --------------------------------
82
+
83
+ * Backbone: 3× (Conv2D + BN + MaxPool), then reshape to time-steps.
84
+ * RNN head: 2× BiLSTM(128), `return_sequences=True`.
85
+ * Classifier: Dense(`num_classes = 36 + 1`) with softmax; `+1` is the CTC blank.
86
+ * Time steps: width is downsampled by 8 ⇒ `250/8 = 31` time steps.
87
+
88
+ The tester script internally builds both: `model_with_ctc` (training graph) and `base_model` (inference). It loads weights into the training graph and then uses `base_model` for predictions.
89
+
90
+ * * *
91
+
92
+ 🎛️ CLI Options
93
+ ---------------
94
+
95
+ --weights <path> : required, *.weights.h5 (same architecture)
96
+ --image <path> : test a single image
97
+ --gt <text> : ground truth for --image (default: file name)
98
+ --data-root <dir> : style0..style59 folders for batch testing
99
+ --samples N : max number of images for batch test (default 64)
100
+ --height H : input height (default 50)
101
+ --width W : input width (default 250)
102
+ --ext png|jpg : image extension for batch (default png)
103
+ --show K : print K sample predictions (default 12)
104
+
105
+
106
+ * * *
107
+
108
+ 📊 Output
109
+ ---------
110
+
111
+ * Per-sample preview lines: `GT: ABC12 | Pred: ABC12`
112
+ * Aggregate metrics:
113
+ * **Exact match** (% of predictions exactly equal to GT)
114
+ * **Mean CER** (character error rate)
115
+
116
+ * * *
117
+
118
+ 🧯 Troubleshooting
119
+ ------------------
120
+
121
+ * **“A total of 1 objects could not be loaded… <Dense name=predictions>”**
122
+ Mismatch between Keras/TF versions or model definition. Use the same environment and architecture as training.
123
+ * **GPU not used**
124
+ Ensure a CUDA-enabled TF build and matching drivers. For server-side issues, test with:
125
+
126
+ import tensorflow as tf
127
+ print(tf.config.list_physical_devices('GPU'))
128
+
129
+ * **NaN loss during training**
130
+ Check: label regex filtering, correct `input_length=31`, use `int32` for CTC inputs, disable LSTM dropouts when using cuDNN (set to `0.0`).
131
+
132
+ * * *
133
+
134
+ 🔐 Notes
135
+ --------
136
+
137
+ * CTC blank ID = `36` (since charset is 36 chars: 0-9 + A-Z).
138
+ * All checkpoints here are _weights only_; to export a full model, save the base model as `.keras` after loading weights in the same environment:
139
+
140
+ model_with_ctc, base_model = build_models(...)
141
+ model_with_ctc.load_weights("captcha_epXXX.weights.h5")
142
+ base_model.save("captcha_epXXX_base.keras")
captcha_best.weights.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ad4a4e763ac32650aacfe949f89ae848545f048648e87474a74ee3d44363699b
3
+ size 28423204
captcha_ep001.weights.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:53a810fe9371ccef31da5e6e397443c40e6b4ebd36f1f5a5d10319b5beeb709b
3
+ size 28423204
captcha_ep002.weights.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f4b9cccc5eb8d850426aa1df915e1e943d01545936cac33cec2f34375eb18c1d
3
+ size 28423204
captcha_ep003.weights.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2e66f30ebd6fdb777961b1e1d99902e16842587bff8c2aee8a7d2580caedfd08
3
+ size 28423204
captcha_ep004.weights.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:19ee3de5d7bdcc256edcbf9f53d32788ac091da48b513c2b8732087656e09c6b
3
+ size 28423204
captcha_ep005.weights.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b657976fc74ac9ab902a002ad740846f4db4beed9960be358bf4e69f5df8c953
3
+ size 28423204
captcha_ep006.weights.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4509190c87d51e40fde0aace2bcfdb845593d24b6a6e21d9574fa72eded03f30
3
+ size 28423204
captcha_ep007.weights.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d2348d78843e7d04f2bd2f1187afe72756aa7c44df1e33b4827e50bc34d4d70d
3
+ size 28423204
captcha_ep008.weights.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:62d4087c454d50ca3b6ec270f5f33cc599523f40d4cc96b6e8f05fe330fc2552
3
+ size 28423204
captcha_ep009.weights.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f9a296be1b0739c864cd6e000692a1ec99f75786248ee70dcffa08a42cca1392
3
+ size 28423204
captcha_ep010.weights.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d1888c5264b73feec874ec858ff40571f568523760fbd448f2251230ee8484b8
3
+ size 28423204
captcha_ep011.weights.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:82a66e290fa6be81337e612957b7a4c7a659f187689369249d4be8c0d5b94770
3
+ size 28423204
captcha_ep012.weights.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8d8db7f18969f189bdba5027f57389e18d6a1d17ededc8de6f663ddc31d9c30e
3
+ size 28423204
captcha_ep013.weights.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:aff79b45f9a106dd2b98325c051793acfe9abce2a74c462e1479cad32d35711d
3
+ size 28423204
captcha_ep014.weights.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:16f241460b63800e9c7565a6d4253d101fcd2f00e5a498857ecc1e11e94427eb
3
+ size 28423204
captcha_ep015.weights.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6a46dbf15ff0f367faeb3c4030d3b7745ec560c7cecb50fd3461540c11740c43
3
+ size 28423204
captcha_ep016.weights.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8d9e047c600357b819d97de68aba79feb92a3d9391d23e2bc7d417f9b7367176
3
+ size 28423204
captcha_ep017.weights.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e2a3071e8a9d9e5101bc196f86c4b3ed73810f153dae280cf4b4059b08e1d7d4
3
+ size 28423204
captcha_ep018.weights.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0113ef419dc66a7510de5998612f3a0c0dd23e903eceaf36fe0cc8bd1e4ca600
3
+ size 28423204
captcha_ep019.weights.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:56e1f008d5392ae15e93093af91248ad0762d3178fa870ae8a3af3425057437c
3
+ size 28423204
captcha_ep020.weights.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:642bb4e11f040add0fda18825b9727c94e4beb4332e1b151929620f95de08b05
3
+ size 28423204
captcha_ep021.weights.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:836541e1e8943c47b511f570c22af46257a3f8a673ebf6fa5f6e063c07cd2ada
3
+ size 28423204
captcha_ep022.weights.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ad4a4e763ac32650aacfe949f89ae848545f048648e87474a74ee3d44363699b
3
+ size 28423204
captcha_requirements.txt ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ absl-py==2.3.1
2
+ asttokens==3.0.0
3
+ astunparse==1.6.3
4
+ certifi==2025.8.3
5
+ charset-normalizer==3.4.3
6
+ comm==0.2.3
7
+ contourpy==1.3.3
8
+ cycler==0.12.1
9
+ debugpy==1.8.16
10
+ decorator==5.2.1
11
+ executing==2.2.1
12
+ filelock==3.19.1
13
+ flatbuffers==25.9.23
14
+ fonttools==4.60.1
15
+ fsspec==2025.9.0
16
+ gast==0.6.0
17
+ google-pasta==0.2.0
18
+ grpcio==1.76.0
19
+ h5py==3.14.0
20
+ hf-xet==1.1.10
21
+ huggingface-hub==0.34.4
22
+ idna==3.10
23
+ inquirerpy==0.3.4
24
+ ipykernel==6.30.1
25
+ ipython==9.5.0
26
+ ipython_pygments_lexers==1.1.1
27
+ ipywidgets==8.1.7
28
+ jedi==0.19.2
29
+ Jinja2==3.1.4
30
+ joblib==1.5.2
31
+ jupyter_client==8.6.3
32
+ jupyter_core==5.8.1
33
+ jupyterlab_widgets==3.0.15
34
+ keras==3.12.0
35
+ keras-nightly==3.12.0.dev2025100703
36
+ kiwisolver==1.4.9
37
+ libclang==18.1.1
38
+ Markdown==3.9
39
+ markdown-it-py==4.0.0
40
+ MarkupSafe==2.1.5
41
+ matplotlib==3.10.7
42
+ matplotlib-inline==0.1.7
43
+ mdurl==0.1.2
44
+ ml_dtypes==0.5.3
45
+ mpmath==1.3.0
46
+ namex==0.1.0
47
+ nest-asyncio==1.6.0
48
+ networkx==3.3
49
+ numpy==1.26.4
50
+ nvidia-cublas-cu12==12.8.4.1
51
+ nvidia-cuda-cupti-cu12==12.8.90
52
+ nvidia-cuda-nvcc-cu12==12.9.86
53
+ nvidia-cuda-nvrtc-cu12==12.8.93
54
+ nvidia-cuda-runtime-cu12==12.8.90
55
+ nvidia-cudnn-cu12==9.10.2.21
56
+ nvidia-cufft-cu12==11.3.3.83
57
+ nvidia-cufile-cu12==1.13.1.3
58
+ nvidia-curand-cu12==10.3.9.90
59
+ nvidia-cusolver-cu12==11.7.3.90
60
+ nvidia-cusparse-cu12==12.5.8.93
61
+ nvidia-cusparselt-cu12==0.7.1
62
+ nvidia-nccl-cu12==2.28.7
63
+ nvidia-nvjitlink-cu12==12.8.93
64
+ nvidia-nvshmem-cu12==3.3.20
65
+ nvidia-nvtx-cu12==12.8.90
66
+ opt_einsum==3.4.0
67
+ optree==0.17.0
68
+ packaging==25.0
69
+ pandas==2.3.3
70
+ parso==0.8.5
71
+ pexpect==4.9.0
72
+ pfzy==0.3.4
73
+ pillow==12.0.0
74
+ platformdirs==4.4.0
75
+ prompt_toolkit==3.0.52
76
+ protobuf==6.33.0
77
+ psutil==7.0.0
78
+ ptyprocess==0.7.0
79
+ pure_eval==0.2.3
80
+ Pygments==2.19.2
81
+ pyparsing==3.2.5
82
+ python-dateutil==2.9.0.post0
83
+ pytz==2025.2
84
+ PyYAML==6.0.2
85
+ pyzmq==27.1.0
86
+ requests==2.32.5
87
+ rich==14.2.0
88
+ scikit-learn==1.7.2
89
+ scipy==1.16.3
90
+ setuptools==80.9.0
91
+ six==1.17.0
92
+ stack-data==0.6.3
93
+ sympy==1.13.3
94
+ tb-nightly==2.20.0a20250717
95
+ tensorboard==2.20.0
96
+ tensorboard-data-server==0.7.2
97
+ termcolor==3.2.0
98
+ tf_nightly==2.21.0.dev20251017
99
+ threadpoolctl==3.6.0
100
+ torch==2.8.0
101
+ torchaudio==2.8.0+cu129
102
+ torchvision==0.23.0
103
+ tornado==6.5.2
104
+ tqdm==4.67.1
105
+ traitlets==5.14.3
106
+ triton==3.4.0
107
+ typing_extensions==4.15.0
108
+ tzdata==2025.2
109
+ urllib3==2.5.0
110
+ wcwidth==0.2.13
111
+ Werkzeug==3.1.3
112
+ wheel==0.45.1
113
+ widgetsnbextension==4.0.14
114
+ wrapt==2.0.0