File size: 1,517 Bytes
853f584
ffd60f3
 
853f584
ffd60f3
 
1541b3e
853f584
ffd60f3
853f584
4453abe
6367af7
4453abe
ffd60f3
bd9a5b3
853f584
4453abe
bd9a5b3
ffd60f3
 
4453abe
bd9a5b3
4453abe
ffd60f3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
38
39
import streamlit as st
from PIL import Image
from ultralytics import YOLO

# 🚗 YOLO моделін жүктеу
# Алдымен терминалда орнату керек: pip install ultralytics
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

        # Тек label + сенімділік шығару
        for b in boxes:
            cls = int(b.cls[0])           # класстың индексі
            conf = float(b.conf[0])       # сенімділік
            label = model.names[cls]      # класстың аты
            st.write(f"**{label}** (сенімділік: {conf:.2f})")

        # Bounding box/segmentation салынған суретті алу
        plotted_img = r.plot()  # OpenCV форматы (numpy массив)
        st.image(plotted_img, caption="Болжам жасалған сурет", use_column_width=True)