Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,7 @@ from PIL import Image
|
|
4 |
import os
|
5 |
|
6 |
# Load the trained YOLOv8 model
|
7 |
-
model = YOLO("
|
8 |
|
9 |
# Define the prediction function
|
10 |
def predict(image):
|
@@ -33,18 +33,18 @@ if uploaded_image is not None:
|
|
33 |
image = Image.open(uploaded_image)
|
34 |
|
35 |
# Display the uploaded image
|
36 |
-
st.image(image, caption="Uploaded Image",
|
37 |
|
38 |
# Run the model prediction
|
39 |
st.subheader("Prediction Results:")
|
40 |
result_image = predict(image)
|
41 |
|
42 |
# Display the result image with bounding boxes
|
43 |
-
st.image(result_image, caption="Detected Image",
|
44 |
|
45 |
# Optionally, show example images from the folder
|
46 |
if st.checkbox('Show example images'):
|
47 |
example_images = get_example_images()
|
48 |
for example_image in example_images:
|
49 |
img = Image.open(example_image)
|
50 |
-
st.image(img, caption=os.path.basename(example_image),
|
|
|
4 |
import os
|
5 |
|
6 |
# Load the trained YOLOv8 model
|
7 |
+
model = YOLO("best.pt")
|
8 |
|
9 |
# Define the prediction function
|
10 |
def predict(image):
|
|
|
33 |
image = Image.open(uploaded_image)
|
34 |
|
35 |
# Display the uploaded image
|
36 |
+
st.image(image, caption="Uploaded Image", use_container_width=True)
|
37 |
|
38 |
# Run the model prediction
|
39 |
st.subheader("Prediction Results:")
|
40 |
result_image = predict(image)
|
41 |
|
42 |
# Display the result image with bounding boxes
|
43 |
+
st.image(result_image, caption="Detected Image", use_container_width=True)
|
44 |
|
45 |
# Optionally, show example images from the folder
|
46 |
if st.checkbox('Show example images'):
|
47 |
example_images = get_example_images()
|
48 |
for example_image in example_images:
|
49 |
img = Image.open(example_image)
|
50 |
+
st.image(img, caption=os.path.basename(example_image), use_container_width=True)
|