Update README.md
Browse files
README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
| 1 |
---
|
| 2 |
library_name: transformers
|
| 3 |
-
|
|
|
|
|
|
|
| 4 |
---
|
| 5 |
|
| 6 |
# Model Card for Model ID
|
|
@@ -13,98 +15,77 @@ tags: []
|
|
| 13 |
|
| 14 |
### Model Description
|
| 15 |
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
- **Developed by:** [More Information Needed]
|
| 21 |
-
- **Funded by [optional]:** [More Information Needed]
|
| 22 |
-
- **Shared by [optional]:** [More Information Needed]
|
| 23 |
-
- **Model type:** [More Information Needed]
|
| 24 |
-
- **Language(s) (NLP):** [More Information Needed]
|
| 25 |
-
- **License:** [More Information Needed]
|
| 26 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
| 27 |
-
|
| 28 |
-
### Model Sources [optional]
|
| 29 |
-
|
| 30 |
-
<!-- Provide the basic links for the model. -->
|
| 31 |
-
|
| 32 |
-
- **Repository:** [More Information Needed]
|
| 33 |
-
- **Paper [optional]:** [More Information Needed]
|
| 34 |
-
- **Demo [optional]:** [More Information Needed]
|
| 35 |
|
| 36 |
## Uses
|
| 37 |
|
| 38 |
-
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
| 39 |
-
|
| 40 |
### Direct Use
|
|
|
|
| 41 |
|
| 42 |
-
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
| 43 |
-
|
| 44 |
-
[More Information Needed]
|
| 45 |
|
| 46 |
### Downstream Use [optional]
|
| 47 |
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
[More Information Needed]
|
| 51 |
|
| 52 |
### Out-of-Scope Use
|
| 53 |
|
| 54 |
-
|
|
|
|
|
|
|
| 55 |
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
## Bias, Risks, and Limitations
|
| 59 |
|
| 60 |
-
|
|
|
|
|
|
|
|
|
|
| 61 |
|
| 62 |
-
[More Information Needed]
|
| 63 |
|
| 64 |
### Recommendations
|
| 65 |
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
| 69 |
|
| 70 |
## How to Get Started with the Model
|
| 71 |
|
| 72 |
-
|
| 73 |
|
| 74 |
-
[More Information Needed]
|
| 75 |
|
| 76 |
## Training Details
|
| 77 |
|
| 78 |
### Training Data
|
| 79 |
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
[More Information Needed]
|
| 83 |
-
|
| 84 |
### Training Procedure
|
| 85 |
|
| 86 |
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
| 87 |
|
| 88 |
#### Preprocessing [optional]
|
| 89 |
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
#### Training Hyperparameters
|
| 94 |
|
| 95 |
-
|
|
|
|
|
|
|
|
|
|
| 96 |
|
| 97 |
-
|
| 98 |
|
| 99 |
-
|
|
|
|
|
|
|
|
|
|
| 100 |
|
| 101 |
-
[More Information Needed]
|
| 102 |
-
|
| 103 |
-
## Evaluation
|
| 104 |
|
| 105 |
-
|
|
|
|
| 106 |
|
| 107 |
-
### Testing Data, Factors & Metrics
|
| 108 |
|
| 109 |
#### Testing Data
|
| 110 |
|
|
@@ -113,30 +94,11 @@ Use the code below to get started with the model.
|
|
| 113 |
[More Information Needed]
|
| 114 |
|
| 115 |
#### Factors
|
| 116 |
-
|
| 117 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
| 118 |
-
|
| 119 |
-
[More Information Needed]
|
| 120 |
|
| 121 |
#### Metrics
|
|
|
|
| 122 |
|
| 123 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
| 124 |
-
|
| 125 |
-
[More Information Needed]
|
| 126 |
-
|
| 127 |
-
### Results
|
| 128 |
-
|
| 129 |
-
[More Information Needed]
|
| 130 |
-
|
| 131 |
-
#### Summary
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
## Model Examination [optional]
|
| 136 |
-
|
| 137 |
-
<!-- Relevant interpretability work for the model goes here -->
|
| 138 |
-
|
| 139 |
-
[More Information Needed]
|
| 140 |
|
| 141 |
## Environmental Impact
|
| 142 |
|
|
@@ -144,56 +106,19 @@ Use the code below to get started with the model.
|
|
| 144 |
|
| 145 |
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).
|
| 146 |
|
| 147 |
-
- **Hardware Type:**
|
| 148 |
-
- **Hours used:**
|
| 149 |
-
- **Cloud Provider:** [More Information Needed]
|
| 150 |
-
- **Compute Region:** [More Information Needed]
|
| 151 |
-
- **Carbon Emitted:** [More Information Needed]
|
| 152 |
|
| 153 |
-
## Technical Specifications [optional]
|
| 154 |
|
| 155 |
### Model Architecture and Objective
|
| 156 |
-
|
| 157 |
[More Information Needed]
|
| 158 |
|
| 159 |
-
### Compute Infrastructure
|
| 160 |
-
|
| 161 |
-
[More Information Needed]
|
| 162 |
-
|
| 163 |
-
#### Hardware
|
| 164 |
-
|
| 165 |
-
[More Information Needed]
|
| 166 |
|
| 167 |
#### Software
|
| 168 |
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
**BibTeX:**
|
| 176 |
-
|
| 177 |
-
[More Information Needed]
|
| 178 |
-
|
| 179 |
-
**APA:**
|
| 180 |
-
|
| 181 |
-
[More Information Needed]
|
| 182 |
-
|
| 183 |
-
## Glossary [optional]
|
| 184 |
-
|
| 185 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
| 186 |
-
|
| 187 |
-
[More Information Needed]
|
| 188 |
-
|
| 189 |
-
## More Information [optional]
|
| 190 |
-
|
| 191 |
-
[More Information Needed]
|
| 192 |
-
|
| 193 |
-
## Model Card Authors [optional]
|
| 194 |
-
|
| 195 |
-
[More Information Needed]
|
| 196 |
-
|
| 197 |
-
## Model Card Contact
|
| 198 |
-
|
| 199 |
-
[More Information Needed]
|
|
|
|
| 1 |
---
|
| 2 |
library_name: transformers
|
| 3 |
+
license: mit
|
| 4 |
+
datasets:
|
| 5 |
+
- gary109/captcha-synth-v3
|
| 6 |
---
|
| 7 |
|
| 8 |
# Model Card for Model ID
|
|
|
|
| 15 |
|
| 16 |
### Model Description
|
| 17 |
|
| 18 |
+
本模型結合了卷積神經網絡 (CNN) 作為**視覺特徵提取器**和 Transformer Encoder 作為**序列解碼器**,旨在解決光學字元辨識 (OCR) 中的驗證碼識別任務。
|
| 19 |
+
CNN Backbone 負責從輸入的灰階驗證碼圖片中提取豐富的空間特徵,而 Transformer Encoder 則利用自註意力機制 (Self-Attention) 來理解這些特徵的序列關係和上下文資訊,最終輸出每個時間步對應各個字元(包含 CTC Blank Token)的機率分佈。
|
| 20 |
+
模型使用 CTC Loss 進行訓練,使其能夠在不知道確切字元對齊位置的情況下學習序列預測。
|
| 21 |
+
訓練完成時,模型能在資料集作者提供的驗證集中達到91.14%的準確度
|
| 22 |
|
| 23 |
+
- **Developed by:** [me]
|
| 24 |
+
- 沒填的部分就是作者沒看懂要填什麼
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
## Uses
|
| 27 |
|
|
|
|
|
|
|
| 28 |
### Direct Use
|
| 29 |
+
此模型可以直接用於識別與 gary109/captcha-synth-v3 數據集中風格類似的驗證碼圖片。
|
| 30 |
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
### Downstream Use [optional]
|
| 33 |
|
| 34 |
+
此模型可以作為更複雜系統的一部分,例如自動化測試流程或輔助工具。也可以在其基礎上,使用特定風格的驗證碼數據進行進一步的微調(例如使用 LoRA)。
|
|
|
|
|
|
|
| 35 |
|
| 36 |
### Out-of-Scope Use
|
| 37 |
|
| 38 |
+
* 此模型**不適用於**通用的 OCR 任務(例如掃描文件)、手寫文字識別。
|
| 39 |
+
* 對於與訓練數據風格迥異(例如完全不同的字體、雜訊模式、背景)的驗證碼,性能可能會顯著下降。
|
| 40 |
+
* **道德考量**:此模型**不應**被用於惡意繞過網站的安全機制或進行任何形式的濫用。開發和使用此類技術應遵守相關法律法規和道德準則。
|
| 41 |
|
| 42 |
+
## **Bias, Risks, and Limitations**
|
|
|
|
|
|
|
| 43 |
|
| 44 |
+
* **性能偏差**:模型性能高度依賴於輸入圖片與訓練數據的相似性。對於訓練集中未出現或罕見的字元樣式、雜訊類型,模型可能表現不佳。
|
| 45 |
+
* **數據集偏差**:gary109/captcha-synth-v3 數據集的生成方式可能引入潛在偏差(例如某些字元組合更常見)。
|
| 46 |
+
* **安全性風險**:如果被用於攻擊性目的,可能繞過基於 CAPTCHA 的人機驗證,構成安全風險。
|
| 47 |
+
* **魯棒性限制**:儘管使用了數據增強,模型對於極端的圖像失真、遮擋或對抗性攻擊可能仍然比較脆弱。
|
| 48 |
|
|
|
|
| 49 |
|
| 50 |
### Recommendations
|
| 51 |
|
| 52 |
+
強烈建議使用者在使用此模型前,充分了解其能力邊界和潛在風險。對於任何安全敏感的應用,不應依賴此模型作為唯一的防護措施。建議在使用或微調此模型時,對目標數據進行充分的評估和錯誤分析。
|
|
|
|
|
|
|
| 53 |
|
| 54 |
## How to Get Started with the Model
|
| 55 |
|
| 56 |
+
稍後會上傳訓練時使用的程式檔案
|
| 57 |
|
|
|
|
| 58 |
|
| 59 |
## Training Details
|
| 60 |
|
| 61 |
### Training Data
|
| 62 |
|
| 63 |
+
模型主要在 [gary109/captcha-synth-v3](https://www.google.com/search?q=https://huggingface.co/datasets/gary109/captcha-synth-v3) 數據集的 train split (約 120 萬張圖片) 上進行訓練。
|
| 64 |
+
該數據集包含帶有標籤的合成驗證碼圖片。
|
|
|
|
|
|
|
| 65 |
### Training Procedure
|
| 66 |
|
| 67 |
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
| 68 |
|
| 69 |
#### Preprocessing [optional]
|
| 70 |
|
| 71 |
+
訓練和驗證數據都經過了以下預處理:
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
+
1. **灰階轉換**:將圖片轉換為單通道灰階圖。
|
| 74 |
+
2. **保持長寬比縮放與填充 (PadAndResize)**:將圖片縮放到 50x200,同時保持原始長寬比,不足部分用黑色 (0) 填充。
|
| 75 |
+
3. **轉換為 Tensor**。
|
| 76 |
+
4. **歸一化**:將像素值歸一化到 \[-1, 1\] 範圍。
|
| 77 |
|
| 78 |
+
在微調階段,訓練集還額外應用了**數據增強**,包括:
|
| 79 |
|
| 80 |
+
* RandomAffine: 隨機旋轉 (±8°)、平移 (±10%)、縮放 (±10%)、錯切 (±5°)。
|
| 81 |
+
* RandomPerspective: 隨機透視變換。
|
| 82 |
+
* ColorJitter: 隨機調整亮度和對比度。
|
| 83 |
+
* RandomErasing: 隨機擦除圖片的一小塊區域。
|
| 84 |
|
|
|
|
|
|
|
|
|
|
| 85 |
|
| 86 |
+
#### Training Hyperparameters
|
| 87 |
+
見config
|
| 88 |
|
|
|
|
| 89 |
|
| 90 |
#### Testing Data
|
| 91 |
|
|
|
|
| 94 |
[More Information Needed]
|
| 95 |
|
| 96 |
#### Factors
|
| 97 |
+
未進行特定子群體或領域的分解評估。
|
|
|
|
|
|
|
|
|
|
| 98 |
|
| 99 |
#### Metrics
|
| 100 |
+
主要評估指標是 **完全匹配準確率 (Exact Match Accuracy)**:模型輸出的文字序列與真實標籤完全一致的樣本比例。同時,在分析中也考慮了錯誤類型(長度不匹配、替換錯誤、複雜錯誤)和字元替換混淆矩陣。
|
| 101 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
|
| 103 |
## Environmental Impact
|
| 104 |
|
|
|
|
| 106 |
|
| 107 |
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).
|
| 108 |
|
| 109 |
+
- **Hardware Type:** RTX 5070 Ti
|
| 110 |
+
- **Hours used:** 5
|
|
|
|
|
|
|
|
|
|
| 111 |
|
|
|
|
| 112 |
|
| 113 |
### Model Architecture and Objective
|
| 114 |
+
模型採用 CNN 作為視覺特徵提取器,隨後是一個多層 Transformer Encoder 負責序列建模。目標是通過 CTCLoss 最小化預測序列與真實標籤之間的差異。
|
| 115 |
[More Information Needed]
|
| 116 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
|
| 118 |
#### Software
|
| 119 |
|
| 120 |
+
* Python 3.13.6
|
| 121 |
+
* PyTorch 2.8.0+cu129
|
| 122 |
+
* Transformers 4.57.0
|
| 123 |
+
* Datasets 4.3.0
|
| 124 |
+
* CUDA 12.9
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|