Downloads · 30 days
0
BiernyVR/vr-guardian-segmentation
vr-guardian-segmentation is a image segmentation model from BiernyVR. Use it for the image segmentation task on the model card, and read the license before you ship it in a product. It is set up for pytorch. The card lists the license as mit.
A specialized high-resolution semantic segmentation model developed to detect, isolate, and mask the safety boundary grids (Guardian Grid — glowing blue, purple, or red lines and dot patterns) in video gameplay record…
Downloads · 30 days
0
Access
Public
Updated Sep 14, 2026
Repo size
251 MB
Likes
0
Public
Click a slice to open those files.
.pth97.9 MB · 39%
From the Hugging Face model README
A specialized high-resolution semantic segmentation model developed to detect, isolate, and mask the safety boundary grids (Guardian Grid — glowing blue, purple, or red lines and dot patterns) in video gameplay recorded directly from Meta Quest (Quest 2, Quest 3, Quest Pro) VR headsets.
Originally built as the perception module for the GenAIVideoStab / VR Guardian Remover automated inpainting pipeline.
When recording gameplay or mixed reality footage on Meta Quest headsets, approaching the physical room boundaries triggers the headset's safety grid. These bright, semi-transparent lines permanently ruin video captures.
Automating the removal of these grids required solving three distinct computer vision challenges:
[Phase 1: YOLOv8 Bounding Boxes] ──> [Phase 2: YOLOv8 Polygon Seg] ──> [Phase 3: High-Res U-Net (1024x1024)]
(Too much background cut) (Lost fine lines & dots) (Sub-pixel accuracy — PRODUCTION)
Neural networks detect the high-contrast core of the grid lines, but physical displays and optical lenses create a subtle colored halo (light bloom/glow).
This model is paired with a deterministic two-stage morphological post-processing pipeline:
cv2.MORPH_CLOSE, 9x9 kernel): Connects separated dots and broken lines into solid geometry.cv2.dilate, 11x11 ellipse kernel, 3 iterations): Safely expands the mask boundaries to swallow all surrounding optical bloom before passing the mask to inpainting engines (e.g. LaMa / ProPainter).In typical VR recordings, the Guardian grid only appears during 10%–30% of the video duration. Using this model's fast logical check:
has_grid = np.any(raw_mask > 0)
clean frames bypass heavy inpainting pipelines entirely. This delivers an up to 3x total video processing speedup with zero degradation to pristine footage.
pip install onnxruntime opencv-python numpy huggingface_hub
import cv2
import numpy as np
import onnxruntime as ort
from huggingface_hub import hf_hub_download
# 1. Download ONNX model
model_path = hf_hub_download(repo_id="BiernyVR/vr-guardian-segmentation", filename="vr_guardian_unet.onnx")
# 2. Preprocess input image to 1024x1024 RGB
img_bgr = cv2.imread("vr_gameplay_frame.jpg")
h, w = img_bgr.shape[:2]
resized = cv2.resize(cv2.cvtColor(img_bgr, cv2.COLOR_BGR2RGB), (1024, 1024))
tensor = ((resized.astype(np.float32) / 255.0 - [0.485, 0.456, 0.406]) / [0.229, 0.224, 0.225]).transpose(2, 0, 1)
tensor = np.expand_dims(tensor, axis=0).astype(np.float32)
# 3. Run Inference
session = ort.InferenceSession(model_path, providers=["CPUExecutionProvider"])
logits = session.run(None, {"input": tensor})[0][0][0]
probs = 1.0 / (1.0 + np.exp(-logits))
raw_mask = (probs > 0.5).astype(np.uint8) * 255
# 4. Morphological Refinement (Closing + Dilation to swallow bloom)
mask_full = cv2.resize(raw_mask, (w, h), interpolation=cv2.INTER_NEAREST)
close_k = cv2.getStructuringElement(cv2.MORPH_RECT, (9, 9))
dilate_k = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (11, 11))
refined_mask = cv2.morphologyEx(mask_full, cv2.MORPH_CLOSE, close_k)
refined_mask = cv2.dilate(refined_mask, dilate_k, iterations=3)
cv2.imwrite("guardian_mask.png", refined_mask)
print("Mask saved! Pass this mask directly to LaMa or another inpainting tool.")
python infer.py --image sample_frame.jpg
| File | Description | Size |
|---|---|---|
vr_guardian_unet.onnx | Standalone ONNX format (1024x1024 input, CPU/GPU ready) | ~97.7 MB |
best_unet.pth | PyTorch checkpoint (U-Net with ResNet-34 encoder) | ~97.9 MB |
yolo_guardian_grid_seg_best.pt | YOLOv8 instance segmentation model checkpoint | ~54.8 MB |
sample_frame.jpg | Real Meta Quest VR frame containing Guardian grid | ~316 KB |
sample_mask.png | Output binary segmentation mask | ~12 KB |
sample_overlay.jpg | Overlay visualization showing detected grid lines | ~325 KB |
infer.py | Complete inference script with morphological bloom filtering | ~3.8 KB |