An open API service indexing awesome lists of open source software.

https://github.com/morellodev/image-signature-classifier

A deep learning-based model that detects whether an image contains a valid handwritten signature or not. Built with MobileNetV2 + Transfer Learning.
https://github.com/morellodev/image-signature-classifier

Last synced: 3 months ago
JSON representation

A deep learning-based model that detects whether an image contains a valid handwritten signature or not. Built with MobileNetV2 + Transfer Learning.

Awesome Lists containing this project

README

          

# ✍️ Signature Classification Model

## 🚀 Overview

This project is a **signature classification model** that determines whether an image contains a **valid handwritten signature** or not. The model is based on **deep learning** and includes a **FastAPI server** for easy deployment and real-time classification.

## 📌 Features

- ✅ Detects whether an image contains a valid signature.
- ✅ Uses **MobileNetV2 + Transfer Learning** for efficient classification.
- ✅ Includes a **FastAPI server** for easy testing and deployment.
- ✅ Supports **image uploads via API**.
- ✅ Can be deployed locally or to **Docker, Render, or AWS**.

---

## 🛠 Installation

### 1️⃣ **Clone the repository**

```bash
git clone https://github.com/your-username/signature-classifier.git
cd signature-classifier
```

### 2️⃣ Create a virtual environment (optional but recommended)

```bash
python -m venv venv-name
source venv-name/bin/activate # On macOS/Linux
venv-name\Scripts\activate # On Windows
```

### 3️⃣ Install dependencies

```bash
pip install -r requirements.txt
```

### 4️⃣ Download the Dataset

Download the **signature dataset** from the [CEDAR Signature Dataset](https://paperswithcode.com/dataset/cedar-signature) page.

Extract the dataset into the `dataset/` folder with the following structure:

```raw
📂 dataset/
├── 📂 train/ # Training data (80% of the dataset)
│ ├── 📂 valid_signature/ # Contains genuine signatures
│ ├── 📂 invalid_signature/ # Contains forged or non-signature images

├── 📂 val/ # Validation data (10% of the dataset)
│ ├── 📂 valid_signature/
│ ├── 📂 invalid_signature/

├── 📂 test/ # Test data (10% of the dataset)
│ ├── 📂 valid_signature/
│ ├── 📂 invalid_signature/
```

## ▶️ Running the API Locally

Once dependencies are installed, you can **start the API** using FastAPI and Uvicorn.

```bash
uvicorn app:app --host 0.0.0.0 --port 8000 --reload
```

Your API will be accessible at [http://127.0.0.1:8000](http://127.0.0.1:8000).

## 🔍 How to Use the API

### 1️⃣ Upload an Image for Classification

Example using **cURL**:

```bash
curl -X 'POST' 'http://127.0.0.1:8000/predict/' \
-H 'accept: application/json' \
-H 'Content-Type: multipart/form-data' \
-F 'file=@dataset/test/valid_signature/sample.png'
```

### 2️⃣ Expected API Response

```json
{
"filename": "sample.png",
"prediction": "Valid Signature ✅",
"confidence": "98.32%"
}
```

## 🛠 Model Training

The model is trained using **MobileNetV2 + Transfer Learning**. The training script (`train.py`) does the following:

1. **Loads the dataset** of valid and invalid signatures.
2. **Uses MobileNetV2** as a feature extractor.
3. **Trains with frozen layers**, then fine-tunes the last layers.
4. **Saves the trained model** (`signature_classifier_finetuned.keras`).

To train the model, run:

```bash
python train.py
```

## 📄 Project Structure

```raw
📂 signature-classifier/
├── 📂 dataset/ # Training data (valid & invalid signatures)
├── 📜 app.py # FastAPI server
├── 📜 train.py # Model training script
├── 📜 classify.py # Local testing script
├── 📜 requirements.txt # Dependencies
├── 📜 README.md # Project documentation
```