File size: 889 Bytes
c8d472e
fa803dc
a9b1adf
c8d472e
fa803dc
4ab2cd6
 
 
 
a9b1adf
 
 
 
a1903a9
fa803dc
 
a9b1adf
 
 
 
fa803dc
a9b1adf
 
 
 
 
 
fa803dc
a1903a9
fa803dc
 
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
import gradio as gr
from utils import extract_kyc_fields
import traceback

def process_document(file):
    try:
        result = extract_kyc_fields(file.name)
        return result
    except Exception as e:
        return {
            "error": f"Failed to process image.\n{str(e)}",
            "traceback": traceback.format_exc()
        }

iface = gr.Interface(
    fn=process_document,
    inputs=gr.File(
        label="Upload Aadhaar/PAN image",
        file_types=[".jpg", ".jpeg", ".png", ".webp", ".tiff", ".bmp"]
    ),
    outputs=gr.JSON(label="Extracted KYC Fields"),
    title="🔍 Smart KYC OCR",
    description=(
        "Upload an image of an Aadhaar or PAN card, and this tool will extract key KYC fields like "
        "**Name**, **Aadhaar Number**, and **Date of Birth** using Tesseract OCR."
    ),
    theme="dark"
)

if __name__ == "__main__":
    iface.launch()