ankandrew commited on
Commit
a243be8
·
verified ·
1 Parent(s): dbad90d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -12
app.py CHANGED
@@ -3,10 +3,6 @@ from open_image_models import LicensePlateDetector
3
  from PIL import Image
4
  import cv2
5
  import numpy as np
6
- from rich.console import Console
7
-
8
- # Set up the rich console for better terminal output
9
- console = Console()
10
 
11
  # Define the available models
12
  PlateDetectorModel = ['yolo-v9-t-640-license-plate-end2end',
@@ -15,11 +11,11 @@ PlateDetectorModel = ['yolo-v9-t-640-license-plate-end2end',
15
  'yolo-v9-t-256-license-plate-end2end']
16
 
17
  # Streamlit interface
18
- st.title("🚗 License Plate Detection with Open Image Models 🚓")
19
- st.write("Select a model and upload an image to perform license plate detection.")
20
  st.markdown("---")
21
 
22
- # Model selection dropdown
23
  selected_model = st.selectbox("🔍 Select a License Plate Detection Model", PlateDetectorModel)
24
 
25
  # File uploader for images
@@ -43,14 +39,18 @@ if uploaded_file is not None:
43
  # Perform license plate detection
44
  detections = lp_detector.predict(image_cv2)
45
 
46
- # Display the detected plates using `rich` for colorful output in the console
47
- console.print(f"[bold green]Detections: [/bold green] {detections}")
48
-
49
  # Streamlit display for detections
50
  if detections:
51
  st.success(f"✅ {len(detections)} License Plates Detected!")
52
- for i, detection in enumerate(detections):
53
- st.write(f"**Plate {i+1}:** {detection}")
 
 
 
 
 
 
 
54
  else:
55
  st.warning("⚠️ No license plates detected!")
56
 
@@ -70,5 +70,9 @@ st.markdown("""
70
  color: white;
71
  border-radius: 8px;
72
  }
 
 
 
 
73
  </style>
74
  """, unsafe_allow_html=True)
 
3
  from PIL import Image
4
  import cv2
5
  import numpy as np
 
 
 
 
6
 
7
  # Define the available models
8
  PlateDetectorModel = ['yolo-v9-t-640-license-plate-end2end',
 
11
  'yolo-v9-t-256-license-plate-end2end']
12
 
13
  # Streamlit interface
14
+ st.title("🦀 Open Image Models: Pre-trained Models for Object Detection")
15
+ st.write("Leverage fast and efficient pre-trained ONNX models for various object detection tasks, starting with license plate detection.")
16
  st.markdown("---")
17
 
18
+ # Model selection dropdown (specific to license plate detection in this example)
19
  selected_model = st.selectbox("🔍 Select a License Plate Detection Model", PlateDetectorModel)
20
 
21
  # File uploader for images
 
39
  # Perform license plate detection
40
  detections = lp_detector.predict(image_cv2)
41
 
 
 
 
42
  # Streamlit display for detections
43
  if detections:
44
  st.success(f"✅ {len(detections)} License Plates Detected!")
45
+
46
+ # Use an expander to show details in a more organized way
47
+ with st.expander("See detected plates details"):
48
+ for i, detection in enumerate(detections):
49
+ st.markdown(f"""
50
+ **Plate {i+1}:**
51
+ - **Bounding Box:** {detection['bbox']}
52
+ - **Confidence:** {detection['confidence']:.2f}
53
+ """)
54
  else:
55
  st.warning("⚠️ No license plates detected!")
56
 
 
70
  color: white;
71
  border-radius: 8px;
72
  }
73
+ .stImage img {
74
+ border-radius: 10px;
75
+ padding: 10px;
76
+ }
77
  </style>
78
  """, unsafe_allow_html=True)