Daniel Cerda Escobar commited on
Commit
a26f7df
·
1 Parent(s): b74b370

Display data

Browse files
Files changed (1) hide show
  1. app.py +33 -5
app.py CHANGED
@@ -1,4 +1,5 @@
1
  import streamlit as st
 
2
  import sahi.utils.file
3
  from PIL import Image
4
  from sahi import AutoDetectionModel
@@ -48,8 +49,17 @@ def download_comparison_images():
48
  download_comparison_images()
49
 
50
  # initialize prediction visual data
51
- #coco_df =
52
-
 
 
 
 
 
 
 
 
 
53
  if "output_1" not in st.session_state:
54
  img_1 = Image.open('plant_pid.png')
55
  st.session_state["output_1"] = img_1.resize((4960,3508))
@@ -58,7 +68,11 @@ if "output_2" not in st.session_state:
58
  img_2 = Image.open('prediction_visual.png')
59
  st.session_state["output_2"] = img_2.resize((4960,3508))
60
 
61
- #if "output_3" not in st.session_state:
 
 
 
 
62
 
63
 
64
  col1, col2, col3 = st.columns(3, gap='medium')
@@ -160,6 +174,8 @@ if submit:
160
 
161
  st.session_state["output_1"] = image
162
  st.session_state["output_2"] = output_visual
 
 
163
 
164
  st.write('##')
165
 
@@ -167,7 +183,7 @@ col1, col2, col3 = st.columns([1, 5, 1], gap='small')
167
  with col2:
168
  st.markdown(f"#### Object Detection Result")
169
  with st.container(border = True):
170
- tab1, tab2, tab3 = st.tabs(['Original Image','Inference Prediction','Data 📊'])
171
  with tab1:
172
  st.image(st.session_state["output_1"])
173
  with tab2:
@@ -176,7 +192,19 @@ with col2:
176
  col1,col2,col3 = st.columns([1,2,1])
177
  with col2:
178
  st.dataframe(
179
- output_df.style.hide_columns('percentage'),
 
 
 
 
 
 
 
 
 
 
 
 
180
  column_config = {
181
  'category' : 'Category',
182
  'count' : 'Number of Elements',
 
1
  import streamlit as st
2
+ import pandas as pd
3
  import sahi.utils.file
4
  from PIL import Image
5
  from sahi import AutoDetectionModel
 
49
  download_comparison_images()
50
 
51
  # initialize prediction visual data
52
+ coco_df = pd.DataFrame({
53
+ 'category' : ['centrifugal-pump','centrifugal-pump','gate-valve','gate-valve','gate-valve','gate-valve','gate-valve','gate-valve','gate-valve','gate-valve','gate-valve'],
54
+ 'score' : [0.88, 0.85, 0.87, 0.87, 0.86, 0.86, 0.85, 0.84, 0.81, 0.81, 0.76]
55
+ })
56
+ output_df = pd.DataFrame({
57
+ 'category':['ball-valve', 'butterfly-valve', 'centrifugal-pump', 'check-valve', 'gate-valve'],
58
+ 'count':[0, 0, 2, 0, 9],
59
+ 'percentage':[0, 0, 18.2, 0, 81.8]
60
+ })
61
+
62
+ # session state
63
  if "output_1" not in st.session_state:
64
  img_1 = Image.open('plant_pid.png')
65
  st.session_state["output_1"] = img_1.resize((4960,3508))
 
68
  img_2 = Image.open('prediction_visual.png')
69
  st.session_state["output_2"] = img_2.resize((4960,3508))
70
 
71
+ if "output_3" not in st.session_state:
72
+ st.session_state["output_3"] = coco_df
73
+
74
+ if "output_4" not in st.session_state:
75
+ st.session_state["output_4"] = output_df
76
 
77
 
78
  col1, col2, col3 = st.columns(3, gap='medium')
 
174
 
175
  st.session_state["output_1"] = image
176
  st.session_state["output_2"] = output_visual
177
+ st.session_state["output_3"] = coco_df
178
+ st.session_state["output_4"] = output_df
179
 
180
  st.write('##')
181
 
 
183
  with col2:
184
  st.markdown(f"#### Object Detection Result")
185
  with st.container(border = True):
186
+ tab1, tab2, tab3, tab4 = st.tabs(['Original Image','Inference Prediction','Data','Insights'])
187
  with tab1:
188
  st.image(st.session_state["output_1"])
189
  with tab2:
 
192
  col1,col2,col3 = st.columns([1,2,1])
193
  with col2:
194
  st.dataframe(
195
+ st.session_state["output_3"],
196
+ column_config = {
197
+ 'category' : 'Predicted Category',
198
+ 'score' : 'Confidence',
199
+ },
200
+ use_container_width = True,
201
+ hide_index = True,
202
+ )
203
+ with tab4:
204
+ col1,col2,col3 = st.columns([1,2,1])
205
+ with col2:
206
+ st.dataframe(
207
+ st.session_state["output_4"],
208
  column_config = {
209
  'category' : 'Category',
210
  'count' : 'Number of Elements',