Update app.py
Browse files
app.py
CHANGED
@@ -27,7 +27,7 @@ def detect_license_plate(image):
|
|
27 |
for box, conf in zip(result.boxes.xyxy, result.boxes.conf):
|
28 |
x1, y1, x2, y2 = map(int, box) # Convert to integers
|
29 |
cv2.rectangle(img, (x1, y1), (x2, y2), (0, 255, 0), 2) # Green rectangle
|
30 |
-
label = f"
|
31 |
cv2.putText(img, label, (x1, y1 - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2)
|
32 |
|
33 |
# Convert back to RGB for Streamlit display
|
@@ -42,13 +42,10 @@ st.write("Upload an image to detect license plates.")
|
|
42 |
uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
|
43 |
|
44 |
if uploaded_file is not None:
|
45 |
-
#
|
46 |
-
image = Image.open(uploaded_file)
|
47 |
-
st.image(image, caption="Uploaded Image", use_column_width=True)
|
48 |
-
|
49 |
-
# Run detection
|
50 |
st.write("Processing...")
|
|
|
51 |
result_image = detect_license_plate(image)
|
52 |
|
53 |
-
# Display the
|
54 |
-
st.image(result_image, caption="Detection Results",
|
|
|
27 |
for box, conf in zip(result.boxes.xyxy, result.boxes.conf):
|
28 |
x1, y1, x2, y2 = map(int, box) # Convert to integers
|
29 |
cv2.rectangle(img, (x1, y1), (x2, y2), (0, 255, 0), 2) # Green rectangle
|
30 |
+
label = f"{conf:.2f}"
|
31 |
cv2.putText(img, label, (x1, y1 - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2)
|
32 |
|
33 |
# Convert back to RGB for Streamlit display
|
|
|
42 |
uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
|
43 |
|
44 |
if uploaded_file is not None:
|
45 |
+
# Run detection directly after uploading
|
|
|
|
|
|
|
|
|
46 |
st.write("Processing...")
|
47 |
+
image = Image.open(uploaded_file)
|
48 |
result_image = detect_license_plate(image)
|
49 |
|
50 |
+
# Display the detection result
|
51 |
+
st.image(result_image, caption="Detection Results", use_container_width=True)
|