Spaces:
Sleeping
Sleeping
Daniel Cerda Escobar
commited on
Commit
Β·
3170d22
1
Parent(s):
7e838a1
Update app file
Browse files
app.py
CHANGED
@@ -1,23 +1,23 @@
|
|
1 |
import streamlit as st
|
|
|
|
|
|
|
2 |
import pandas as pd
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
],
|
9 |
}
|
10 |
-
)
|
11 |
-
|
12 |
|
13 |
st.set_page_config(
|
14 |
-
page_title="P&ID Object Detection
|
15 |
layout="wide",
|
16 |
initial_sidebar_state="expanded"
|
17 |
-
)
|
18 |
|
19 |
-
st.title('P&ID Object Detection
|
20 |
-
st.subheader(' Identify valves and pumps with deep learning model', divider='rainbow')
|
21 |
st.caption('Developed by Deep Drawings Co.')
|
22 |
|
23 |
col1, col2, col3 = st.columns([10, 10, 10])
|
@@ -30,22 +30,33 @@ with col2:
|
|
30 |
3) Press to Perform Inference π
|
31 |
4) Visualize Model Predictions π
|
32 |
'''
|
33 |
-
|
34 |
-
|
35 |
-
st.data_editor(
|
36 |
-
data_df,
|
37 |
-
column_config={
|
38 |
-
"apps": st.column_config.ImageColumn(
|
39 |
-
"Preview Image", help="Streamlit app preview screenshots"
|
40 |
-
)
|
41 |
-
},
|
42 |
-
hide_index=True,
|
43 |
-
)
|
44 |
|
45 |
st.write('##')
|
46 |
|
47 |
col1, col2, col3 = st.columns([10, 10, 10])
|
48 |
with col1:
|
49 |
-
st.markdown(f"#####
|
50 |
# set input image by upload
|
51 |
-
image_file = st.file_uploader("Upload your diagram
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
+
from PIL import Image
|
3 |
+
import random
|
4 |
+
import sahi.utils.file
|
5 |
import pandas as pd
|
6 |
|
7 |
+
IMAGE_TO_URL = {
|
8 |
+
'factory_pid.png' : 'https://d1afc1j4569hs1.cloudfront.net/factory-pid.png',
|
9 |
+
'plant_pid.png' : 'https://d1afc1j4569hs1.cloudfront.net/plant-pid.png',
|
10 |
+
'processing_pid.png' : 'https://d1afc1j4569hs1.cloudfront.net/processing-pid.png'
|
|
|
11 |
}
|
|
|
|
|
12 |
|
13 |
st.set_page_config(
|
14 |
+
page_title="P&ID Object Detection",
|
15 |
layout="wide",
|
16 |
initial_sidebar_state="expanded"
|
17 |
+
)
|
18 |
|
19 |
+
st.title('P&ID Object Detection')
|
20 |
+
st.subheader(' Identify valves and pumps with deep learning model ', divider='rainbow')
|
21 |
st.caption('Developed by Deep Drawings Co.')
|
22 |
|
23 |
col1, col2, col3 = st.columns([10, 10, 10])
|
|
|
30 |
3) Press to Perform Inference π
|
31 |
4) Visualize Model Predictions π
|
32 |
'''
|
33 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
st.write('##')
|
36 |
|
37 |
col1, col2, col3 = st.columns([10, 10, 10])
|
38 |
with col1:
|
39 |
+
st.markdown(f"##### Input File")
|
40 |
# set input image by upload
|
41 |
+
image_file = st.file_uploader("Upload your diagram", type=["pdf"])
|
42 |
+
with col2:
|
43 |
+
# set input images from examples
|
44 |
+
def slider_func(option):
|
45 |
+
option_to_id = {
|
46 |
+
'factory_pid.png' : str(1),
|
47 |
+
'plant_pid.png' : str(2),
|
48 |
+
'processing_pid.png' : str(3),
|
49 |
+
}
|
50 |
+
return option_to_id[option]
|
51 |
+
slider = st.select_slider(
|
52 |
+
'Or select from example diagrams',
|
53 |
+
options = ['factory_pid.png', 'plant_pid.png', 'processing_pid.png'],
|
54 |
+
format_func = slider_func,
|
55 |
+
value = 'processing_pid.png',
|
56 |
+
)
|
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[slider])
|
62 |
+
st.image(image, width = 400)
|