Flood Detector
a water level classifier for surveillance cameras
2 min readupdated
This model estimates river water levels from fixed-camera footage, sorting conditions into four classes: low, medium, high, and flood. Built on a lightweight MobileNetV3Large architecture, it incorporates conformal prediction (a method for estimating confidence intervals) to gauge prediction uncertainty. Designed for edge deployment as part of an academic project, it is a solid fit for researchers and developers building environmental monitoring systems.
Key features
- Lightweight MobileNetV3Large backbone optimized to run on low-power hardware.
- Dedicated class-imbalance techniques, including focal loss and data augmentation.
- Conformal prediction to quantify prediction accuracy and reliability.
- Trained on real-world footage from a fixed camera in Sao Carlos, Brazil.
What you can do
- Integrate the model into a local river-monitoring pipeline using camera feeds.
- Reuse the code and approach for natural hazard and emergency analysis projects.
- Explore the training notebook to apply conformal prediction to your own tasks.
Example
import numpy as np
import tensorflow as tf
from huggingface_hub import hf_hub_download
REPO_ID = "Bisse18/Mobilenet_V3_Large_FT_for_urban_flood_detection"
CLASS_NAMES = ["low", "medium", "high", "flood"]
model = tf.keras.models.load_model(hf_hub_download(REPO_ID, "flood_model.keras"), compile=False)
thresholds = np.load(hf_hub_download(REPO_ID, "conformal_thresholds.npy"))
img = tf.io.decode_jpeg(tf.io.read_file("river.jpg"), channels=3)
img = tf.image.resize(img, (224, 224))
probs = model.predict(img[None], verbose=0)[0]
valid = np.where(probs >= thresholds)[0]
pred = valid[np.argmax(probs[valid])] if len(valid) else int(np.argmax(probs))
print("Prediction:", CLASS_NAMES[pred])Read more
Details• Global accuracy: 96.48% (2020 test set)
• Flood class F1-score: 78.65%
• Framework: TensorFlow / Keras
• Limitations: trained on data from a single camera only; does not replace official warning systems










Comments