Spaces:
Sleeping
Sleeping
Daniel Cerda Escobar
commited on
Commit
Β·
bd7c529
1
Parent(s):
b574fc0
Update app file
Browse files
app.py
CHANGED
@@ -1,14 +1,16 @@
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
from PIL import Image
|
3 |
import random
|
4 |
import sahi.utils.file
|
5 |
-
|
6 |
-
import numpy as np
|
7 |
|
8 |
IMAGE_TO_URL = {
|
9 |
'factory_pid.png' : 'https://d1afc1j4569hs1.cloudfront.net/factory-pid.png',
|
10 |
'plant_pid.png' : 'https://d1afc1j4569hs1.cloudfront.net/plant-pid.png',
|
11 |
-
'processing_pid.png' : 'https://d1afc1j4569hs1.cloudfront.net/processing-pid.png'
|
|
|
12 |
}
|
13 |
|
14 |
st.set_page_config(
|
@@ -21,6 +23,12 @@ st.title('P&ID Object Detection')
|
|
21 |
st.subheader(' Identify valves and pumps with deep learning model ', divider='rainbow')
|
22 |
st.caption('Developed by Deep Drawings Co.')
|
23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
col1, col2, col3 = st.columns(3, gap='medium')
|
25 |
with col1:
|
26 |
with st.expander('How to use it'):
|
@@ -85,3 +93,18 @@ st.write('##')
|
|
85 |
col1, col2, col3 = st.columns([3, 1, 3])
|
86 |
with col2:
|
87 |
submit = st.button("π Perform Prediction")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pandas as pd
|
2 |
+
import numpy as np
|
3 |
import streamlit as st
|
4 |
from PIL import Image
|
5 |
import random
|
6 |
import sahi.utils.file
|
7 |
+
from streamlit_image_comparison import image_comparison
|
|
|
8 |
|
9 |
IMAGE_TO_URL = {
|
10 |
'factory_pid.png' : 'https://d1afc1j4569hs1.cloudfront.net/factory-pid.png',
|
11 |
'plant_pid.png' : 'https://d1afc1j4569hs1.cloudfront.net/plant-pid.png',
|
12 |
+
'processing_pid.png' : 'https://d1afc1j4569hs1.cloudfront.net/processing-pid.png',
|
13 |
+
'prediction_visual.png' : 'https://d1afc1j4569hs1.cloudfront.net/prediction_visual.png'
|
14 |
}
|
15 |
|
16 |
st.set_page_config(
|
|
|
23 |
st.subheader(' Identify valves and pumps with deep learning model ', divider='rainbow')
|
24 |
st.caption('Developed by Deep Drawings Co.')
|
25 |
|
26 |
+
if "output_1" not in st.session_state:
|
27 |
+
st.session_state["output_1"] = sahi.utils.cv.read_image_as_pil(IMAGE_TO_URL['plant_pid.png'])
|
28 |
+
|
29 |
+
if "output_2" not in st.session_state:
|
30 |
+
st.session_state["output_2"] = sahi.utils.cv.read_image_as_pil(IMAGE_TO_URL['prediction_visual.png'])
|
31 |
+
|
32 |
col1, col2, col3 = st.columns(3, gap='medium')
|
33 |
with col1:
|
34 |
with st.expander('How to use it'):
|
|
|
93 |
col1, col2, col3 = st.columns([3, 1, 3])
|
94 |
with col2:
|
95 |
submit = st.button("π Perform Prediction")
|
96 |
+
|
97 |
+
st.write('##')
|
98 |
+
|
99 |
+
st.markdown(f"##### Uploaded Image vs Model Prediction:")
|
100 |
+
static_component = image_comparison(
|
101 |
+
img1=st.session_state["output_1"],
|
102 |
+
img2=st.session_state["output_2"],
|
103 |
+
label1='Uploaded Diagram',
|
104 |
+
label2='Model Inference',
|
105 |
+
width=700,
|
106 |
+
starting_position=50,
|
107 |
+
show_labels=True,
|
108 |
+
make_responsive=True,
|
109 |
+
in_memory=True,
|
110 |
+
)
|