Skip to main content 首页 创作者 adu2021 skillxiv ffacenerf-few-shot-face-editing
ffacenerf-few-shot-face-editing Edit 3D faces with flexible mask layouts using only a few training samples. FFaceNeRF employs geometry adapters with feature injection and latent mixing for tri-plane augmentation, enabling rapid NeRF adaptation without fixed segmentation masks. Ideal for personalized medical imaging, creative face editing, and applications requiring user-defined mask control.
跳到安装 Skills Marketplace 发现并探索由社区构建的 Agent Skills
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/ADu2021/skillXiv --skill ffacenerf-few-shot-face-editing命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
下载 Zip 下载中... 同仓库更多 Skills meaningful-kebab-case-name Convert arXiv papers into ready-to-use agent skills using category-aware extraction. First classifies the paper into one or more of 11 research categories, then applies a specialized extraction pipeline for each category — because different types of papers produce different types of usable knowledge. A single paper can yield multiple skills if it spans categories. Use this skill whenever the user wants to turn a paper into a skill, extract practical techniques from research, build a skill library from papers, convert arXiv papers into reusable agent instructions, or batch-process multiple papers into skills. Also trigger when someone asks about extracting actionable knowledge from papers, making research practical for LLM agents, or systematically converting academic contributions into structured agent capabilities.
action-quantization-behavior-cloning Establish regret bounds for behavior cloning with discretized actions combining statistical error and quantization error terms. Prove smoothness requirements for safe quantizer design, show that learning-based quantizers fail these requirements, and propose model-based augmentation to reduce error dependence from H² to H.
adaptive-lora-personalized-ranks Dynamically allocate LoRA ranks per-layer during fine-tuning instead of using fixed uniform ranks. Learn optimal rank for each layer and subject via variational framework with discretized exponential distribution, reducing memory footprint while maintaining fidelity and text-alignment.
name ffacenerf-few-shot-face-editing title FFaceNeRF: Few-shot Face Editing in Neural Radiance Fields version 0.0.2 engine skillxiv-v0.0.2-claude-opus-4.6 license MIT url https://arxiv.org/abs/2503.17095 keywords ["neural-radiance-fields","face-editing","few-shot-learning","3d-face-modeling","latent-mixing"] description Edit 3D faces with flexible mask layouts using only a few training samples. FFaceNeRF employs geometry adapters with feature injection and latent mixing for tri-plane augmentation, enabling rapid NeRF adaptation without fixed segmentation masks. Ideal for personalized medical imaging, creative face editing, and applications requiring user-defined mask control.
Core Concept
FFaceNeRF tackles a fundamental limitation in NeRF-based 3D face editing: existing methods rely on fixed segmentation masks predefined during training, severely restricting user control. Changing mask layouts requires retraining with large datasets—impractical for personalized applications like medical imaging or creative editing. FFaceNeRF introduces a flexible NeRF editing framework that adapts to arbitrary mask layouts using only a handful of training images. The key innovation combines two complementary techniques: geometry adapters with feature injection (for precise geometric control) and latent mixing for tri-plane augmentation (enabling training with few samples). This empowers applications where custom masks and rapid adaptation are critical.
Architecture Overview
The system integrates four essential components:
Geometry Adapter with Feature Injection : Parameterized module that modulates geometry attributes without full NeRF retraining, enabling manipulation of face shape while preserving appearance
Latent Mixing for Tri-Plane Augmentation : Augmentation strategy in latent space that synthesizes diverse training views from few samples, expanding effective training data
Mask-Guided Editing Pipeline : Accepts user-defined masks and applies geometry changes selectively to masked regions
Rapid Model Adaptation : Few-shot fine-tuning that converges quickly on new mask layouts and editing targets
Implementation Steps
1. Initialize NeRF and Geometry Adapter
Set up base NeRF model and attach geometry adapter for targeted manipulation:
import torch
import torch.nn as nn
from typing import Tuple
class GeometryAdapter (nn.Module):
"""
Learnable adapter for geometry modification in NeRF.
Uses feature injection to modulate density and position shifts.
"""
def __init__ (self, hidden_dim: int = 64 , input_dim: int = 3 ):
super ().__init__()
self .input_dim = input_dim
.hidden_dim = hidden_dim
.fc1 = nn.Linear(input_dim, hidden_dim)
.fc2 = nn.Linear(hidden_dim, hidden_dim)
.fc3 = nn.Linear(hidden_dim, input_dim)
.density_head = nn.Linear(hidden_dim, )
( ) -> [torch.Tensor, torch.Tensor]:
x = torch.cat([positions, features], dim=- ) features positions
h = torch.relu( .fc1(x))
h = torch.relu( .fc2(h))
position_offset = torch.tanh( .fc3(h)) *
density_modulation = .density_head(h)
position_offset, density_modulation
self
self
self
self
self
1
def
forward
self, positions: torch.Tensor, features: torch.Tensor
Tuple
"""
Modulate geometry via position offsets and density changes.
Takes 3D positions and extracted features as input.
"""
1
if
is
not
None
else
self
self
self
0.1
self
return
2. Implement Latent Mixing for Tri-Plane Augmentation Augment training data in latent space by mixing features from few samples:
def latent_mixing_augmentation (tri_plane_features: torch.Tensor,
num_augmentations: int = 5 ) -> torch.Tensor:
"""
Synthesize diverse tri-plane features via latent space mixing.
Enables training effective models from very few input images.
"""
batch_size, planes, height, width = tri_plane_features.shape
augmented_features = [tri_plane_features]
for _ in range (num_augmentations):
idx1 = torch.randint(0 , batch_size, (1 ,)).item()
idx2 = torch.randint(0 , batch_size, (1 ,)).item()
alpha = torch.rand(1 ).item()
mixed = alpha * tri_plane_features[idx1] + (1 - alpha) * tri_plane_features[idx2]
augmented_features.append(mixed.unsqueeze(0 ))
augmented_batch = torch.cat(augmented_features, dim=0 )
return augmented_batch
3. Mask-Guided Geometry Editing Apply selective geometry modifications only to user-defined masked regions:
def apply_mask_guided_editing (ray_positions: torch.Tensor,
mask: torch.Tensor,
geometry_adapter: GeometryAdapter,
features: torch.Tensor ) -> torch.Tensor:
"""
Edit geometry selectively within masked regions.
Preserves unmasked areas while applying targeted shape changes.
"""
position_offsets, density_mods = geometry_adapter(ray_positions, features)
masked_offsets = position_offsets * mask.unsqueeze(-1 )
modified_positions = ray_positions + masked_offsets
return modified_positions
4. Few-Shot NeRF Fine-Tuning Pipeline Train NeRF with geometry adapter and augmentation using minimal samples:
import torch.optim as optim
from torch.utils.data import DataLoader
def train_ffacenerf (nerf_model,
geometry_adapter: GeometryAdapter,
train_images: torch.Tensor,
train_masks: torch.Tensor,
target_geometry: torch.Tensor,
num_epochs: int = 50 ,
learning_rate: float = 1e-3 ):
"""
Few-shot fine-tune NeRF with geometry adapter and latent mixing.
Rapidly adapts to new mask layouts and editing targets.
"""
optimizer = optim.Adam([
{'params' : geometry_adapter.parameters(), 'lr' : learning_rate},
{'params' : nerf_model.parameters(), 'lr' : learning_rate * 0.1 }
])
tri_plane_features = nerf_model.encode_tri_plane(train_images)
augmented_features = latent_mixing_augmentation(tri_plane_features, num_augmentations=8 )
for epoch in range (num_epochs):
total_loss = 0.0
for aug_idx in range (augmented_features.shape[0 ]):
features = augmented_features[aug_idx:aug_idx+1 ]
ray_positions = nerf_model.sample_rays()
modified_positions = apply_mask_guided_editing(ray_positions, train_masks,
geometry_adapter, features)
rendered_image = nerf_model.render(modified_positions, features)
recon_loss = torch.nn.functional.mse_loss(rendered_image, train_images)
position_offsets, _ = geometry_adapter(ray_positions, features)
smooth_loss = torch.mean(torch.abs (torch.diff(position_offsets, dim=0 )))
loss = recon_loss + 0.1 * smooth_loss
optimizer.zero_grad()
loss.backward()
optimizer.step()
total_loss += loss.item()
if (epoch + 1 ) % 10 == 0 :
print (f"Epoch {epoch + 1 } : Loss = {total_loss / augmented_features.shape[0 ]:.4 f} " )
return nerf_model, geometry_adapter
5. Inference with Custom Mask Layouts Apply trained model to new mask layouts without retraining:
def inference_with_custom_mask (nerf_model,
geometry_adapter: GeometryAdapter,
input_image: torch.Tensor,
new_mask: torch.Tensor,
editing_strength: float = 1.0 ) -> torch.Tensor:
"""
Generate edited face image with custom mask layout.
Enables flexible user control without requiring full retraining.
"""
with torch.no_grad():
tri_plane_features = nerf_model.encode_tri_plane(input_image)
ray_positions = nerf_model.sample_rays()
modified_positions = apply_mask_guided_editing(
ray_positions,
new_mask * editing_strength,
geometry_adapter,
tri_plane_features
)
edited_image = nerf_model.render(modified_positions, tri_plane_features)
return edited_image
Practical Guidance
When to Use FFaceNeRF
Personalized Medical Imaging : Surgeons planning procedures with patient-specific mask layouts
Creative Face Editing : Artists and designers requiring flexible, interactive mask control
Rapid Prototyping : Testing multiple editing styles with custom masks quickly
Interactive Face Manipulation : Real-time or near-real-time editing in applications
Limited Data Scenarios : Adapting models when only a few images of target face are available
When NOT to Use FFaceNeRF
Large-Scale Video Processing : NeRF is computationally expensive for frame-by-frame editing
Fixed-Mask Production Pipelines : If mask layouts are predetermined, standard NeRF methods are simpler and faster
Extremely Low-Light Images : NeRF struggles with insufficient illumination cues for geometry estimation
Extreme Facial Expressions : If target geometry requires dramatic topology changes beyond adapter capacity
Real-Time GPU-Constrained Environments : Rendering NeRF at interactive framerates requires high-end hardware
Hyperparameter Tuning
Geometry Adapter Hidden Dimension : Default 64; increase to 128 for more expressive geometry changes, reduce to 32 for efficiency
Position Offset Bound : Default 0.1; increase to 0.2 for larger deformations, decrease to 0.05 for subtle changes
Latent Mixing Augmentations : Default 8; use 4-5 for very few samples (3-5 images), 12-15 for slightly larger sets (10+ images)
Smooth Loss Weight : Default 0.1; increase to 0.3 for smoother geometry, decrease to 0.01 for detailed local changes
Learning Rate : Start at 1e-3; reduce to 5e-4 if loss oscillates, increase to 2e-3 for faster convergence with stable training
Number of Training Epochs : Default 50; use 30 for very few samples, 100+ if computational budget allows
Common Pitfalls
Over-Aggressive Latent Mixing : Too many augmentations can create unrealistic, inconsistent face geometry. Use moderation
Ignoring Smooth Regularization : Without smoothness constraints, geometry adapter produces noisy, artifact-prone edits
Mask-Geometry Mismatch : Masks that don't align with natural facial regions cause unnatural deformations
Insufficient Few-Shot Diversity : If all training images show similar expressions or lighting, adapter overfits to spurious patterns
Position Offset Over-Scaling : Large offsets (>0.2) cause topology breaks and rendering artifacts
Neglecting Feature Consistency : Ensure tri-plane features remain stable across editing strength variations to avoid color shifts
References
Neural Radiance Fields (NeRF): Volumetric scene representation for view synthesis
3D Face Modeling: Morphable models and geometric manipulation in face space
Geometry Adapters: Parameter-efficient modules for targeted manipulation in neural representations
Latent Space Augmentation: Data synthesis through interpolation and mixing in learned representations
Few-Shot Learning: Training effective models with minimal labeled data
Tri-Plane Representations: Efficient factorized 3D representation for neural rendering