logasanjeev commited on
Commit
4b3e4fe
·
verified ·
1 Parent(s): 8b05dd3

Update inference.py

Browse files
Files changed (1) hide show
  1. inference.py +4 -2
inference.py CHANGED
@@ -122,9 +122,10 @@ def process_id(image_path, model_name=None, save_json=True, output_json="detecte
122
  continue
123
  conf = box.conf[0].item()
124
  xyxy = box.xyxy[0].tolist()
 
 
125
  if cls not in filtered_boxes or conf > filtered_boxes[cls]["conf"]:
126
- filtered_boxes[cls] = {"conf": conf, "xyxy": xyxy, "class_name": class_names[cls]}
127
- logger.info(f"Detected box for class: {class_names[cls]}, confidence: {conf:.2f}")
128
  except IndexError as e:
129
  logger.error(f"Error processing box: {e}, box data: {box}")
130
  continue
@@ -165,6 +166,7 @@ def process_id(image_path, model_name=None, save_json=True, output_json="detecte
165
  extracted_text = " ".join(
166
  word_info[1][0] for line in ocr_result for word_info in line if word_info and len(word_info) > 1 and len(word_info[1]) > 0
167
  ) if ocr_result else "No text detected"
 
168
  detected_text[class_name] = extracted_text
169
 
170
  # Draw OCR bounding boxes
 
122
  continue
123
  conf = box.conf[0].item()
124
  xyxy = box.xyxy[0].tolist()
125
+ class_name = class_names[cls]
126
+ logger.info(f"Detected box for class index: {cls}, class name: {class_name}, confidence: {conf:.2f}, coords: {xyxy}")
127
  if cls not in filtered_boxes or conf > filtered_boxes[cls]["conf"]:
128
+ filtered_boxes[cls] = {"conf": conf, "xyxy": xyxy, "class_name": class_name}
 
129
  except IndexError as e:
130
  logger.error(f"Error processing box: {e}, box data: {box}")
131
  continue
 
166
  extracted_text = " ".join(
167
  word_info[1][0] for line in ocr_result for word_info in line if word_info and len(word_info) > 1 and len(word_info[1]) > 0
168
  ) if ocr_result else "No text detected"
169
+ logger.info(f"Extracted text for {class_name}: {extracted_text}")
170
  detected_text[class_name] = extracted_text
171
 
172
  # Draw OCR bounding boxes