streaming part1

This commit is contained in:
2025-07-27 08:01:08 -07:00
parent 277d554ecc
commit 4b058c2405
17 changed files with 3072 additions and 683 deletions

View File

@@ -1,16 +1,18 @@
# VR180 Human Matting with Det-SAM2
A proof-of-concept implementation for automated human matting on VR180 3D side-by-side equirectangular video using Det-SAM2 and YOLOv8 detection.
Automated human matting for VR180 3D side-by-side video using SAM2 and YOLOv8. Now with two processing approaches: chunked (original) and streaming (optimized).
## Features
- **Automatic Person Detection**: Uses YOLOv8 to eliminate manual point selection
- **VRAM Optimization**: Memory management for RTX 3080 (10GB) compatibility
- **VR180-Specific Processing**: Side-by-side stereo handling with disparity mapping
- **Flexible Scaling**: 25%, 50%, or 100% processing resolution with AI upscaling
- **Two Processing Modes**:
- **Chunked**: Original stable implementation with higher memory usage
- **Streaming**: New 2-3x faster implementation with constant memory usage
- **VRAM Optimization**: Memory management for consumer GPUs (10GB+)
- **VR180-Specific Processing**: Stereo consistency with master-slave eye processing
- **Flexible Scaling**: 25%, 50%, or 100% processing resolution
- **Multiple Output Formats**: Alpha channel or green screen background
- **Chunked Processing**: Handles long videos with memory-efficient chunking
- **Cloud GPU Ready**: Docker containerization for RunPod, Vast.ai deployment
- **Cloud GPU Ready**: Optimized for RunPod, Vast.ai deployment
## Installation
@@ -48,9 +50,60 @@ output:
3. **Process video:**
```bash
# Chunked approach (original)
vr180-matting config.yaml
# Streaming approach (optimized, 2-3x faster)
python -m vr180_streaming config-streaming.yaml
```
## Processing Approaches
### Streaming Approach (Recommended)
- **Memory**: Constant ~50GB usage
- **Speed**: 2-3x faster than chunked
- **GPU**: 70%+ utilization
- **Best for**: Long videos, limited RAM
```bash
python -m vr180_streaming --generate-config config-streaming.yaml
python -m vr180_streaming config-streaming.yaml
```
### Chunked Approach (Original)
- **Memory**: 100GB+ peak usage
- **Speed**: Slower due to chunking overhead
- **GPU**: Lower utilization (~2.5%)
- **Best for**: Maximum stability, testing
```bash
vr180-matting --generate-config config-chunked.yaml
vr180-matting config-chunked.yaml
```
See [STREAMING_VS_CHUNKED.md](STREAMING_VS_CHUNKED.md) for detailed comparison.
## RunPod Quick Setup
For cloud GPU processing on RunPod:
```bash
# After connecting to your RunPod instance
git clone <repository-url>
cd sam2e
./runpod_setup.sh
# Then use the convenience scripts:
./run_streaming.sh # For streaming approach (recommended)
./run_chunked.sh # For chunked approach
```
The setup script will:
- Install all dependencies
- Download SAM2 models
- Create example configs
- Set up convenience scripts
## Configuration
### Input Settings
@@ -172,14 +225,24 @@ VRAM Utilization: 82%
### Project Structure
```
vr180_matting/
vr180_matting/ # Chunked approach (original)
├── config.py # Configuration management
├── detector.py # YOLOv8 person detection
├── sam2_wrapper.py # SAM2 integration
├── memory_manager.py # VRAM optimization
├── video_processor.py # Base video processing
├── vr180_processor.py # VR180-specific processing
└── main.py # CLI entry point
├── sam2_wrapper.py # SAM2 integration
├── memory_manager.py # VRAM optimization
├── video_processor.py # Base video processing
├── vr180_processor.py # VR180-specific processing
└── main.py # CLI entry point
vr180_streaming/ # Streaming approach (optimized)
├── frame_reader.py # Streaming frame reader
├── frame_writer.py # Direct ffmpeg pipe writer
├── stereo_manager.py # Stereo consistency management
├── sam2_streaming.py # SAM2 streaming integration
├── detector.py # YOLO person detection
├── streaming_processor.py # Main processor
├── config.py # Configuration
└── main.py # CLI entry point
```
### Contributing