File size: 5,321 Bytes
49c16a5 859beab 49c16a5 859beab 49c16a5 859beab 49c16a5 859beab 49c16a5 859beab 49c16a5 859beab 49c16a5 859beab 49c16a5 859beab 49c16a5 859beab 49c16a5 859beab 49c16a5 859beab 49c16a5 859beab 49c16a5 859beab 49c16a5 859beab 49c16a5 859beab 49c16a5 859beab 49c16a5 859beab 49c16a5 859beab 49c16a5 859beab 49c16a5 859beab 49c16a5 859beab |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
---
library_name: transformers
license: mit
datasets:
- gary109/captcha-synth-v3
---
# Model Card for Model ID
<!-- Provide a quick summary of what the model is/does. -->
## Model Details
### Model Description
本模型結合了卷積神經網絡 (CNN) 作為**視覺特徵提取器**和 Transformer Encoder 作為**序列解碼器**,旨在解決光學字元辨識 (OCR) 中的驗證碼識別任務。
CNN Backbone 負責從輸入的灰階驗證碼圖片中提取豐富的空間特徵,而 Transformer Encoder 則利用自註意力機制 (Self-Attention) 來理解這些特徵的序列關係和上下文資訊,最終輸出每個時間步對應各個字元(包含 CTC Blank Token)的機率分佈。
模型使用 CTC Loss 進行訓練,使其能夠在不知道確切字元對齊位置的情況下學習序列預測。
訓練完成時,模型能在資料集作者提供的驗證集中達到91.14%的準確度
- **Developed by:** [me]
- 沒填的部分就是作者沒看懂要填什麼
## Uses
### Direct Use
此模型可以直接用於識別與 gary109/captcha-synth-v3 數據集中風格類似的驗證碼圖片。
### Downstream Use [optional]
此模型可以作為更複雜系統的一部分,例如自動化測試流程或輔助工具。也可以在其基礎上,使用特定風格的驗證碼數據進行進一步的微調(例如使用 LoRA)。
### Out-of-Scope Use
* 此模型**不適用於**通用的 OCR 任務(例如掃描文件)、手寫文字識別。
* 對於與訓練數據風格迥異(例如完全不同的字體、雜訊模式、背景)的驗證碼,性能可能會顯著下降。
* **道德考量**:此模型**不應**被用於惡意繞過網站的安全機制或進行任何形式的濫用。開發和使用此類技術應遵守相關法律法規和道德準則。
## **Bias, Risks, and Limitations**
* **性能偏差**:模型性能高度依賴於輸入圖片與訓練數據的相似性。對於訓練集中未出現或罕見的字元樣式、雜訊類型,模型可能表現不佳。
* **數據集偏差**:gary109/captcha-synth-v3 數據集的生成方式可能引入潛在偏差(例如某些字元組合更常見)。
* **安全性風險**:如果被用於攻擊性目的,可能繞過基於 CAPTCHA 的人機驗證,構成安全風險。
* **魯棒性限制**:儘管使用了數據增強,模型對於極端的圖像失真、遮擋或對抗性攻擊可能仍然比較脆弱。
### Recommendations
強烈建議使用者在使用此模型前,充分了解其能力邊界和潛在風險。對於任何安全敏感的應用,不應依賴此模型作為唯一的防護措施。建議在使用或微調此模型時,對目標數據進行充分的評估和錯誤分析。
## How to Get Started with the Model
稍後會上傳訓練時使用的程式檔案
## Training Details
### Training Data
模型主要在 [gary109/captcha-synth-v3](https://www.google.com/search?q=https://huggingface.co/datasets/gary109/captcha-synth-v3) 數據集的 train split (約 120 萬張圖片) 上進行訓練。
該數據集包含帶有標籤的合成驗證碼圖片。
### Training Procedure
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
#### Preprocessing [optional]
訓練和驗證數據都經過了以下預處理:
1. **灰階轉換**:將圖片轉換為單通道灰階圖。
2. **保持長寬比縮放與填充 (PadAndResize)**:將圖片縮放到 50x200,同時保持原始長寬比,不足部分用黑色 (0) 填充。
3. **轉換為 Tensor**。
4. **歸一化**:將像素值歸一化到 \[-1, 1\] 範圍。
在微調階段,訓練集還額外應用了**數據增強**,包括:
* RandomAffine: 隨機旋轉 (±8°)、平移 (±10%)、縮放 (±10%)、錯切 (±5°)。
* RandomPerspective: 隨機透視變換。
* ColorJitter: 隨機調整亮度和對比度。
* RandomErasing: 隨機擦除圖片的一小塊區域。
#### Training Hyperparameters
見config
#### Testing Data
<!-- This should link to a Dataset Card if possible. -->
[More Information Needed]
#### Factors
未進行特定子群體或領域的分解評估。
#### Metrics
主要評估指標是 **完全匹配準確率 (Exact Match Accuracy)**:模型輸出的文字序列與真實標籤完全一致的樣本比例。同時,在分析中也考慮了錯誤類型(長度不匹配、替換錯誤、複雜錯誤)和字元替換混淆矩陣。
## Environmental Impact
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
- **Hardware Type:** RTX 5070 Ti
- **Hours used:** 5
### Model Architecture and Objective
模型採用 CNN 作為視覺特徵提取器,隨後是一個多層 Transformer Encoder 負責序列建模。目標是通過 CTCLoss 最小化預測序列與真實標籤之間的差異。
[More Information Needed]
#### Software
* Python 3.13.6
* PyTorch 2.8.0+cu129
* Transformers 4.57.0
* Datasets 4.3.0
* CUDA 12.9 |