anonymousatom commited on
Commit
4290d05
·
verified ·
1 Parent(s): f814794

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +33 -0
  2. best.pt +3 -0
  3. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from PIL import Image
3
+ from ultralytics import YOLO
4
+
5
+ st.title("Object Detection with YOLO")
6
+
7
+ model = YOLO('best.pt')
8
+
9
+ def detect_objects(image):
10
+ result = model(image)
11
+ return result
12
+
13
+
14
+ uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "png", "jpeg"])
15
+
16
+ if uploaded_file is not None:
17
+ image = Image.open(uploaded_file)
18
+ st.image(image, caption='Uploaded Image.', use_column_width=True)
19
+
20
+ if st.button('Detect Objects'):
21
+ image.save('uploaded_image.jpg')
22
+
23
+ result = detect_objects('uploaded_image.jpg')
24
+
25
+ boxes = result[0].boxes
26
+ masks = result[0].masks
27
+ keypoints = result[0].keypoints
28
+ probs = result[0].probs
29
+
30
+ st.write("Number of objects detected:", len(boxes))
31
+ result[0].save(filename='result.jpg')
32
+
33
+ st.image('result.jpg', use_column_width=True)
best.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2631a282bc9fe4bf10af87f1ea6a89b2c15f756e22a8c35f24a3e2303243caa6
3
+ size 6223705
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ torch
2
+ ultralytics
3
+ streamlit