Spaces:
Sleeping
Sleeping
Daniel Cerda Escobar
commited on
Commit
·
b113de0
1
Parent(s):
b62e10b
Update image size
Browse files
app.py
CHANGED
@@ -29,7 +29,7 @@ def get_model():
|
|
29 |
detection_model = AutoDetectionModel.from_pretrained(
|
30 |
model_type='yolov8',
|
31 |
model_path=yolov8_model_path,
|
32 |
-
confidence_threshold=0.
|
33 |
device="cpu",
|
34 |
)
|
35 |
return detection_model
|
@@ -93,10 +93,10 @@ with col3:
|
|
93 |
st.markdown('##### Set model parameters')
|
94 |
slice_size = st.slider(
|
95 |
label = 'Slice Size',
|
96 |
-
min_value=
|
97 |
-
max_value=
|
98 |
-
value=
|
99 |
-
step=
|
100 |
)
|
101 |
overlap_ratio = st.slider(
|
102 |
label = 'Overlap Ratio',
|
@@ -124,7 +124,7 @@ if submit:
|
|
124 |
with st.spinner(text="Downloading model weights ... "):
|
125 |
detection_model = get_model()
|
126 |
|
127 |
-
image_size =
|
128 |
|
129 |
with st.spinner(text="Performing prediction ... "):
|
130 |
output = sahi_yolov8m_inference(
|
@@ -152,7 +152,7 @@ with col2:
|
|
152 |
img2=st.session_state["output_2"],
|
153 |
label1='Uploaded Diagram',
|
154 |
label2='Model Inference',
|
155 |
-
width=
|
156 |
starting_position=50,
|
157 |
show_labels=True,
|
158 |
make_responsive=True,
|
|
|
29 |
detection_model = AutoDetectionModel.from_pretrained(
|
30 |
model_type='yolov8',
|
31 |
model_path=yolov8_model_path,
|
32 |
+
confidence_threshold=0.8,
|
33 |
device="cpu",
|
34 |
)
|
35 |
return detection_model
|
|
|
93 |
st.markdown('##### Set model parameters')
|
94 |
slice_size = st.slider(
|
95 |
label = 'Slice Size',
|
96 |
+
min_value=1240,
|
97 |
+
max_value=4960,
|
98 |
+
value=2480,
|
99 |
+
step=1240
|
100 |
)
|
101 |
overlap_ratio = st.slider(
|
102 |
label = 'Overlap Ratio',
|
|
|
124 |
with st.spinner(text="Downloading model weights ... "):
|
125 |
detection_model = get_model()
|
126 |
|
127 |
+
image_size = 4960
|
128 |
|
129 |
with st.spinner(text="Performing prediction ... "):
|
130 |
output = sahi_yolov8m_inference(
|
|
|
152 |
img2=st.session_state["output_2"],
|
153 |
label1='Uploaded Diagram',
|
154 |
label2='Model Inference',
|
155 |
+
width=1240,
|
156 |
starting_position=50,
|
157 |
show_labels=True,
|
158 |
make_responsive=True,
|
utils.py
CHANGED
@@ -9,12 +9,12 @@ TEMP_DIR = "temp"
|
|
9 |
def sahi_yolov8m_inference(
|
10 |
image,
|
11 |
detection_model,
|
12 |
-
slice_height=
|
13 |
-
slice_width=
|
14 |
overlap_height_ratio=0.1,
|
15 |
overlap_width_ratio=0.1,
|
16 |
-
image_size=
|
17 |
-
postprocess_match_threshold=0.
|
18 |
):
|
19 |
# sliced inference
|
20 |
detection_model.image_size = image_size
|
|
|
9 |
def sahi_yolov8m_inference(
|
10 |
image,
|
11 |
detection_model,
|
12 |
+
slice_height=1240,
|
13 |
+
slice_width=1240,
|
14 |
overlap_height_ratio=0.1,
|
15 |
overlap_width_ratio=0.1,
|
16 |
+
image_size=4960,
|
17 |
+
postprocess_match_threshold=0.8,
|
18 |
):
|
19 |
# sliced inference
|
20 |
detection_model.image_size = image_size
|