Upload app.py
Browse files
app.py
CHANGED
|
@@ -193,18 +193,25 @@ st.markdown("""
|
|
| 193 |
object-fit: contain;
|
| 194 |
}
|
| 195 |
|
| 196 |
-
/*
|
| 197 |
-
.
|
| 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 |
-
|
| 205 |
-
|
| 206 |
border-radius: 15px;
|
| 207 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 208 |
}
|
| 209 |
|
| 210 |
/* Mobile responsive adjustments */
|
|
@@ -482,41 +489,29 @@ def main():
|
|
| 482 |
</div>
|
| 483 |
""", unsafe_allow_html=True)
|
| 484 |
|
| 485 |
-
#
|
| 486 |
-
st.markdown("**π± Take
|
| 487 |
-
|
| 488 |
-
|
| 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="
|
| 498 |
)
|
| 499 |
|
| 500 |
-
#
|
| 501 |
image = None
|
| 502 |
-
image_source =
|
| 503 |
|
| 504 |
-
if
|
| 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:
|
| 513 |
# Display the image with appropriate caption
|
| 514 |
-
|
| 515 |
-
"camera": "π· Camera Photo",
|
| 516 |
-
"uploaded": "π Uploaded Image"
|
| 517 |
-
}
|
| 518 |
-
caption = caption_map.get(image_source, "Image")
|
| 519 |
-
st.image(image, caption=caption, use_column_width=True)
|
| 520 |
|
| 521 |
# Get prediction
|
| 522 |
transform = get_inference_transform()
|
|
@@ -532,7 +527,6 @@ def main():
|
|
| 532 |
with st.expander("π¬ Technical Details"):
|
| 533 |
st.markdown(f"""
|
| 534 |
**Prediction Details:**
|
| 535 |
-
- Input Source: {image_source.title()}
|
| 536 |
- Predicted Class: {predicted_label}
|
| 537 |
- Confidence Score: {confidence_score:.4f}
|
| 538 |
- Fire Probability: {all_probs[0]:.4f}
|
|
|
|
| 193 |
object-fit: contain;
|
| 194 |
}
|
| 195 |
|
| 196 |
+
/* File uploader styling - enhanced for mobile */
|
| 197 |
+
.stFileUploader > div {
|
| 198 |
border-radius: 15px;
|
|
|
|
|
|
|
| 199 |
margin: 10px 0;
|
| 200 |
}
|
| 201 |
|
| 202 |
+
.stFileUploader > div > div {
|
| 203 |
+
border: 2px dashed #74b9ff;
|
| 204 |
border-radius: 15px;
|
| 205 |
+
padding: 20px;
|
| 206 |
+
background: rgba(116, 185, 255, 0.05);
|
| 207 |
+
transition: all 0.3s ease;
|
| 208 |
+
}
|
| 209 |
+
|
| 210 |
+
.stFileUploader > div > div:hover {
|
| 211 |
+
border-color: #0984e3;
|
| 212 |
+
background: rgba(116, 185, 255, 0.1);
|
| 213 |
+
transform: translateY(-2px);
|
| 214 |
+
box-shadow: 0 4px 15px rgba(116, 185, 255, 0.2);
|
| 215 |
}
|
| 216 |
|
| 217 |
/* Mobile responsive adjustments */
|
|
|
|
| 489 |
</div>
|
| 490 |
""", unsafe_allow_html=True)
|
| 491 |
|
| 492 |
+
# Mobile-friendly file uploader that opens native camera
|
| 493 |
+
st.markdown("**π± Take Photo or Upload Image**")
|
| 494 |
+
st.markdown("πΈ **On Mobile**: Tap below β Choose 'Take Photo' to open camera")
|
| 495 |
+
st.markdown("π» **On Desktop**: Click below to select image files")
|
|
|
|
|
|
|
| 496 |
|
|
|
|
|
|
|
| 497 |
uploaded_file = st.file_uploader(
|
| 498 |
+
"Choose an image or take a photo...",
|
| 499 |
type=['jpg', 'jpeg', 'png', 'bmp', 'tiff'],
|
| 500 |
+
help="π± Mobile: Tap to open camera or gallery | π» Desktop: Click to browse files"
|
| 501 |
)
|
| 502 |
|
| 503 |
+
# Process the uploaded image
|
| 504 |
image = None
|
| 505 |
+
image_source = "uploaded"
|
| 506 |
|
| 507 |
+
if 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:
|
| 513 |
# Display the image with appropriate caption
|
| 514 |
+
st.image(image, caption="πΈ Your Image", use_column_width=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 515 |
|
| 516 |
# Get prediction
|
| 517 |
transform = get_inference_transform()
|
|
|
|
| 527 |
with st.expander("π¬ Technical Details"):
|
| 528 |
st.markdown(f"""
|
| 529 |
**Prediction Details:**
|
|
|
|
| 530 |
- Predicted Class: {predicted_label}
|
| 531 |
- Confidence Score: {confidence_score:.4f}
|
| 532 |
- Fire Probability: {all_probs[0]:.4f}
|