An advanced application for estimating and visualizing depth in underwater images and videos using state-of-the-art AI models. Built with Gradio, PyTorch, and the Depth Anything model family, optimized for underwater environments.
-
Multi-Format Support: Process both underwater images and videos
-
Interactive Interface: User-friendly Gradio web interface
-
Underwater-Specific Enhancements: Contrast correction for murky water and handling of unique lighting conditions
-
Multiple Visualization Options: Various colormaps optimized for underwater depth visualization
-
Analysis Tools: Depth distribution histogram for detailed analysis
-
Model Options: Choice between different model sizes tailored for underwater use
-
Real-Time Processing: Live preview of results
- Clone the repository:
git clone https://github.com/yourusername/underwater-depth-estimation-app.git
cd underwater-depth-estimation-app
- Create a virtual environment (recommended):
python -m venv venv
source venv/bin/activate # On Windows use: venv\Scripts\activate
- Install required packages:
pip install -r requirements.txt
torch
torchvision
transformers
opencv-python
pillow
gradio
tqdm
matplotlib
numpy
- Start the Gradio app:
python app.py
-
Open your browser and navigate to the provided URL (typically
http://localhost:7860
) -
Choose between image or video processing:
- Upload an underwater image or video
- Select your preferred colormap and model
- Enable/disable histogram and underwater contrast enhancement
- Click "Process" to generate the depth visualization
- INFERNO (recommended for underwater)
- JET
- VIRIDIS
- PLASMA
- MAGMA
- HOT
- Depth Anything Small: Faster processing, smaller memory footprint
- Depth Anything Base: Higher accuracy, larger model size
The app generates:
- Depth maps with underwater-specific color visualization
- Depth distribution histograms (for images)
- Processed videos with underwater depth visualization
-
Murky or Low-Visibility Water:
- Enable contrast enhancement
- Use the "Base" model for better depth estimation
-
CUDA Out of Memory:
- Reduce input image/video resolution
- Use the "Small" model instead of "Base"
- Free up GPU memory
-
Slow Processing:
- Ensure CUDA is available
- Check GPU usage
- Consider reducing input resolution
-
Video Codec Issues:
- Install required codecs
- Try converting video to MP4 format
- Check OpenCV installation