gopichandra commited on
Commit
a9b1adf
·
verified ·
1 Parent(s): daeb81c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -4
app.py CHANGED
@@ -1,19 +1,30 @@
1
  import gradio as gr
2
  from utils import extract_kyc_fields
 
3
 
4
  def process_document(file):
5
  try:
6
  result = extract_kyc_fields(file.name)
7
  return result
8
  except Exception as e:
9
- return {"error": str(e)}
 
 
 
10
 
11
  iface = gr.Interface(
12
  fn=process_document,
13
- inputs=gr.File(label="Upload Aadhaar/PAN image"),
 
 
 
14
  outputs=gr.JSON(label="Extracted KYC Fields"),
15
- title="Smart KYC OCR",
16
- description="Upload an Aadhaar or PAN card image to extract structured KYC fields using Tesseract OCR"
 
 
 
 
17
  )
18
 
19
  if __name__ == "__main__":
 
1
  import gradio as gr
2
  from utils import extract_kyc_fields
3
+ import traceback
4
 
5
  def process_document(file):
6
  try:
7
  result = extract_kyc_fields(file.name)
8
  return result
9
  except Exception as e:
10
+ return {
11
+ "error": f"Failed to process image.\n{str(e)}",
12
+ "traceback": traceback.format_exc()
13
+ }
14
 
15
  iface = gr.Interface(
16
  fn=process_document,
17
+ inputs=gr.File(
18
+ label="Upload Aadhaar/PAN image",
19
+ file_types=[".jpg", ".jpeg", ".png", ".webp", ".tiff", ".bmp"]
20
+ ),
21
  outputs=gr.JSON(label="Extracted KYC Fields"),
22
+ title="🔍 Smart KYC OCR",
23
+ description=(
24
+ "Upload an image of an Aadhaar or PAN card, and this tool will extract key KYC fields like "
25
+ "**Name**, **Aadhaar Number**, and **Date of Birth** using Tesseract OCR."
26
+ ),
27
+ theme="dark"
28
  )
29
 
30
  if __name__ == "__main__":