more stuff
This commit is contained in:
@@ -43,8 +43,8 @@ output:
|
||||
path: "/workspace/output_video.mp4" # Update with your output path
|
||||
format: "greenscreen" # "greenscreen" or "alpha"
|
||||
background_color: [0, 255, 0] # RGB for green screen
|
||||
video_codec: "h264_nvenc" # GPU encoding (or "hevc_nvenc" for better compression)
|
||||
quality_preset: "p4" # NVENC preset (p1-p7, higher = better quality)
|
||||
video_codec: "libx264" # CPU encoding (use "h264_nvenc" if GPU encoding works)
|
||||
quality_preset: "medium" # CPU preset (ultrafast/fast/medium/slow/veryslow)
|
||||
crf: 18 # Quality (0-51, lower = better, 18 = high quality)
|
||||
maintain_sbs: true # Keep side-by-side format with audio
|
||||
|
||||
|
||||
@@ -12,4 +12,4 @@ ffmpeg-python>=0.2.0
|
||||
decord>=0.6.0
|
||||
# GPU acceleration (optional but recommended for stereo validation speedup)
|
||||
# cupy-cuda11x>=12.0.0 # For CUDA 11.x
|
||||
# cupy-cuda12x>=12.0.0 # For CUDA 12.x - uncomment appropriate version
|
||||
cupy-cuda12x>=12.0.0 # For CUDA 12.x (most common on modern systems)
|
||||
@@ -58,20 +58,11 @@ pip install -r requirements.txt
|
||||
print_status "Installing video processing libraries..."
|
||||
pip install decord ffmpeg-python
|
||||
|
||||
# Install CuPy for GPU acceleration of stereo validation
|
||||
# Install CuPy for GPU acceleration (CUDA 12 is standard on modern RunPod)
|
||||
print_status "Installing CuPy for GPU acceleration..."
|
||||
# Auto-detect CUDA version and install appropriate CuPy
|
||||
if command -v nvidia-smi &> /dev/null; then
|
||||
CUDA_VERSION=$(nvidia-smi | grep "CUDA Version" | awk '{print $9}' | cut -d. -f1-2)
|
||||
echo "Detected CUDA version: $CUDA_VERSION"
|
||||
|
||||
if [[ "$CUDA_VERSION" == "11."* ]]; then
|
||||
pip install cupy-cuda11x>=12.0.0 && print_success "Installed CuPy for CUDA 11.x"
|
||||
elif [[ "$CUDA_VERSION" == "12."* ]]; then
|
||||
pip install cupy-cuda12x>=12.0.0 && print_success "Installed CuPy for CUDA 12.x"
|
||||
else
|
||||
print_error "Unknown CUDA version, skipping CuPy installation"
|
||||
fi
|
||||
print_status "Installing CuPy for CUDA 12.x (standard on RunPod)..."
|
||||
pip install cupy-cuda12x>=12.0.0 && print_success "Installed CuPy for CUDA 12.x"
|
||||
else
|
||||
print_error "NVIDIA GPU not detected, skipping CuPy installation"
|
||||
fi
|
||||
|
||||
@@ -132,13 +132,22 @@ class StreamingFrameWriter:
|
||||
bufsize=10**8 # Large buffer for performance
|
||||
)
|
||||
|
||||
# Test if ffmpeg starts successfully (quick check)
|
||||
import time
|
||||
time.sleep(0.1) # Give ffmpeg time to fail if it's going to
|
||||
|
||||
if self.ffmpeg_process.poll() is not None:
|
||||
# Process already died - read error
|
||||
stderr = self.ffmpeg_process.stderr.read().decode()
|
||||
raise RuntimeError(f"FFmpeg failed immediately: {stderr}")
|
||||
|
||||
# Set process to ignore SIGINT (Ctrl+C) - we'll handle it
|
||||
if hasattr(signal, 'pthread_sigmask'):
|
||||
signal.pthread_sigmask(signal.SIG_BLOCK, [signal.SIGINT])
|
||||
|
||||
except Exception as e:
|
||||
# Try CPU fallback if GPU encoding fails
|
||||
if 'nvenc' in self.ffmpeg_cmd:
|
||||
if 'nvenc' in ' '.join(self.ffmpeg_cmd):
|
||||
print(f"⚠️ GPU encoding failed, trying CPU fallback...")
|
||||
self.ffmpeg_cmd = self._build_ffmpeg_command('libx264', 'medium', 18)
|
||||
self._start_ffmpeg()
|
||||
|
||||
@@ -34,6 +34,11 @@ class SAM2StreamingProcessor:
|
||||
self.config = config
|
||||
self.device = torch.device(config.get('hardware', {}).get('device', 'cuda'))
|
||||
|
||||
# Processing parameters (set before _init_predictor)
|
||||
self.memory_offload = config.get('matting', {}).get('memory_offload', True)
|
||||
self.fp16 = config.get('matting', {}).get('fp16', True)
|
||||
self.correction_interval = config.get('matting', {}).get('correction_interval', 300)
|
||||
|
||||
# SAM2 model configuration
|
||||
model_cfg = config.get('matting', {}).get('sam2_model_cfg', 'sam2.1_hiera_l')
|
||||
checkpoint = config.get('matting', {}).get('sam2_checkpoint',
|
||||
@@ -43,11 +48,6 @@ class SAM2StreamingProcessor:
|
||||
self.predictor = None
|
||||
self._init_predictor(model_cfg, checkpoint)
|
||||
|
||||
# Processing parameters
|
||||
self.memory_offload = config.get('matting', {}).get('memory_offload', True)
|
||||
self.fp16 = config.get('matting', {}).get('fp16', True)
|
||||
self.correction_interval = config.get('matting', {}).get('correction_interval', 300)
|
||||
|
||||
# State management
|
||||
self.states = {} # eye -> inference state
|
||||
self.object_ids = []
|
||||
|
||||
Reference in New Issue
Block a user