Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,14 +1,14 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
from PIL import Image
|
4 |
import cv2
|
5 |
import numpy as np
|
|
|
|
|
|
|
|
|
6 |
|
7 |
# Define the available models
|
8 |
-
|
9 |
-
'yolo-v9-t-512-license-plate-end2end',
|
10 |
-
'yolo-v9-t-384-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")
|
@@ -16,7 +16,7 @@ st.write("Leverage fast and efficient pre-trained ONNX models for various object
|
|
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",
|
20 |
|
21 |
# File uploader for images
|
22 |
uploaded_file = st.file_uploader("π Upload an image...", type=["jpg", "png", "jpeg", "webp"])
|
@@ -42,15 +42,15 @@ if uploaded_file is not None:
|
|
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 |
# Access attributes of the DetectionResult class
|
50 |
bbox = detection.bounding_box
|
51 |
st.markdown(f"""
|
52 |
-
**Plate {i+1}:**
|
53 |
-
- **Label:** {detection.label}
|
54 |
- **Confidence:** {detection.confidence:.2f}
|
55 |
- **Bounding Box:** (x1: {bbox.x1}, y1: {bbox.y1}, x2: {bbox.x2}, y2: {bbox.y2})
|
56 |
""")
|
|
|
1 |
+
from typing import get_args
|
2 |
+
|
|
|
3 |
import cv2
|
4 |
import numpy as np
|
5 |
+
import streamlit as st
|
6 |
+
from PIL import Image
|
7 |
+
|
8 |
+
from open_image_models.detection.core.hub import PlateDetectorModel
|
9 |
|
10 |
# Define the available models
|
11 |
+
detection_models = get_args(PlateDetectorModel)
|
|
|
|
|
|
|
12 |
|
13 |
# Streamlit interface
|
14 |
st.title("π¦ Open Image Models: Pre-trained Models for Object 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", detection_models)
|
20 |
|
21 |
# File uploader for images
|
22 |
uploaded_file = st.file_uploader("π Upload an image...", type=["jpg", "png", "jpeg", "webp"])
|
|
|
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 |
# Access attributes of the DetectionResult class
|
50 |
bbox = detection.bounding_box
|
51 |
st.markdown(f"""
|
52 |
+
**Plate {i+1}:**
|
53 |
+
- **Label:** {detection.label}
|
54 |
- **Confidence:** {detection.confidence:.2f}
|
55 |
- **Bounding Box:** (x1: {bbox.x1}, y1: {bbox.y1}, x2: {bbox.x2}, y2: {bbox.y2})
|
56 |
""")
|