Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from ultralytics import YOLO
|
3 |
+
from PIL import Image
|
4 |
+
model= YOLO ("yolov8n-seg.pt")
|
5 |
+
st.title("image segmentation")
|
6 |
+
up= st.file_uploader("upload an image", type= ["jpg","png", "jpeg"])
|
7 |
+
if st.button("detect"):
|
8 |
+
image= Image.open(up).convert('RGB')
|
9 |
+
result= model(image)
|
10 |
+
output= result[0].plot()
|
11 |
+
col1, col2= st.columns(2)
|
12 |
+
with col1:
|
13 |
+
st.image(image,use_column_width= True)
|
14 |
+
with col2:
|
15 |
+
|
16 |
+
st.image(output,use_column_width= True)
|