File size: 3,963 Bytes
9a1739e
 
 
 
 
 
 
 
 
 
 
 
855ec97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
125
126
127
128
129
130
131
132
133
134
135
136
---
title: Card Id Counter
emoji: πŸ“Š
colorFrom: blue
colorTo: blue
sdk: gradio
sdk_version: 5.11.0
app_file: app.py
pinned: false
short_description: Cameroon Card ID Counter
---

# Voter Card Verification System

## Overview

This project is a web-based application for verifying voter card numbers using machine learning and database storage. Users upload an image of their voter card along with the card number. The application uses GroqCloud's LLM to verify:

1. If the provided number appears on the card.
2. If the card is of Cameroonian origin (by checking for the presence of "Cameroun" on the card).

If the verification is successful, the card number is saved in a local SQLite database.

## Features

* **Image and Text Verification** : Validates the voter card number and checks the origin of the card using GroqCloud's LLM with vision capabilities.
* **Database Integration** : Stores verified card numbers in a SQLite database, ensuring uniqueness.
* **User-Friendly Interface** : Provides an intuitive interface built with Gradio for easy interaction.

## Installation and Setup

### Prerequisites

1. Python 3.8 or later.
2. Required Python packages:
   * `gradio`
   * `pillow`
   * `sqlite3` (part of Python's standard library)
   * `groq` (GroqCloud Python SDK)
   * `base64` (part of Python's standard library)

### Steps

1. Clone this repository:
   ```bash
   git clone https://github.com/your-repo/voter-card-verification.git
   cd voter-card-verification
   ```
2. Install the required packages:
   ```bash
   pip install -r requirements.txt
   ```
3. Set up your GroqCloud API key:
   * Add your GroqCloud API key as an environment variable:
     ```bash
     export GROQ_API_KEY="your-api-key"
     ```
   * Specify the model ID as an environment variable:
     ```bash
     export GROQ_MODEL_ID="llama-3.2-11b-vision-preview"
     ```
4. Run the application:
   ```bash
   python app.py
   ```

## How It Works

1. **Initialization** :

* A SQLite database (`voter_cards.db`) is created to store voter card numbers.
* The GroqCloud client is initialized using the API key.

1. **User Interaction** :

* Users upload an image of their voter card and enter the card number in the Gradio interface.
* The image is converted to a base64-encoded string to send to the GroqCloud LLM.

1. **Verification** :

* The GroqCloud LLM is queried to check if:
  1. The provided number appears on the card.
  2. The card contains the word "Cameroun" to confirm its origin.
* The model responds with `true` if both conditions are met; otherwise, it responds with `false`.

1. **Database Storage** :

* If verification succeeds, the card number is stored in the SQLite database. Duplicate entries are prevented.

1. **Output** :

* Users receive feedback on whether the verification succeeded or failed.

## Project Structure

```
voter-card-verification/
β”‚
β”œβ”€β”€ app.py               # Main application file
β”œβ”€β”€ requirements.txt     # Python dependencies
β”œβ”€β”€ voter_cards.db       # SQLite database (auto-created on first run)
└── README.md            # Project documentation
```

## Usage

1. Open the application in your browser after launching it.
2. Upload an image of your voter card.
3. Enter the voter card number.
4. View the result of the verification.

## Notes

* Ensure the uploaded image is clear and readable.
* This application is tailored for verifying voter cards specific to Cameroon.

## Future Enhancements

* Integration with Firebase for cloud-based storage.
* Improved OCR fallback for local verification.
* Support for additional countries and card types.

## License

This project is licensed under the MIT License. See the `LICENSE` file for details.

## Acknowledgments

* [GroqCloud](https://www.groq.com/) for their advanced LLM capabilities.
* [Gradio](https://www.gradio.app/) for the user-friendly web interface.

---

For any questions or issues, feel free to open an issue in the repository.