Spaces:
Runtime error
Runtime error
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +8 -4
src/streamlit_app.py
CHANGED
|
@@ -6,7 +6,7 @@ from ultralytics import YOLO
|
|
| 6 |
|
| 7 |
@st.cache_resource(show_spinner=False)
|
| 8 |
def load_model():
|
| 9 |
-
return YOLO('
|
| 10 |
|
| 11 |
def predict(image, model):
|
| 12 |
img_np = np.array(image)
|
|
@@ -17,9 +17,13 @@ def predict(image, model):
|
|
| 17 |
return results[0]
|
| 18 |
|
| 19 |
def draw_results(image, results):
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
def crop_box(image, box):
|
| 25 |
img_np = np.array(image)
|
|
|
|
| 6 |
|
| 7 |
@st.cache_resource(show_spinner=False)
|
| 8 |
def load_model():
|
| 9 |
+
return YOLO('best.pt')
|
| 10 |
|
| 11 |
def predict(image, model):
|
| 12 |
img_np = np.array(image)
|
|
|
|
| 17 |
return results[0]
|
| 18 |
|
| 19 |
def draw_results(image, results):
|
| 20 |
+
try:
|
| 21 |
+
img_annotated = results.plot()
|
| 22 |
+
img_annotated_rgb = cv2.cvtColor(img_annotated, cv2.COLOR_BGR2RGB)
|
| 23 |
+
return Image.fromarray(img_annotated_rgb)
|
| 24 |
+
except Exception as e:
|
| 25 |
+
st.error(f"Error during annotation: {e}")
|
| 26 |
+
return image
|
| 27 |
|
| 28 |
def crop_box(image, box):
|
| 29 |
img_np = np.array(image)
|