|
|
import streamlit as st |
|
|
from PIL import Image |
|
|
from ultralytics import YOLO |
|
|
|
|
|
|
|
|
|
|
|
model = YOLO("models/best.pt") |
|
|
|
|
|
st.title("🚘 Машинаның зақымын анықтау (YOLO Detection)") |
|
|
|
|
|
|
|
|
uploaded_file = st.file_uploader("Суретті жүктеңіз", type=["jpg","jpeg","png"]) |
|
|
|
|
|
if uploaded_file: |
|
|
image = Image.open(uploaded_file).convert("RGB") |
|
|
st.image(image, caption="Жүктелген сурет", use_column_width=True) |
|
|
|
|
|
with st.spinner("Анализ жасалуда..."): |
|
|
|
|
|
results = model.predict(image) |
|
|
|
|
|
st.subheader("📋 Нәтиже:") |
|
|
|
|
|
|
|
|
for r in results: |
|
|
boxes = r.boxes |
|
|
masks = r.masks |
|
|
|
|
|
|
|
|
for b in boxes: |
|
|
cls = int(b.cls[0]) |
|
|
conf = float(b.conf[0]) |
|
|
label = model.names[cls] |
|
|
st.write(f"**{label}** (сенімділік: {conf:.2f})") |
|
|
|
|
|
|
|
|
plotted_img = r.plot() |
|
|
st.image(plotted_img, caption="Болжам жасалған сурет", use_column_width=True) |
|
|
|