Neylton commited on
Commit
012ffb4
Β·
verified Β·
1 Parent(s): c2dd694

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -53
app.py CHANGED
@@ -193,29 +193,18 @@ st.markdown("""
193
  object-fit: contain;
194
  }
195
 
196
- /* Simplified tab styling */
197
- .stTabs {
198
- margin-top: 10px;
199
- }
200
-
201
- .stTabs > div > div > div > div {
202
- padding: 10px 15px;
203
- font-weight: bold;
204
- border-radius: 8px;
205
- margin-right: 5px;
206
- }
207
-
208
- .stTabs > div > div > div > div[aria-selected="true"] {
209
- background: linear-gradient(135deg, #74b9ff 0%, #0984e3 100%);
210
- color: white !important;
211
- border-radius: 8px;
212
- }
213
-
214
  /* Camera input styling */
215
  .stCamera > div {
216
  border-radius: 15px;
217
  overflow: hidden;
218
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
 
 
 
 
 
 
 
219
  }
220
 
221
  /* Mobile responsive adjustments */
@@ -247,13 +236,6 @@ st.markdown("""
247
  .stImage > img {
248
  max-height: 300px;
249
  }
250
-
251
- /* Make tabs more touch-friendly on mobile */
252
- .stTabs > div > div > div > div {
253
- padding: 12px 16px;
254
- font-size: 1rem;
255
- min-height: 44px;
256
- }
257
  }
258
  </style>
259
  """, unsafe_allow_html=True)
@@ -500,38 +482,31 @@ def main():
500
  </div>
501
  """, unsafe_allow_html=True)
502
 
503
- # Create tabs for different input methods
504
- tab1, tab2 = st.tabs(["πŸ“· Camera", "πŸ“ Upload"])
 
 
 
 
 
 
 
 
 
 
 
 
505
 
 
506
  image = None
507
  image_source = None
508
 
509
- with tab1:
510
- st.markdown("**πŸ“± Take a Live Photo**")
511
-
512
- # Direct camera input - this opens native mobile camera
513
- camera_photo = st.camera_input(
514
- "πŸ“Έ Take a picture",
515
- help="Click to access your device camera and take a photo for fire detection"
516
- )
517
-
518
- if camera_photo is not None:
519
- image = Image.open(camera_photo)
520
- image_source = "camera"
521
-
522
- with tab2:
523
- st.markdown("**πŸ“ Upload from Device**")
524
-
525
- # File uploader for existing images
526
- uploaded_file = st.file_uploader(
527
- "Choose an image...",
528
- type=['jpg', 'jpeg', 'png', 'bmp', 'tiff'],
529
- help="Upload an existing image from your device for fire detection"
530
- )
531
-
532
- if uploaded_file is not None:
533
- image = Image.open(uploaded_file)
534
- image_source = "uploaded"
535
 
536
  # Process the image (whether uploaded or from camera)
537
  if image is not None:
 
193
  object-fit: contain;
194
  }
195
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
196
  /* Camera input styling */
197
  .stCamera > div {
198
  border-radius: 15px;
199
  overflow: hidden;
200
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
201
+ margin: 10px 0;
202
+ }
203
+
204
+ /* File uploader styling */
205
+ .stFileUploader > div {
206
+ border-radius: 15px;
207
+ margin: 10px 0;
208
  }
209
 
210
  /* Mobile responsive adjustments */
 
236
  .stImage > img {
237
  max-height: 300px;
238
  }
 
 
 
 
 
 
 
239
  }
240
  </style>
241
  """, unsafe_allow_html=True)
 
482
  </div>
483
  """, unsafe_allow_html=True)
484
 
485
+ # Camera input for mobile devices
486
+ st.markdown("**πŸ“± Take a Live Photo**")
487
+ camera_photo = st.camera_input(
488
+ "πŸ“Έ Take a picture",
489
+ help="Use your device camera to take a photo for fire detection"
490
+ )
491
+
492
+ # File uploader for existing images
493
+ st.markdown("**πŸ“ Or Upload from Device**")
494
+ uploaded_file = st.file_uploader(
495
+ "Choose an image...",
496
+ type=['jpg', 'jpeg', 'png', 'bmp', 'tiff'],
497
+ help="Upload an existing image from your device for fire detection"
498
+ )
499
 
500
+ # Determine which input was used
501
  image = None
502
  image_source = None
503
 
504
+ if camera_photo is not None:
505
+ image = Image.open(camera_photo)
506
+ image_source = "camera"
507
+ elif uploaded_file is not None:
508
+ image = Image.open(uploaded_file)
509
+ image_source = "uploaded"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
510
 
511
  # Process the image (whether uploaded or from camera)
512
  if image is not None: