Spaces:
Sleeping
Sleeping
Daniel Cerda Escobar
commited on
Commit
Β·
4d1e216
1
Parent(s):
117d139
Update app file
Browse files
app.py
CHANGED
@@ -25,40 +25,39 @@ with col1:
|
|
25 |
with st.expander('How to use it'):
|
26 |
st.markdown(
|
27 |
'''
|
28 |
-
1) Upload your P&ID or select example diagrams
|
29 |
2) Set confidence threshold π
|
30 |
-
3) Press to perform inference
|
31 |
-
4) Visualize model predictions
|
32 |
'''
|
33 |
)
|
34 |
|
35 |
st.write('##')
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
st.image(image, use_column_width = True)
|
|
|
25 |
with st.expander('How to use it'):
|
26 |
st.markdown(
|
27 |
'''
|
28 |
+
1) Upload your P&ID or select example diagrams π¬
|
29 |
2) Set confidence threshold π
|
30 |
+
3) Press to perform inference π
|
31 |
+
4) Visualize model predictions π
|
32 |
'''
|
33 |
)
|
34 |
|
35 |
st.write('##')
|
36 |
+
|
37 |
+
col1, col2, col3, col4 = st.columns([1, 2, 2, 1], gap='large')
|
38 |
+
with col2:
|
39 |
+
st.markdown('##### Input File')
|
40 |
+
# set input image by upload
|
41 |
+
image_file = st.file_uploader("Upload your diagram", type=["pdf"])
|
42 |
+
# set input images from examples
|
43 |
+
def radio_func(option):
|
44 |
+
option_to_id = {
|
45 |
+
'factory_pid.png' : 'A',
|
46 |
+
'plant_pid.png' : 'B',
|
47 |
+
'processing_pid.png' : 'C',
|
48 |
+
}
|
49 |
+
return option_to_id[option]
|
50 |
+
radio = st.radio(
|
51 |
+
'Or select from the following examples',
|
52 |
+
options = ['factory_pid.png', 'plant_pid.png', 'processing_pid.png'],
|
53 |
+
format_func = radio_func,
|
54 |
+
)
|
55 |
+
with col3:
|
56 |
+
st.markdown('##### Preview')
|
57 |
+
# visualize input image
|
58 |
+
if image_file is not None:
|
59 |
+
image = Image.open(image_file)
|
60 |
+
else:
|
61 |
+
image = sahi.utils.cv.read_image_as_pil(IMAGE_TO_URL[radio])
|
62 |
+
with st.container(border = True):
|
63 |
+
st.image(image, use_column_width = True)
|
|