maliahson commited on
Commit
bffb9de
·
verified ·
1 Parent(s): c61a667

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -11
app.py CHANGED
@@ -55,7 +55,7 @@ def process_front_cnic(image):
55
  return {"error": f"Front CNIC processing error: {e}"}
56
 
57
  def process_back_cnic(image):
58
- """Process back CNIC image to extract QR code, Barcode, and CNIC number."""
59
  if image is None:
60
  return {"error": "No image provided"}
61
 
@@ -71,14 +71,7 @@ def process_back_cnic(image):
71
  x1, y1, x2, y2 = map(int, box.xyxy[0])
72
  roi = img[y1:y2, x1:x2]
73
 
74
- if cls_name == "qr scan":
75
- try:
76
- qr_result = decode(Image.fromarray(cv2.cvtColor(roi, cv2.COLOR_BGR2RGB)))
77
- output["QR Scan"] = qr_result[0].data.decode('utf-8') if qr_result else "No QR code detected"
78
- except Exception as e:
79
- output["QR Scan"] = f"QR decode error: {e}"
80
-
81
- elif cls_name == "barcode":
82
  try:
83
  barcode_result = decode(Image.fromarray(cv2.cvtColor(roi, cv2.COLOR_BGR2RGB)))
84
  output["Barcode"] = barcode_result[0].data.decode('utf-8') if barcode_result else "No barcode detected"
@@ -104,7 +97,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
104
  # CNIC Detection and Information Extraction
105
  Upload front and back CNIC images to extract information.
106
  - **Front CNIC**: Extracts Name, Age, DOB, Father's Name, etc.
107
- - **Back CNIC**: Extracts QR Code, Barcode, and CNIC number.
108
  """
109
  )
110
 
@@ -144,4 +137,4 @@ api = gr.Interface(
144
  )
145
 
146
  if __name__ == "__main__":
147
- demo.launch()
 
55
  return {"error": f"Front CNIC processing error: {e}"}
56
 
57
  def process_back_cnic(image):
58
+ """Process back CNIC image to extract Barcode and CNIC number (no QR code processing)."""
59
  if image is None:
60
  return {"error": "No image provided"}
61
 
 
71
  x1, y1, x2, y2 = map(int, box.xyxy[0])
72
  roi = img[y1:y2, x1:x2]
73
 
74
+ if cls_name == "barcode":
 
 
 
 
 
 
 
75
  try:
76
  barcode_result = decode(Image.fromarray(cv2.cvtColor(roi, cv2.COLOR_BGR2RGB)))
77
  output["Barcode"] = barcode_result[0].data.decode('utf-8') if barcode_result else "No barcode detected"
 
97
  # CNIC Detection and Information Extraction
98
  Upload front and back CNIC images to extract information.
99
  - **Front CNIC**: Extracts Name, Age, DOB, Father's Name, etc.
100
+ - **Back CNIC**: Extracts Barcode and CNIC number (QR code processing removed).
101
  """
102
  )
103
 
 
137
  )
138
 
139
  if __name__ == "__main__":
140
+ demo.launch()