Sourudra commited on
Commit
2f69058
·
verified ·
1 Parent(s): b82945e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -17
app.py CHANGED
@@ -27,28 +27,13 @@ ocr_reader = load_easyocr_reader()
27
  def process_image(image, confidence_threshold=0.5):
28
  # Perform license plate detection
29
  results = yolo_model(image, conf=confidence_threshold)
30
- annotated_image = image.copy() # Work on a copy to draw the bounding boxes
31
 
32
- # Loop through detections and draw red, thicker bounding boxes
33
- for result in results:
34
- boxes = result.boxes.xyxy.cpu().numpy().astype(int)
35
- if len(boxes) == 0:
36
- st.warning("No license plate detected!")
37
- return
38
-
39
- for box in boxes:
40
- x1, y1, x2, y2 = box
41
- # Draw the bounding box (red, thickness 3)
42
- cv2.rectangle(annotated_image, (x1, y1), (x2, y2), (255, 0, 0), 3)
43
-
44
- # Convert to RGB for display
45
- annotated_image_rgb = cv2.cvtColor(annotated_image, cv2.COLOR_BGR2RGB)
46
-
47
  # Create columns to display the uploaded image, cropped image, and extracted text side by side
48
  c1, c2 = st.columns(2)
49
 
50
  with c1:
51
- st.image(annotated_image_rgb, caption="Detected License Plate(s)", use_container_width=True)
52
 
53
  # Loop through detections and perform OCR
54
  for result in results:
 
27
  def process_image(image, confidence_threshold=0.5):
28
  # Perform license plate detection
29
  results = yolo_model(image, conf=confidence_threshold)
30
+ annotated_image = cv2.cvtColor(results[0].plot(), cv2.COLOR_BGR2RGB)
31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  # Create columns to display the uploaded image, cropped image, and extracted text side by side
33
  c1, c2 = st.columns(2)
34
 
35
  with c1:
36
+ st.image(annotated_image, caption="Detected License Plate(s)", use_container_width=True)
37
 
38
  # Loop through detections and perform OCR
39
  for result in results: