Update app.py
Browse files
app.py
CHANGED
@@ -28,14 +28,17 @@ st.write("Upload an image to detect vehicle license plates along with their conf
|
|
28 |
uploaded_image = st.file_uploader("Choose an image", type=["jpg", "jpeg", "png"])
|
29 |
|
30 |
if uploaded_image is not None:
|
|
|
|
|
|
|
|
|
|
|
31 |
# Display the uploaded image
|
32 |
-
image = Image.open(
|
33 |
st.image(image, caption="Uploaded Image", use_column_width=True)
|
34 |
|
35 |
# Run YOLOv8 inference
|
36 |
with st.spinner("Running detection..."):
|
37 |
-
temp_file = tempfile.NamedTemporaryFile(delete=False)
|
38 |
-
temp_file.write(uploaded_image.read())
|
39 |
results = model(temp_file.name)
|
40 |
|
41 |
# Draw bounding boxes and confidence scores on the image
|
@@ -60,3 +63,6 @@ if uploaded_image is not None:
|
|
60 |
# Show individual detections in a table
|
61 |
st.write("### Detection Results")
|
62 |
st.write(results_table)
|
|
|
|
|
|
|
|
28 |
uploaded_image = st.file_uploader("Choose an image", type=["jpg", "jpeg", "png"])
|
29 |
|
30 |
if uploaded_image is not None:
|
31 |
+
# Save the uploaded image to a temporary file
|
32 |
+
temp_file = tempfile.NamedTemporaryFile(delete=False, suffix=".jpg") # Ensure proper file extension
|
33 |
+
temp_file.write(uploaded_image.read())
|
34 |
+
temp_file.close()
|
35 |
+
|
36 |
# Display the uploaded image
|
37 |
+
image = Image.open(temp_file.name)
|
38 |
st.image(image, caption="Uploaded Image", use_column_width=True)
|
39 |
|
40 |
# Run YOLOv8 inference
|
41 |
with st.spinner("Running detection..."):
|
|
|
|
|
42 |
results = model(temp_file.name)
|
43 |
|
44 |
# Draw bounding boxes and confidence scores on the image
|
|
|
63 |
# Show individual detections in a table
|
64 |
st.write("### Detection Results")
|
65 |
st.write(results_table)
|
66 |
+
|
67 |
+
# Remove temporary files (optional cleanup)
|
68 |
+
os.unlink(temp_file.name)
|