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)