dperales commited on
Commit
f03abd6
1 Parent(s): 76f7bad

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -20
app.py CHANGED
@@ -1,9 +1,9 @@
1
  try:
2
  import detectron2
3
  except:
4
- import os
5
  os.system('pip install git+https://github.com/facebookresearch/detectron2.git')
6
 
 
7
  import streamlit as st
8
  from PIL import Image
9
  from matplotlib.pyplot import axis
@@ -186,13 +186,24 @@ def inference(image):
186
  return img1, img2, img3, parts_list_damages
187
 
188
  def main():
 
 
 
 
 
 
 
 
 
189
  hide_streamlit_style = """
190
  <style>
191
  #MainMenu {visibility: hidden;}
192
  footer {visibility: hidden;}
193
  </style>
194
  """
 
195
  st.markdown(hide_streamlit_style, unsafe_allow_html=True)
 
196
 
197
  with st.sidebar:
198
  image = Image.open('itaca_logo.png')
@@ -205,41 +216,49 @@ def main():
205
  "key"],
206
  default_index=0
207
  )
208
-
209
- # Additional section below the option menu
210
- # st.markdown("---") # Add a separator line
211
- # st.header("Settings")
212
-
213
- st.title('ITACA Insurance Core AI Module')
214
-
215
  if page == "Damage Detection":
216
- st.header('Car Parts Damage Detection')
217
 
218
- st.write(
219
  """
220
  """
221
  )
222
 
223
- uploaded_file = st.file_uploader("Upload an image:")
 
 
 
 
 
 
 
 
 
224
 
225
  # Check if a file has been uploaded
226
  if uploaded_file is not None:
227
  # Load and display the image
228
  image = Image.open(uploaded_file)
229
- st.image(image, caption="Uploaded image")
230
-
 
 
 
 
231
  else:
232
- st.write("Please upload an image.")
233
 
234
- if st.button("Prediction"):
235
  with st.spinner("Loading..."):
236
- # Call the inference function with the uploaded image
237
  imagen1, imagen2, imagen3, partes = inference(image)
238
 
239
- st.image(imagen1, caption="crash image1")
240
- st.image(imagen2, caption="crash image2")
241
- st.image(imagen3, caption="crash image3")
242
- st.table(partes)
 
 
243
 
244
  elif page == "Under Construction":
245
  st.header('Under Construction')
 
1
  try:
2
  import detectron2
3
  except:
 
4
  os.system('pip install git+https://github.com/facebookresearch/detectron2.git')
5
 
6
+ import os
7
  import streamlit as st
8
  from PIL import Image
9
  from matplotlib.pyplot import axis
 
186
  return img1, img2, img3, parts_list_damages
187
 
188
  def main():
189
+ st.set_page_config(layout="wide")
190
+ c1, c2 = st.columns((1, 1))
191
+ c2.markdown("<br><br><br><br><br><br><br><br><br><br><br><br>", unsafe_allow_html=True)
192
+
193
+ tab1, tab2, tab3, tab4 = c2.tabs(["Image of damages", "Image of scratches", "Image of parts", "Information about damages parts"])
194
+
195
+ # Replace '20px' with your desired font size
196
+ font_size = '20px'
197
+
198
  hide_streamlit_style = """
199
  <style>
200
  #MainMenu {visibility: hidden;}
201
  footer {visibility: hidden;}
202
  </style>
203
  """
204
+
205
  st.markdown(hide_streamlit_style, unsafe_allow_html=True)
206
+ c1.title('ITACA Insurance Core AI Module')
207
 
208
  with st.sidebar:
209
  image = Image.open('itaca_logo.png')
 
216
  "key"],
217
  default_index=0
218
  )
219
+
 
 
 
 
 
 
220
  if page == "Damage Detection":
221
+ c1.header('Car Parts Damage Detection')
222
 
223
+ c1.write(
224
  """
225
  """
226
  )
227
 
228
+ # Display the list of CSV files
229
+ directory = "./"
230
+ all_files = os.listdir(directory)
231
+ # Filter files to only include JPG files
232
+ jpg_files = [file for file in all_files if file.endswith((".jpg"))]
233
+
234
+ # Select an image file from the list
235
+ selected_jpg = c1.selectbox("Select a JPG file from the list", ["None"] + jpg_files)
236
+
237
+ uploaded_file = c1.file_uploader("Upload an image:")
238
 
239
  # Check if a file has been uploaded
240
  if uploaded_file is not None:
241
  # Load and display the image
242
  image = Image.open(uploaded_file)
243
+ c1.image(image, width=600, caption="Uploaded image")
244
+
245
+ elif selected_jpg != 'None':
246
+ image = Image.open(selected_jpg)
247
+ c1.image(image, width=600, caption="Uploaded image")
248
+
249
  else:
250
+ c1.write("Please upload an image.")
251
 
252
+ if c1.button("Prediction"):
253
  with st.spinner("Loading..."):
 
254
  imagen1, imagen2, imagen3, partes = inference(image)
255
 
256
+ c2.markdown("<br><br><br><br><br><br><br><br><br><br><br><br><br><br>", unsafe_allow_html=True)
257
+
258
+ tab1.image(imagen1, width=600)
259
+ tab2.image(imagen2, width=600)
260
+ tab3.image(imagen3, width=600)
261
+ tab4.table(partes)
262
 
263
  elif page == "Under Construction":
264
  st.header('Under Construction')