Abs6187 commited on
Commit
26f6a32
·
verified ·
1 Parent(s): 3b4c7e2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -4,7 +4,7 @@ from PIL import Image
4
  import os
5
 
6
  # Load the trained YOLOv8 model
7
- model = YOLO("yolov8n.pt")
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", use_column_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_column_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_column_width=True)
 
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)