File size: 1,547 Bytes
20e81e1 802f0a7 cdd7398 f4318f8 cdd7398 87d87cb cdd7398 87d87cb cdd7398 87d87cb cdd7398 87d87cb cdd7398 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
import streamlit as st
from PIL import Image
from ultralyticsplus import YOLO, render_result
# Load the YOLOv8 model from the 'best.pt' checkpoint
model_path = "best.pt"
model = YOLO(model_path)
st.title("Bone Fracture Detection using YOLOv8")
uploaded_file = st.file_uploader("Choose an image...", type="jpg")
if uploaded_file is not None:
image = Image.open(uploaded_file)
st.image(image, caption='Uploaded Image.', use_column_width=True)
st.write("")
image_size = st.slider('Image Size', min_value=320, max_value=1280, value=640, step=32)
conf_threshold = st.slider('Confidence Threshold', min_value=0.0, max_value=1.0, value=0.25, step=0.05)
iou_threshold = st.slider('IOU Threshold', min_value=0.0, max_value=1.0, value=0.45, step=0.05)
if st.button('Detect'):
# Perform object detection on the input image using the YOLOv8 model
results = model.predict(image,
conf=conf_threshold,
iou=iou_threshold,
imgsz=image_size)
# Print the detected objects' information (class, coordinates, and probability)
box = results[0].boxes
st.write("Object type:", box.cls)
st.write("Coordinates:", box.xyxy)
st.write("Probability:", box.conf)
# Render the output image with bounding boxes around detected objects
render = render_result(model=model, image=image, result=results[0])
st.image(render, caption='Detected Image.', use_column_width=True)
|