Download app.py from Nurisslam/ML: direct link, hf CLI and curl.
- Browser
- Download file 1.44 kB
-
https://huggingface.co/spaces/Nurisslam/ML/resolve/main/app.py
- Command line
-
hf download hf://spaces/Nurisslam/ML/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Nurisslam/ML/resolve/main/app.py
1.44 kB
| import streamlit as st | |
| from PIL import Image | |
| import torch | |
| from ultralytics import YOLO | |
| from huggingface_hub import hf_hub_download | |
| # Hugging Face-тен YOLOv11 модель жүктеу | |
| model_path = hf_hub_download( | |
| repo_id="harpreetsahota/car-dd-segmentation-yolov11", | |
| filename="best.pt" | |
| ) | |
| # Модельді жүктеу | |
| model = YOLO(model_path) | |
| st.set_page_config(page_title="Car Damage Detection", page_icon="🚗", layout="centered") | |
| st.title("🚗 Машина зақымын анықтау (YOLOv11 Segmentation)") | |
| uploaded_file = st.file_uploader("Машина суретін жүктеңіз", type=["jpg", "jpeg", "png"]) | |
| if uploaded_file is not None: | |
| image = Image.open(uploaded_file).convert("RGB") | |
| st.image(image, caption="Жүктелген сурет", use_column_width=True) | |
| st.write("🔎 Анализ жасалуда...") | |
| results = model.predict(image) | |
| st.subheader("📋 Нәтиже:") | |
| for r in results: | |
| boxes = r.boxes | |
| names = r.names | |
| for box in boxes: | |
| cls = int(box.cls[0]) | |
| label = names[cls] | |
| conf = float(box.conf[0]) | |
| st.success(f"{label} (сенімділік: {conf:.2f})") | |
| # Сегментацияланған суретті көрсету | |
| res_plotted = results[0].plot()[:, :, ::-1] | |
| st.image(res_plotted, caption="Зақым табылған аймақтар", use_column_width=True) | |