How xmlyqing00/v-floodnet works
1. Repository purpose
V-FloodNet is a research pipeline for urban flood analysis. It combines:
- water segmentation from images or videos,
- reference-object detection/segmentation/tracking,
- and water level/depth estimation from the segmented scene.
2. Top-level flow
The main data path is:
input images or video frames → water segmentation → reference object localization → geometric depth/level estimation → optional comparison/visualization of results.
Video support adds temporal feature aggregation so the system can use information across frames instead of processing each frame independently.
3. Primary entry points
The repository is organized around a few CLI scripts:
- test_image_seg.py for image segmentation inference
- test_video_seg.py for video segmentation inference
- est_waterlevel.py for water-level/depth estimation
- train_image_seg.py and train_video_seg.py for retraining the two segmentation subsystems
These are the main boundaries an architecture diagram should show as separate execution paths.
4. Image segmentation subsystem
The image_module/ package contains the dataset and transform logic for single-image water segmentation. It is the simplest inference branch and is used when inputs are still images or extracted video frames. This module is supported by estimation/ and the shared utilities, but is otherwise independent from the temporal model.
5. Video segmentation subsystem
The video_module/ package implements the temporal model used for videos. Its structure suggests:
- a dataset loader under video_module/dataset/
- a segmentation model under video_module/model/
- a feature-bank mechanism (FeatureBank.py) for storing and reusing frame features
- an AFB-URR model (AFB_URR.py) for adaptive video segmentation
This subsystem is the core difference from the image-only path: it exploits temporal context and memory across frames.
6. Reference object detection and tracking
The estimation/ package handles non-water objects used as scale references. It includes:
- object_detection.py
- reference_tracking.py
- Detectron2 configuration files for keypoint and instance segmentation models
The README indicates three reference modes: people, stop sign, and generic reference object. This is the component that turns segmentation output into a measurable physical water depth.
7. MeshTransformer integration
The MeshTransformer/ submodule is an external dependency used for human detection and 3D mesh alignment when the reference object is a person. This is a distinct subsystem with its own model weights and setup requirements, and it plugs into the estimation branch rather than the segmentation branch.
8. Shared utilities
myutils/ contains cross-cutting helpers:
- data handling
- depth plotting
- system/runtime helpers
These utilities are not a standalone subsystem, but they support both inference and evaluation workflows, especially result visualization and file handling.
9. Data and preprocessing
The repository includes dedicated preprocessing/conversion scripts under scripts/, such as:
- video-to-image and image-to-video conversion
- LabelMe conversion
- batch evaluation and animation generation
These are workflow tools around the main pipeline, and they matter because the segmentation models expect frame folders rather than raw videos.
10. Model configuration and pretrained assets
The estimation/configs/ tree holds Detectron2 model configs, while runtime weights live in records/ after download. The architecture depends on pretrained components for practical use:
- water segmentation weights
- reference detection/segmentation weights
- MeshTransformer weights and SMPL model files
This means the system is a composed inference stack rather than a single end-to-end monolith.
11. Training vs inference boundary
Training scripts are split from inference scripts and each branch has its own dataset/transforms. The image and video segmentation models are trained separately, which is important for the architecture diagram: the segmentation stack is modular, not one shared training pipeline.
12. Outputs and evaluation
Outputs include segmentation masks, annotated frames, estimated water-level curves/hydrographs, and animation artifacts. scripts/cmp_hydrograph.py compares estimated levels against ground truth, indicating an evaluation layer built on top of the core inference pipeline.
Main entry points: est_waterlevel.py Estimate level · test_video_seg.py Video infer · myutils Shared utils · scripts Workflow scripts
Components 15
CLI entry points
Primary training and inference commands for the pipeline.
- Image infer · Runs water segmentation on still images or extracted frames.
test_image_seg.py - Video infer · Runs temporal water segmentation on video inputs.
test_video_seg.py - Image train · Retrains the image segmentation branch.
train_image_seg.py - Video train · Retrains the video segmentation branch.
train_video_seg.py - Estimate level · Orchestrates segmentation output and reference-based water depth estimation.
est_waterlevel.py
Segmentation
Water segmentation subsystems for images and videos.
- Image data · Single-image water segmentation dataset and transforms.
image_module/dataset_water.py - Video data · Video-frame dataset and preprocessing for temporal segmentation.
video_module/dataset/Water_DS.py - AFB-URR · Adaptive video segmentation model that uses temporal context.
video_module/model/AFB_URR.py - Feature bank · Stores and reuses frame features across time.
video_module/model/FeatureBank.py
Estimation
Reference-object localization and water-level/depth estimation.
- Object detect · Detects or segments reference objects used for scaling.
estimation/object_detection.py - Ref tracking · Tracks reference objects through frames for stable measurements.
estimation/reference_tracking.py - MeshTransformer · Human detection and 3D mesh alignment for person-based reference estimation.
MeshTransformer
Support
Shared utilities, preprocessing scripts, and external mesh tooling.
- Shared utils · Common data, plotting, and runtime helpers used across workflows.
myutils - Workflow scripts · Video/image conversion, batch runs, label conversion, and hydrograph comparison tools.
scripts - Model configs · Detectron2 configuration files for reference-object models.
estimation/configs
Connections 17
- Image infer → Image data: uses · Loads image segmentation data and transforms.
- Image train → Image data: trains on · Uses the image dataset/transforms during retraining.
- Video infer → Video data: uses · Loads video segmentation data and transforms.
- Video train → Video data: trains on · Uses the video dataset/transforms during retraining.
- Video infer → AFB-URR: runs · Executes the temporal segmentation model.
- AFB-URR → Feature bank: reads/writes · Maintains temporal feature memory across frames.
- Estimate level → Object detect: calls · Uses reference-object detection or segmentation for scale estimation.
- Estimate level → Ref tracking: calls · Tracks references to stabilize depth estimation.
- Estimate level → MeshTransformer: optional person mode · Invokes mesh alignment when people are the reference object.
- Object detect → Model configs: configured by · Uses Detectron2 model configuration files.
- Ref tracking → Shared utils: uses · Shares common data and plotting helpers.
- Image infer → Shared utils: uses · Relies on shared utilities for I/O and visualization.
- Video infer → Shared utils: uses · Relies on shared utilities for I/O and visualization.
- Estimate level → Shared utils: uses · Uses shared helpers for result handling and plotting.
- Workflow scripts → Video infer: wraps · Provides batch and conversion workflows around video inference.
- Workflow scripts → Estimate level: wraps · Provides batch evaluation and comparison workflows.
- Workflow scripts → MeshTransformer: bootstraps · Downloads and runs supporting mesh models.