Spaces:
Running
Running
fcakyon
commited on
Commit
Β·
486e870
1
Parent(s):
f995a01
add usage
Browse files
app.py
CHANGED
|
@@ -3,7 +3,7 @@ import sahi.utils.mmdet
|
|
| 3 |
import sahi.model
|
| 4 |
from PIL import Image
|
| 5 |
import random
|
| 6 |
-
from utils import
|
| 7 |
from utils import sahi_mmdet_inference
|
| 8 |
|
| 9 |
MMDET_YOLACT_MODEL_URL = "https://download.openmmlab.com/mmdetection/v2.0/yolact/yolact_r50_1x8_coco/yolact_r50_1x8_coco_20200908-f38d58df.pth"
|
|
@@ -121,7 +121,7 @@ st.markdown(
|
|
| 121 |
<p style='text-align: center'>
|
| 122 |
<a href='https://github.com/obss/sahi' target='_blank'>SAHI Github</a> | <a href='https://github.com/open-mmlab/mmdetection/tree/master/configs/yolox' target='_blank'>YOLOX Github</a> | <a href='https://huggingface.co/spaces/fcakyon/sahi-yolov5' target='_blank'>SAHI+YOLOv5 Demo</a>
|
| 123 |
<br />
|
| 124 |
-
Follow me for more! <a href='https://twitter.com/fcakyon' target='_blank'>twitter
|
| 125 |
</p>
|
| 126 |
""",
|
| 127 |
unsafe_allow_html=True,
|
|
@@ -129,6 +129,24 @@ st.markdown(
|
|
| 129 |
|
| 130 |
st.write("##")
|
| 131 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
col1, col2, col3 = st.columns([6, 1, 6])
|
| 133 |
with col1:
|
| 134 |
st.markdown(f"##### Set input image:")
|
|
@@ -181,9 +199,9 @@ with col3:
|
|
| 181 |
)
|
| 182 |
postprocess_class_agnostic = st.checkbox("postprocess_class_agnostic", value=True)
|
| 183 |
|
| 184 |
-
col1, col2, col3 = st.columns([
|
| 185 |
with col2:
|
| 186 |
-
submit = st.button("
|
| 187 |
|
| 188 |
if submit:
|
| 189 |
# perform prediction
|
|
@@ -219,7 +237,7 @@ if submit:
|
|
| 219 |
st.session_state["output_2"] = output_2
|
| 220 |
|
| 221 |
st.markdown(f"##### YOLOX Standard vs SAHI Prediction:")
|
| 222 |
-
static_component =
|
| 223 |
img1=st.session_state["output_1"],
|
| 224 |
img2=st.session_state["output_2"],
|
| 225 |
label1="YOLOX",
|
|
|
|
| 3 |
import sahi.model
|
| 4 |
from PIL import Image
|
| 5 |
import random
|
| 6 |
+
from utils import image_comparison
|
| 7 |
from utils import sahi_mmdet_inference
|
| 8 |
|
| 9 |
MMDET_YOLACT_MODEL_URL = "https://download.openmmlab.com/mmdetection/v2.0/yolact/yolact_r50_1x8_coco/yolact_r50_1x8_coco_20200908-f38d58df.pth"
|
|
|
|
| 121 |
<p style='text-align: center'>
|
| 122 |
<a href='https://github.com/obss/sahi' target='_blank'>SAHI Github</a> | <a href='https://github.com/open-mmlab/mmdetection/tree/master/configs/yolox' target='_blank'>YOLOX Github</a> | <a href='https://huggingface.co/spaces/fcakyon/sahi-yolov5' target='_blank'>SAHI+YOLOv5 Demo</a>
|
| 123 |
<br />
|
| 124 |
+
Follow me for more! <a href='https://twitter.com/fcakyon' target='_blank'> <img src="https://img.icons8.com/color/48/000000/twitter--v1.png" height="30"></a><a href='https://www.linkedin.com/in/fcakyon/' target='_blank'><img src="https://img.icons8.com/fluency/48/000000/linkedin.png" height="30"></a> <a href='https://fcakyon.medium.com/' target='_blank'><img src="https://img.icons8.com/ios-filled/48/000000/medium-monogram.png" height="27"></a>
|
| 125 |
</p>
|
| 126 |
""",
|
| 127 |
unsafe_allow_html=True,
|
|
|
|
| 129 |
|
| 130 |
st.write("##")
|
| 131 |
|
| 132 |
+
with st.expander("Usage"):
|
| 133 |
+
st.markdown(
|
| 134 |
+
"""
|
| 135 |
+
<p>
|
| 136 |
+
1. Upload or select the input image πΌοΈ
|
| 137 |
+
<br />
|
| 138 |
+
2. (Optional) Set SAHI parameters βοΈ
|
| 139 |
+
<br />
|
| 140 |
+
3. Press to "π Perform Prediction"
|
| 141 |
+
<br />
|
| 142 |
+
4. Enjoy sliding image comparison π₯
|
| 143 |
+
</p>
|
| 144 |
+
""",
|
| 145 |
+
unsafe_allow_html=True,
|
| 146 |
+
)
|
| 147 |
+
|
| 148 |
+
st.write("##")
|
| 149 |
+
|
| 150 |
col1, col2, col3 = st.columns([6, 1, 6])
|
| 151 |
with col1:
|
| 152 |
st.markdown(f"##### Set input image:")
|
|
|
|
| 199 |
)
|
| 200 |
postprocess_class_agnostic = st.checkbox("postprocess_class_agnostic", value=True)
|
| 201 |
|
| 202 |
+
col1, col2, col3 = st.columns([4, 3, 4])
|
| 203 |
with col2:
|
| 204 |
+
submit = st.button("π Perform Prediction")
|
| 205 |
|
| 206 |
if submit:
|
| 207 |
# perform prediction
|
|
|
|
| 237 |
st.session_state["output_2"] = output_2
|
| 238 |
|
| 239 |
st.markdown(f"##### YOLOX Standard vs SAHI Prediction:")
|
| 240 |
+
static_component = image_comparison(
|
| 241 |
img1=st.session_state["output_1"],
|
| 242 |
img2=st.session_state["output_2"],
|
| 243 |
label1="YOLOX",
|
utils.py
CHANGED
|
@@ -86,7 +86,7 @@ def pillow_local_file_to_base64(image: Image.Image):
|
|
| 86 |
return base64_src
|
| 87 |
|
| 88 |
|
| 89 |
-
def
|
| 90 |
img1: str,
|
| 91 |
img2: str,
|
| 92 |
label1: str = "1",
|
|
|
|
| 86 |
return base64_src
|
| 87 |
|
| 88 |
|
| 89 |
+
def image_comparison(
|
| 90 |
img1: str,
|
| 91 |
img2: str,
|
| 92 |
label1: str = "1",
|