|
1 | | -# 🧩 Game Xếp Hình (Jigsaw Puzzle Web Game) |
2 | 1 |
|
3 | | -Chào mừng bạn đến với dự án Game Xếp Hình! Đây là một trò chơi giải đố vui nhộn dựa trên web, nơi bạn có thể thử thách khả năng quan sát và tư duy logic của mình bằng cách lắp ráp các mảnh ghép thành một bức tranh hoàn chỉnh. |
| 2 | +# Handwriting Signature Writer Identification using CNN |
4 | 3 |
|
5 | | - |
6 | | -*<p align="center">Giao diện chính của trò chơi</p>* |
| 4 | +This project implements a Convolutional Neural Network (CNN) model to identify the writer of a given handwritten signature. The model is trained on a dataset of genuine and forged signatures, and it aims to classify a new signature sample to its respective writer. |
| 5 | + |
| 6 | +Developed in Google Colab using TensorFlow and Keras. |
| 7 | + |
| 8 | + <!-- Replace with your result screenshot --> |
| 9 | + |
| 10 | +--- |
| 11 | + |
| 12 | +## Table of Contents |
| 13 | + |
| 14 | +- [Project Overview](#project-overview) |
| 15 | +- [Dataset](#dataset) |
| 16 | +- [Methodology](#methodology) |
| 17 | + - [Data Preprocessing](#data-preprocessing) |
| 18 | + - [Model Architecture](#model-architecture) |
| 19 | + - [Training](#training) |
| 20 | +- [Results](#results) |
| 21 | +- [How to Use](#how-to-use) |
| 22 | + - [Prerequisites](#prerequisites) |
| 23 | + - [Setup](#setup) |
| 24 | + - [Running the Notebook](#running-the-notebook) |
| 25 | +- [Future Work](#future-work) |
| 26 | +- [Author](#author) |
| 27 | +- [Acknowledgments](#acknowledgments) |
| 28 | + |
| 29 | +--- |
| 30 | + |
| 31 | +## Project Overview |
| 32 | + |
| 33 | +The goal is to build a system that identifies the author of a handwritten signature. This has applications in forensics and document verification. A CNN is used due to its effectiveness in image recognition tasks. |
7 | 34 |
|
8 | 35 | --- |
9 | 36 |
|
10 | | -## ✨ Tính Năng Nổi Bật |
| 37 | +## Dataset |
11 | 38 |
|
12 | | -* **Giao diện Kéo và Thả (Drag & Drop):** Dễ dàng di chuyển các mảnh ghép vào đúng vị trí trên bảng chơi. |
13 | | -* **Xoay Mảnh Ghép:** Chỉ cần một cú click để xoay mảnh ghép 90 độ theo chiều kim đồng hồ. |
14 | | -* **Nhiều Bộ Ảnh:** Lựa chọn từ nhiều bộ ảnh với các chủ đề và độ khó khác nhau (tùy thuộc vào ảnh). |
15 | | -* **Ảnh Tham Chiếu:** Luôn có ảnh gốc hoàn chỉnh để bạn đối chiếu trong quá trình chơi. |
16 | | -* **Bộ Đếm Thời Gian:** Theo dõi và thử thách bản thân để hoàn thành game trong thời gian nhanh nhất. |
17 | | -* **Kiểm Tra & Thông Báo Chiến Thắng:** Game tự động nhận biết khi bạn hoàn thành và hiển thị thông báo chúc mừng cùng thời gian thực hiện. |
18 | | -* **Giao diện Thân Thiện:** Sử dụng Bootstrap để đảm bảo trải nghiệm tốt trên nhiều kích thước màn hình. |
| 39 | +The dataset contains handwritten signatures from multiple writers, including both genuine (`full_org`) and forged (`full_forg`) samples. |
| 40 | + |
| 41 | +- **Source:** [Add dataset name/link or brief explanation if private] |
| 42 | +- **Structure:** |
| 43 | + - Example filenames: `original_58_1.png`, `forgeries_1_10.png` |
| 44 | +- **Image Format:** PNG, TIFF, or JPG |
| 45 | + |
| 46 | +> **Note on Privacy:** All data has been anonymized and used solely for research purposes. Ensure proper consent when using real signature data. |
19 | 47 |
|
20 | 48 | --- |
21 | 49 |
|
22 | | -## 🛠️ Công Nghệ Sử Dụng |
| 50 | +## Methodology |
| 51 | + |
| 52 | +### Data Preprocessing |
| 53 | + |
| 54 | +- **Loading:** Signature paths collected from Google Drive |
| 55 | +- **Labeling:** Writer IDs extracted from filenames |
| 56 | +- **Encoding:** String IDs converted to integers |
| 57 | +- **Splitting:** 80/20 train-validation split (with stratification) |
| 58 | +- **Image Processing:** |
| 59 | + - Resize to `64x256` |
| 60 | + - Grayscale (1 channel) |
| 61 | + - Normalize pixel values `[0, 1]` |
| 62 | + |
| 63 | +> **TensorFlow Dataset Pipeline** is used for efficient loading, batching, and prefetching. |
| 64 | +
|
| 65 | +--- |
| 66 | + |
| 67 | +### Model Architecture |
| 68 | + |
| 69 | +CNN model structure: |
| 70 | + |
| 71 | +```text |
| 72 | +Model: "sequential" |
| 73 | +_________________________________________________________________ |
| 74 | + Layer (type) Output Shape Param # |
| 75 | +================================================================= |
| 76 | + conv2d (Conv2D) (None, 62, 254, 32) 320 |
| 77 | + max_pooling2d (MaxPooling2D) (None, 31, 127, 32) 0 |
| 78 | + conv2d_1 (Conv2D) (None, 29, 125, 64) 18496 |
| 79 | + max_pooling2d_1 (MaxPooling2D) (None, 14, 62, 64) 0 |
| 80 | + conv2d_2 (Conv2D) (None, 12, 60, 128) 73856 |
| 81 | + max_pooling2d_2 (MaxPooling2D) (None, 6, 30, 128) 0 |
| 82 | + flatten (Flatten) (None, 23040) 0 |
| 83 | + dense (Dense) (None, 128) 2949248 |
| 84 | + dropout (Dropout) (None, 128) 0 |
| 85 | + dense_1 (Dense) (None, 55) 7095 |
| 86 | +================================================================= |
| 87 | +Total params: 3,046,015 |
| 88 | +Trainable params: 3,046,015 |
| 89 | +Non-trainable params: 0 |
| 90 | +_________________________________________________________________ |
| 91 | +``` |
| 92 | + |
| 93 | + |
| 94 | + |
| 95 | +--- |
| 96 | + |
| 97 | +### Training |
| 98 | + |
| 99 | +* **Optimizer:** Adam |
| 100 | +* **Loss:** `SparseCategoricalCrossentropy(from_logits=True)` |
| 101 | +* **Metrics:** Accuracy |
| 102 | +* **Epochs:** 30 (or adjust as needed) |
23 | 103 |
|
24 | | -* **Ngôn ngữ:** HTML5, CSS3, JavaScript (ES6+) |
25 | | -* **Thư viện/Framework:** |
26 | | - * **jQuery:** Hỗ trợ thao tác DOM và xử lý sự kiện. |
27 | | - * **Bootstrap 4:** Cung cấp các thành phần giao diện và hệ thống lưới responsive. |
| 104 | +Training history includes plots for accuracy and loss across epochs. |
28 | 105 |
|
29 | 106 | --- |
30 | 107 |
|
31 | | -## 🚀 Bắt Đầu Nhanh (Getting Started) |
| 108 | +## Results |
32 | 109 |
|
33 | | -Chơi game thật đơn giản: |
| 110 | +On validation set: |
34 | 111 |
|
35 | | -1. **Tải về dự án:** |
36 | | - * Cách 1: Clone repository (nếu có): |
37 | | - ```bash |
38 | | - git clone [Đường dẫn đến repository của bạn, nếu có] |
39 | | - cd [Tên thư mục dự án] |
| 112 | +* **Validation Accuracy:** 95.83% |
| 113 | +* **Validation Loss:** 0.25 |
| 114 | + |
| 115 | +**Training and Validation Accuracy:** |
| 116 | + |
| 117 | + |
| 118 | +**Training and Validation Loss:** |
| 119 | + |
| 120 | + |
| 121 | +**Example Test (Writer ID: 58):** |
| 122 | + |
| 123 | +* **Accuracy:** 95.83% (23/24 correct) |
| 124 | + |
| 125 | +--- |
| 126 | + |
| 127 | +## How to Use |
| 128 | + |
| 129 | +### Prerequisites |
| 130 | + |
| 131 | +* Google Colab or local Python environment |
| 132 | +* Python Libraries: |
| 133 | + |
| 134 | + * TensorFlow (2.x) |
| 135 | + * NumPy |
| 136 | + * Matplotlib |
| 137 | + * scikit-learn |
| 138 | + * Pillow |
| 139 | + |
| 140 | +### Setup |
| 141 | + |
| 142 | +1. **Clone the repo (optional):** |
| 143 | + |
| 144 | + ```bash |
| 145 | + git clone https://github.com/TranHuuDat2004/handwriting-signature-recognition.git |
| 146 | + cd handwriting-signature-recognition |
| 147 | + ``` |
| 148 | + |
| 149 | +2. **Upload Notebook to Colab** |
| 150 | + |
| 151 | +3. **Prepare Dataset:** |
| 152 | + |
| 153 | + * Upload dataset to Google Drive |
| 154 | + * Update `BASE_DATA_DIR` in the notebook: |
| 155 | + |
| 156 | + ```python |
| 157 | + BASE_DATA_DIR = '/content/drive/MyDrive/YOUR_PATH_TO/SIGNATURES' |
40 | 158 | ``` |
41 | | - * Cách 2: Tải file ZIP của dự án và giải nén ra một thư mục. |
42 | | -2. **Mở file HTML:** Tìm đến file `index.html` (hoặc `game.html`) trong thư mục vừa giải nén và mở nó bằng trình duyệt web yêu thích của bạn (Chrome, Firefox, Edge,...). |
43 | 159 |
|
44 | | -Vậy là xong! Bạn đã có thể bắt đầu chơi game ngay lập tức. |
| 160 | +--- |
| 161 | + |
| 162 | +### Running the Notebook |
| 163 | + |
| 164 | +1. **Mount Google Drive** |
| 165 | +2. **Run cells sequentially:** |
| 166 | + |
| 167 | + * Collect paths and labels |
| 168 | + * Preprocess images |
| 169 | + * Create Dataset objects |
| 170 | + * Build and train the model |
| 171 | + * Evaluate and save model |
| 172 | + * Predict single or batch samples |
| 173 | + * Evaluate on a specific writer ID |
45 | 174 |
|
46 | 175 | --- |
47 | 176 |
|
48 | | -## 🤝 Đóng Góp (Contributing) |
| 177 | +## Future Work |
49 | 178 |
|
50 | | -Mọi ý tưởng đóng góp, báo lỗi hoặc đề xuất cải thiện đều được chào đón! Vui lòng [Mở một Issue]([Link tới trang Issues trên repo của bạn, nếu có]) để chúng ta có thể thảo luận chi tiết hơn. |
| 179 | +* Try ResNet, VGG, or MobileNet |
| 180 | +* Improve data augmentation |
| 181 | +* Explore Siamese Networks for signature verification |
| 182 | +* Build a web interface (e.g., with Streamlit) |
| 183 | +* Train on larger datasets |
51 | 184 |
|
52 | 185 | --- |
53 | 186 |
|
54 | | -## 📝 Giấy Phép (License) |
| 187 | +## Author |
55 | 188 |
|
56 | | -Dự án này được phân phối dưới giấy phép [MIT]([Link tới file LICENSE của bạn, nếu có] - ví dụ: LICENSE). Xem file `LICENSE` để biết thêm chi tiết. |
| 189 | +**Tran Huu Dat** |
| 190 | +GitHub: [@TranHuuDat2004](https://github.com/TranHuuDat2004) |
| 191 | +\[LinkedIn or Portfolio link - optional] |
57 | 192 |
|
58 | 193 | --- |
59 | 194 |
|
60 | | -## 👤 Tác Giả |
| 195 | +## Acknowledgments |
61 | 196 |
|
62 | | -* **[Tên Của Bạn hoặc Tên Nhóm]** |
63 | | -* **Liên hệ:** [Địa chỉ email hoặc link mạng xã hội của bạn] |
| 197 | +* TensorFlow and Keras for deep learning frameworks |
| 198 | +* Google Colab for providing a free GPU environment |
| 199 | +* [Your dataset source or research papers if applicable] |
64 | 200 |
|
65 | | -Cảm ơn bạn đã quan tâm đến dự án Game Xếp Hình! Chúc bạn chơi game vui vẻ! 🎉 |
| 201 | +--- |
0 commit comments