Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
import streamlit as st
|
2 |
-
from ultralytics import YOLO
|
3 |
from ultralytics.utils.plotting import Annotator
|
4 |
import numpy as np
|
5 |
import cv2
|
6 |
-
import yolov9
|
7 |
from PIL import Image
|
|
|
|
|
8 |
|
9 |
# Load the YOLOv9 model
|
10 |
model = yolov9.load('fracture.pt', device="cpu")
|
@@ -39,8 +39,13 @@ st.title("YOLOv9 Fracture Detection")
|
|
39 |
uploaded_file = st.file_uploader("Choose an image...", type=["png", "jpg", "jpeg"])
|
40 |
|
41 |
if uploaded_file is not None:
|
42 |
-
#
|
43 |
-
image = Image.open(uploaded_file)
|
|
|
|
|
|
|
|
|
|
|
44 |
st.image(image, caption='Uploaded Image.', use_column_width=True)
|
45 |
|
46 |
# Run the prediction
|
|
|
1 |
import streamlit as st
|
|
|
2 |
from ultralytics.utils.plotting import Annotator
|
3 |
import numpy as np
|
4 |
import cv2
|
|
|
5 |
from PIL import Image
|
6 |
+
import io
|
7 |
+
import yolov9
|
8 |
|
9 |
# Load the YOLOv9 model
|
10 |
model = yolov9.load('fracture.pt', device="cpu")
|
|
|
39 |
uploaded_file = st.file_uploader("Choose an image...", type=["png", "jpg", "jpeg"])
|
40 |
|
41 |
if uploaded_file is not None:
|
42 |
+
# Convert the uploaded file to a JPEG image
|
43 |
+
image = Image.open(uploaded_file).convert("RGB")
|
44 |
+
img_byte_arr = io.BytesIO()
|
45 |
+
image.save(img_byte_arr, format="JPEG")
|
46 |
+
image = Image.open(io.BytesIO(img_byte_arr.getvalue()))
|
47 |
+
|
48 |
+
# Display the uploaded image
|
49 |
st.image(image, caption='Uploaded Image.', use_column_width=True)
|
50 |
|
51 |
# Run the prediction
|