Spaces:
Sleeping
Sleeping
Federico Galatolo
commited on
Commit
•
e6c8bda
1
Parent(s):
c6268ab
app compatibile with streamlit 1.10
Browse files
app.py
CHANGED
@@ -12,7 +12,7 @@ import torchvision
|
|
12 |
from collections import OrderedDict
|
13 |
from scipy import spatial
|
14 |
import matplotlib.pyplot as plt
|
15 |
-
|
16 |
|
17 |
from detectron2.engine import DefaultPredictor
|
18 |
from detectron2.utils.visualizer import Visualizer
|
@@ -89,7 +89,6 @@ def load_model():
|
|
89 |
cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = TH
|
90 |
cfg.MODEL.DEVICE = "cpu"
|
91 |
|
92 |
-
|
93 |
metadata = Metadata()
|
94 |
metadata.set(
|
95 |
evaluator_type="coco",
|
@@ -154,15 +153,22 @@ def explain(img, model):
|
|
154 |
pred = cv2.resize(pred, (800, 800))
|
155 |
pred = cv2.cvtColor(pred, cv2.COLOR_BGR2RGB)
|
156 |
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
|
164 |
state.write("Populating first tab...")
|
165 |
-
with
|
166 |
st.header("Detected lesions")
|
167 |
st.image(pred)
|
168 |
|
|
|
12 |
from collections import OrderedDict
|
13 |
from scipy import spatial
|
14 |
import matplotlib.pyplot as plt
|
15 |
+
from packaging import version
|
16 |
|
17 |
from detectron2.engine import DefaultPredictor
|
18 |
from detectron2.utils.visualizer import Visualizer
|
|
|
89 |
cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = TH
|
90 |
cfg.MODEL.DEVICE = "cpu"
|
91 |
|
|
|
92 |
metadata = Metadata()
|
93 |
metadata.set(
|
94 |
evaluator_type="coco",
|
|
|
153 |
pred = cv2.resize(pred, (800, 800))
|
154 |
pred = cv2.cvtColor(pred, cv2.COLOR_BGR2RGB)
|
155 |
|
156 |
+
if version.parse(st.__version__) >= version.parse("1.11.0"):
|
157 |
+
tabs = st.tabs(["Result", "Detection"] + [f"Lesion #{i}" for i in range(0, len(instances))])
|
158 |
+
lesion_tabs = tabs[2:]
|
159 |
+
detection_tab = tabs[1]
|
160 |
+
with tabs[0]:
|
161 |
+
st.header("Image processed")
|
162 |
+
st.success("Use the tabs on the right to see the detected lesions and detailed explanations for each lesion")
|
163 |
+
|
164 |
+
else:
|
165 |
+
tabs = [st.container() for i in range(0, len(instances)+1)]
|
166 |
+
lesion_tabs = tabs[1:]
|
167 |
+
detection_tab = tabs[0]
|
168 |
+
|
169 |
|
170 |
state.write("Populating first tab...")
|
171 |
+
with detection_tab:
|
172 |
st.header("Detected lesions")
|
173 |
st.image(pred)
|
174 |
|