Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,7 @@ import streamlit as st
|
|
2 |
from ultralyticsplus import YOLO, render_result
|
3 |
import PIL.Image as Image
|
4 |
import numpy as np
|
|
|
5 |
import requests
|
6 |
from io import BytesIO
|
7 |
|
@@ -35,18 +36,11 @@ if uploaded_file:
|
|
35 |
|
36 |
# Show the rendered result
|
37 |
st.image(rendered_image, caption="Detection Results", use_column_width=True)
|
|
|
38 |
# Count the number of each cell type
|
39 |
cell_counts = {"RBC": 0, "WBC": 0, "Platelets": 0}
|
40 |
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
else:
|
45 |
-
for box in results[0].boxes:
|
46 |
-
st.write(f"Bounding box: {box.xyxy}")
|
47 |
-
st.write(f"Confidence: {box.conf}")
|
48 |
-
st.write(f"Class: {box.cls}")
|
49 |
-
# Display details of detected boxes
|
50 |
st.write("Detection Results:")
|
51 |
for box in results[0].boxes:
|
52 |
class_index = int(box.cls) # Get the class index
|
@@ -56,9 +50,15 @@ else:
|
|
56 |
cell_counts["WBC"] += 1
|
57 |
elif class_index == 0: # Platelets
|
58 |
cell_counts["Platelets"] += 1
|
|
|
|
|
|
|
|
|
|
|
59 |
|
60 |
# Display the counts of each cell type
|
61 |
st.write("Cell Type Counts:")
|
62 |
st.write(pd.DataFrame.from_dict(cell_counts, orient='index', columns=['Count']))
|
|
|
63 |
else:
|
64 |
-
st.write("Upload an image to start detection")
|
|
|
2 |
from ultralyticsplus import YOLO, render_result
|
3 |
import PIL.Image as Image
|
4 |
import numpy as np
|
5 |
+
import pandas as pd
|
6 |
import requests
|
7 |
from io import BytesIO
|
8 |
|
|
|
36 |
|
37 |
# Show the rendered result
|
38 |
st.image(rendered_image, caption="Detection Results", use_column_width=True)
|
39 |
+
|
40 |
# Count the number of each cell type
|
41 |
cell_counts = {"RBC": 0, "WBC": 0, "Platelets": 0}
|
42 |
|
43 |
+
# Display details of detected boxes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
st.write("Detection Results:")
|
45 |
for box in results[0].boxes:
|
46 |
class_index = int(box.cls) # Get the class index
|
|
|
50 |
cell_counts["WBC"] += 1
|
51 |
elif class_index == 0: # Platelets
|
52 |
cell_counts["Platelets"] += 1
|
53 |
+
|
54 |
+
# Display bounding box information
|
55 |
+
st.write(f"Bounding box: {box.xyxy}")
|
56 |
+
st.write(f"Confidence: {box.conf}")
|
57 |
+
st.write(f"Class: {box.cls}")
|
58 |
|
59 |
# Display the counts of each cell type
|
60 |
st.write("Cell Type Counts:")
|
61 |
st.write(pd.DataFrame.from_dict(cell_counts, orient='index', columns=['Count']))
|
62 |
+
|
63 |
else:
|
64 |
+
st.write("Upload an image to start detection.")
|