VideoP2PModel<T>

Models & Types · AiDotNet.Diffusion.Video.VideoEditing

VideoP2P prompt-to-prompt cross-attention control for video editing.

Inheritance: DiffusionModelBase<T> → LatentDiffusionModelBase<T> → VideoDiffusionModelBase<T> → VideoP2PModel<T>

For Beginners

VideoP2P extends prompt-to-prompt image editing to video by controlling cross-attention maps across frames. You can change specific elements (e.g., cat to dog) while preserving the rest of the video content.

How It Works

References:

  • Paper: “Video-P2P: Video Editing with Cross-attention Control” (Liu et al., 2024)

VideoP2P extends the Prompt-to-Prompt image editing approach to video by manipulating cross- attention maps in the diffusion UNet during video generation. Enables precise semantic editing (e.g., changing object attributes) while preserving temporal consistency through shared attention.

Technical specifications:

  • Architecture: Cross-Attention Control + Temporal Consistency
  • Latent channels: 4
  • Default: 24 frames at 8 FPS
  • Supports I2V: No | T2V: Yes | V2V: Yes

Example

var options = new DiffusionModelOptions<float> { LatentChannels = 4, DefaultInferenceSteps = 50 };
var input = Tensor<float>.CreateRandom(new[] { 1, 4, 24, 64, 64 });
var trainX = Tensor<float>.CreateRandom(4, 8);
var trainY = Tensor<float>.CreateRandom(4, 2);
var result = new AiModelBuilder<float, Tensor<float>, Tensor<float>>()
    .ConfigureModel(new VideoP2PModel<float>(options: options))
    .Build(trainX, trainY);
var edited = result.Predict(input);

Constructors

Constructor Summary
VideoP2PModel(NeuralNetworkArchitecture<T> architecture, DiffusionModelOptions<T> options, INoiseScheduler<T> scheduler, VideoUNetPredictor<T> predictor, TemporalVAE<T> temporalVAE, IConditioningModule<T> conditioner, int defaultNumFrames, int defaultFPS, int? seed) Initializes a new instance of VideoP2PModel with full customization support.

Properties

Property Summary
IConditioningModule<T> Conditioner { get; }
INoisePredictor<T> NoisePredictor { get; }
IVAEModel<T> TemporalVAE { get; }
IVAEModel<T> VAE { get; }
bool SupportsImageToVideo { get; }
bool SupportsTextToVideo { get; }
bool SupportsVideoToVideo { get; }
int LatentChannels { get; }

Methods

Method Summary
ModelMetadata<T> GetModelMetadata()