Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,7 @@
|
|
4 |
import numpy as np
|
5 |
import streamlit as st
|
6 |
from PIL import Image
|
|
|
7 |
|
8 |
from rapid_layout import RapidLayout, VisLayout
|
9 |
|
@@ -79,8 +80,11 @@ select_model = st.selectbox("选择版面分析模型:", model_types.keys())
|
|
79 |
st.write("支持检测类型:")
|
80 |
st.code(model_types[select_model], language="python")
|
81 |
|
|
|
|
|
|
|
82 |
with st.spinner(f"Downloading {select_model} model..."):
|
83 |
-
layout_engine = RapidLayout(model_type=select_model)
|
84 |
|
85 |
st.write("请上传图像:")
|
86 |
img_suffix = ["png", "jpg", "jpeg"]
|
@@ -92,7 +96,7 @@ if img_file_buffer:
|
|
92 |
image = Image.open(img_file_buffer)
|
93 |
img = np.array(image)
|
94 |
with st.spinner("推理中...."):
|
95 |
-
boxes, scores, class_names, *elapse = layout_engine(img)
|
96 |
ploted_img = VisLayout.draw_detections(img, boxes, scores, class_names)
|
97 |
|
98 |
st.image(ploted_img, use_column_width=True)
|
|
|
4 |
import numpy as np
|
5 |
import streamlit as st
|
6 |
from PIL import Image
|
7 |
+
import cv2
|
8 |
|
9 |
from rapid_layout import RapidLayout, VisLayout
|
10 |
|
|
|
80 |
st.write("支持检测类型:")
|
81 |
st.code(model_types[select_model], language="python")
|
82 |
|
83 |
+
conf_threshold = st.slider("Confidence Threshold", 0, 1, 0.5)
|
84 |
+
iou_threshold = st.slider("IoU Threshold", 0, 1, 0.5)
|
85 |
+
|
86 |
with st.spinner(f"Downloading {select_model} model..."):
|
87 |
+
layout_engine = RapidLayout(model_type=select_model, conf_thres=conf_threshold, iou_thres=iou_threshold)
|
88 |
|
89 |
st.write("请上传图像:")
|
90 |
img_suffix = ["png", "jpg", "jpeg"]
|
|
|
96 |
image = Image.open(img_file_buffer)
|
97 |
img = np.array(image)
|
98 |
with st.spinner("推理中...."):
|
99 |
+
boxes, scores, class_names, *elapse = layout_engine(img, )
|
100 |
ploted_img = VisLayout.draw_detections(img, boxes, scores, class_names)
|
101 |
|
102 |
st.image(ploted_img, use_column_width=True)
|