Piotr Krawiec commited on
Commit
9419682
·
1 Parent(s): c3f41c6
Files changed (3) hide show
  1. best.pt +3 -0
  2. main.py +33 -0
  3. requirements.txt +5 -0
best.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9379f467a6e97a72bbda1ff81096e56f8f87831660b29436fc5783a043e0b94b
3
+ size 23815362
main.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import numpy as np
3
+ from ultralytics import YOLO
4
+ from PIL import Image
5
+ import supervision as sv
6
+
7
+ model = YOLO('best.pt')
8
+ mask_annotator = sv.MaskAnnotator()
9
+ box_annontator = sv.BoxAnnotator()
10
+
11
+
12
+ st.title("Yolov8 Solar Panel Segmentation")
13
+
14
+ uploaded_file = st.file_uploader("Upload an image", type=["png", "jpg", "jpeg"], accept_multiple_files=False)
15
+
16
+ if uploaded_file is not None:
17
+ image = Image.open(uploaded_file).convert('RGB')
18
+ image_arr = np.array(image)
19
+
20
+ result = model.predict(image)[0] # Use `image` because of RGB to BGR conversion
21
+
22
+ detections = sv.Detections.from_ultralytics(result)
23
+
24
+ labels = [
25
+ f"solar panel {confidence:0.2f}"
26
+ for _, _, confidence, _, _
27
+ in detections
28
+ ]
29
+ annotated_image = mask_annotator.annotate(image_arr, detections)
30
+ annotated_image = box_annontator.annotate(annotated_image, detections, labels=labels)
31
+
32
+
33
+ st.image(annotated_image, caption='Uploaded Image.', use_column_width=True)
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ torch
2
+ torchvision
3
+ ultralytics
4
+ streamlit
5
+ supervision