loadVideoMattingModel()v4.0.523
Downloads a video matting model from an immutable path on remotion.media and initializes it. Calling it before separateVideoLayers() lets you show model-loading progress.
load-model.tsimport {loadVideoMattingModel } from '@remotion/video-matting'; constresult = awaitloadVideoMattingModel ({model : 'modnet',onProgress : ({progress }) => {console .log (progress ); }, });console .log (result .alreadyLoaded );
Options
model
One of the names returned by getAvailableModels().
onProgress?
Called while model files are resolved and downloaded. Default: no callback.
The callback receives these properties:
status
The current model-loading status.
file
The model file associated with the update, or null for aggregate progress.
progress
Download progress between 0 and 1, or null when it cannot be calculated.
loadedBytes
The number of bytes downloaded, or null when it is unknown.
totalBytes
The total number of bytes, or null when it is unknown.
Return value
Returns an object with this property:
alreadyLoaded
Whether the same model was already initialized in memory.
The browser manages the persistent Transformers.js cache. This function also retains the initialized model in memory until disposeVideoMattingModel() is called or the page closes.
The hosted files are byte-identical to files from the pinned upstream Hugging Face revision.
Compatibility
| Browsers | Environments | |||||
|---|---|---|---|---|---|---|
Chrome | Firefox | Safari | ||||