|
import streamlit as st |
|
import glob |
|
from ultralytics import YOLO |
|
from PIL import Image |
|
|
|
|
|
model_path = "best.pt" |
|
model = YOLO(model_path) |
|
|
|
PREDICT_KWARGS = { |
|
"conf": 0.15, |
|
} |
|
|
|
|
|
st.title("OOI RCA Digital Still Camera Benthic Megafauna Detector") |
|
st.write("This app uses a YOLOv11 model to detect benthic megafauna in images taken by the RCA OOI Digital Still Camera placed at Southern Hydrate Ridge to provide near real-time biological data. Please select an image from the sidebar on the left to try it out! This model was trained by University of Washington researchers on a RTX 3090 GPU for 100 epochs using MBARIs YOLOv8 model FathomNet/MBARI-315k-yolov8 as a starting point.The dataset used was first annotated by the afrorementioned MBARI model before being preprocessed both algorithmically and by hand by Dr. Katie Bigham and Atticus Carter. Classes are constrained to morphotypes as exact species are yet to be fully IDed and integrated. This models ideal image input size for training is 1024x1024. ") |
|
|
|
|
|
examples = glob.glob("images/*.png") |
|
|
|
|
|
st.sidebar.title("Example Images") |
|
selected_example = st.sidebar.selectbox("Select an example image", examples) |
|
|
|
|
|
uploaded_file = st.file_uploader("Or upload an image", type=["png", "jpg", "jpeg"]) |
|
|
|
|
|
if uploaded_file is not None: |
|
image = Image.open(uploaded_file) |
|
image_path = uploaded_file |
|
elif selected_example: |
|
image = Image.open(selected_example) |
|
image_path = selected_example |
|
else: |
|
image = None |
|
image_path = None |
|
|
|
|
|
if image_path is not None: |
|
results = model.predict(image_path, **PREDICT_KWARGS) |
|
prediction_image = results[0].plot()[:, :, ::-1] |
|
|
|
|
|
col1, col2 = st.columns(2) |
|
|
|
with col1: |
|
st.image(image, caption="Selected Image", use_column_width=True) |
|
|
|
with col2: |
|
st.image(prediction_image, caption="Predicted Image", use_column_width=True) |
|
else: |
|
st.write("Please upload an image or select an example to proceed.") |
|
|
|
|
|
st.markdown( |
|
""" |
|
--- |
|
**© 2024 Atticus Carter, [https://oceancv.org/](https://oceancv.org/)** |
|
**Image Credit: Ocean Observatories Initiative 2022** |
|
""" |
|
) |
|
|