jasonoh commited on
Commit
74fed8d
1 Parent(s): c879892
Files changed (5) hide show
  1. .gitignore +1 -0
  2. app.py +27 -0
  3. best.pt +3 -0
  4. predicted_image.jpg +0 -0
  5. requirements.txt +3 -0
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ venv
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from ultralytics import YOLO
3
+ import tempfile
4
+
5
+ # Load the model
6
+ model = YOLO('best.pt')
7
+
8
+ st.title('YOLO Object Detection')
9
+
10
+ uploaded_file = st.file_uploader("Upload an image", type=['jpg', 'jpeg', 'png'])
11
+
12
+ if uploaded_file is not None:
13
+ with tempfile.NamedTemporaryFile(delete=False, suffix='.jpg') as tmp_file:
14
+ tmp_file.write(uploaded_file.getvalue())
15
+ uploaded_image_path = tmp_file.name
16
+
17
+ # Display the uploaded image
18
+ st.image(uploaded_image_path, caption='Uploaded Image', use_column_width=True)
19
+
20
+ # Perform inference and save the result
21
+ results = model(uploaded_image_path)
22
+ saved_image_path = 'predicted_image.jpg' # Define the path where the image will be saved
23
+ for result in results:
24
+ result.save(filename=saved_image_path) # Save the predicted image
25
+
26
+ # Display the image with predictions
27
+ st.image(saved_image_path, caption='Predicted Image', use_column_width=True)
best.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9184ee1d77314b5ee0ca76ad74878743ea9266e1667e11a8972825f052262efc
3
+ size 6232793
predicted_image.jpg ADDED
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ streamlit
2
+ ultralytics
3
+ dill