Transformers documentation

VidEoMT

You are viewing main version, which requires installation from source. If you'd like regular pip install, checkout the latest stable version (v5.22.1).
Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

このモデルは2026年2月19日にHF papersで公開され、2026年3月25日にHugging Face Transformersに貢献されました。

VidEoMT

概要

VidEoMTモデルは、Narges Norouzi、Idil Esen Zulfikar、Niccolò Cavagnero、Tommie Kerssies、Bastian Leibe、Gijs Dubbelman、Daan de Geus による論文 Your ViT is Secretly Also a Video Segmentation Model で提案されました。Video Encoder-only Mask Transformer (VidEoMT) は、プレーンな Vision Transformer (ViT) をベースに構築された、オンライン動画セグメンテーションのための軽量なエンコーダー専用モデルです。これは EoMT の動画への最小限の拡張であり、専用のトラッキングモジュールや重いタスク固有のヘッドに依存することなく、ViTエンコーダー内で空間的および時間的な推論を行います。

論文の抄録は以下の通りです。

既存のオンライン動画セグメンテーションモデルは、フレームごとのセグメンターと複雑な専用トラッキングモジュールを組み合わせるのが一般的です。これらのモジュールは効果的ですが、アーキテクチャの複雑さと計算オーバーヘッドを大きく引き起こします。最近の研究では、十分な容量と大規模な事前学習によってスケーリングされたプレーンなVision Transformer (ViT) エンコーダーは、専用モジュールを必要とせずに高精度な画像セグメンテーションを実行できることが示唆されています。この観察を踏まえ、私たちは、専用のトラッキングモジュールを不要にするシンプルなエンコーダーオンリーの動画セグメンテーションモデル、Video Encoder-only Mask Transformer (VidEoMT) を提案します。エンコーダーオンリーのViTにおける時間モデリングを可能にするため、VidEoMTは、前フレームのクエリを再利用してフレーム間で情報を伝達する軽量なクエリ伝播メカニズムを導入しています。これと新しいコンテンツへの適応性をバランスさせるため、伝播されたクエリと時間的に無関係な学習済みクエリのセットを組み合わせるクエリ融合戦略を採用しています。その結果、VidEoMTは追加の複雑さなしでトラッカーの利点を獲得し、ViT-Lバックボーンで最大160 FPSで動作しながら、5倍から10倍高速で競争力のある精度を実現しています。

ヒント:

  • VidEoMTは現在、DINOv2バックボーン(register tokens付き)のみをサポートしています。利用可能なモデルサイズはViT-S、ViT-B、ViT-Lです。
  • モデルは、(batch_size, num_frames, 3, height, width) の形状を持つ 5 次元テンソルとして動画入力を受け入れます。
  • VidEoMTは3つの動画セグメンテーションタスクをサポートしています:インスタンス、セマンティック、およびパノプティックセグメンテーションです。それぞれについて、動画プロセッサに専用の後処理メソッドが用意されています。

このモデルはnielsrによって提供されました。 元のコードはこちらで確認できます。

アーキテクチャ情報

VidEoMTは、register tokensを備えた通常のDINOv2事前学習済みVision Transformerをセグメンテーションモデルとして再利用するEoMTを基盤としています。EoMTは、ViTエンコーダー内に直接、学習されたobject queriesと軽量なmask prediction headを導入することで、タスク固有のデコーダーの必要性を排除しています。

VidEoMTは、次の2つの重要な追加要素により、これを動画に拡張します。

  1. クエリの伝播: 前フレームのオブジェクトクエリは、線形射影(query_updater)を通じて次のフレームに引き継がれ、専用のトラッカーを用いずに時間的な推論を可能にします。
  2. クエリ融合: 伝播されたクエリに、時間的に依存しない学習済みクエリのセットを加えることで、動画に新たに出現するオブジェクトに適応できるようにします。

初期のエンコーダ層はすべてのフレームを独立して(並列に)処理しますが、最終ブロックは融合されたクエリを用いてフレームごとに動作し、フレームごとのマスクとクラスの予測を生成します。

使用例

Hugging Face による VidEoMT の実装を使用して、事前学習済みモデルで推論を実行します。以下の例では、サンプル動画に対する動画インスタンス、セマンティック、パノプティックのポストプロセッシングをデモするために、公開されている tue-mps/videomt-dinov2-small-ytvis2019 チェックポイントを再利用しています。

Video Instance Segmentation

import matplotlib.pyplot as plt
import numpy as np
import torch

from transformers import AutoModelForUniversalSegmentation, AutoVideoProcessor
from transformers.video_utils import load_video


model_id = "tue-mps/videomt-dinov2-small-ytvis2019"
processor = AutoVideoProcessor.from_pretrained(model_id)
model = AutoModelForUniversalSegmentation.from_pretrained(model_id, device_map="auto")

video_url = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/videos/pexels-allan-mas-5362370.mp4"
# Sample 8 frames to keep the example lightweight.
video_frames, _ = load_video(video_url, num_frames=8)

inputs = processor(videos=[video_frames], return_tensors="pt").to(model.device)

with torch.inference_mode():
    outputs = model(**inputs)

original_height, original_width = video_frames[0].shape[:2]
target_sizes = [(original_height, original_width)] * len(video_frames)

results = processor.post_process_instance_segmentation(
    outputs,
    target_sizes=target_sizes,
)

fig, axes = plt.subplots(2, 4, figsize=(16, 8))
for idx, (ax, frame, result) in enumerate(zip(axes.flatten(), video_frames, results)):
    ax.imshow(frame)
    seg = result["segmentation"].cpu().numpy()
    masked = np.ma.masked_where(seg == -1, seg)
    ax.imshow(masked, alpha=0.6, cmap="tab20")
    ax.set_title(f"Frame {idx}")
    ax.axis("off")
plt.suptitle("Video Instance Segmentation")
plt.tight_layout()
plt.show()

ビデオセマンティックセグメンテーション

import matplotlib.pyplot as plt
import torch

from transformers import AutoModelForUniversalSegmentation, AutoVideoProcessor
from transformers.video_utils import load_video


model_id = "tue-mps/videomt-dinov2-small-ytvis2019"
processor = AutoVideoProcessor.from_pretrained(model_id)
model = AutoModelForUniversalSegmentation.from_pretrained(model_id, device_map="auto")

video_url = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/videos/pexels-allan-mas-5362370.mp4"
# Sample 8 frames to keep the example lightweight.
video_frames, _ = load_video(video_url, num_frames=8)

inputs = processor(videos=[video_frames], return_tensors="pt").to(model.device)

with torch.inference_mode():
    outputs = model(**inputs)

original_height, original_width = video_frames[0].shape[:2]
target_sizes = [(original_height, original_width)] * len(video_frames)

preds = processor.post_process_semantic_segmentation(
    outputs,
    target_sizes=target_sizes,
)

fig, axes = plt.subplots(2, 4, figsize=(16, 8))
for idx, (ax, frame, seg_map) in enumerate(zip(axes.flatten(), video_frames, preds)):
    ax.imshow(frame)
    ax.imshow(seg_map.cpu().numpy(), alpha=0.6, cmap="tab20")
    ax.set_title(f"Frame {idx}")
    ax.axis("off")
plt.suptitle("Video Semantic Segmentation")
plt.tight_layout()
plt.show()

Video Panoptic Segmentation

import matplotlib.pyplot as plt
import numpy as np
import torch

from transformers import AutoModelForUniversalSegmentation, AutoVideoProcessor
from transformers.video_utils import load_video


model_id = "tue-mps/videomt-dinov2-small-ytvis2019"
processor = AutoVideoProcessor.from_pretrained(model_id)
model = AutoModelForUniversalSegmentation.from_pretrained(model_id, device_map="auto")

video_url = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/videos/pexels-allan-mas-5362370.mp4"
# Sample 8 frames to keep the example lightweight.
video_frames, _ = load_video(video_url, num_frames=8)

inputs = processor(videos=[video_frames], return_tensors="pt").to(model.device)

with torch.inference_mode():
    outputs = model(**inputs)

original_height, original_width = video_frames[0].shape[:2]
target_sizes = [(original_height, original_width)] * len(video_frames)

results = processor.post_process_panoptic_segmentation(
    outputs,
    target_sizes=target_sizes,
)

fig, axes = plt.subplots(2, 4, figsize=(16, 8))
for idx, (ax, frame, result) in enumerate(zip(axes.flatten(), video_frames, results)):
    ax.imshow(frame)
    seg = result["segmentation"].cpu().numpy()
    masked = np.ma.masked_where(seg == -1, seg)
    ax.imshow(masked, alpha=0.6, cmap="tab20")
    ax.set_title(f"Frame {idx}")
    ax.axis("off")
plt.suptitle("Video Panoptic Segmentation")
plt.tight_layout()
plt.show()

VideomtVideoProcessor

クラス transformers.VideomtVideoProcessor

< >

( **kwargs: *<class 'transformers.processing_utils.VideosKwargs'> )

パラメータ

  • do_convert_rgb (bool、kwargs、optional、デフォルトは True) — 画像を RGB に変換するかどうか。
  • do_resize (bool、kwargs、任意、デフォルトはTrue) — 画像をリサイズするかどうか。
  • size (Annotated[int | list[int] | tuple[int, ...] | dict[str, int] | None, None], kwargs、デフォルトは {'height' -- 640, 'width': 640}): モデルへの最大入力サイズを指定します。
  • default_to_square (bool、kwargs、任意、デフォルトは True) — size が int の場合、リサイズ時に正方形の画像をデフォルトとするかどうかを指定します。
  • resample (Annotated[Union[int, PILImageResampling, NoneType], None], kwargs, デフォルトは 2) — 画像のリサイズ時に使用するリサンプリングフィルタです。PILImageResampling の列挙型のいずれかを使用できます。do_resize が True に設定されている場合のみ、効果が現れます。
  • do_rescale (bool、kwargs、任意、デフォルトはTrue) — 画像をリスケールするかどうかを指定します。
  • rescale_factor (float、kwargs、任意、デフォルト値は 0.00392156862745098) — do_rescale が True に設定されている場合、画像をリスケールするための係数です。
  • do_normalize (bool、kwargs、optional、デフォルトはTrue) — 画像を正規化するかどうかを指定します。
  • image_mean (Union[float, list[float], tuple[float, ...]]、kwargs、optional、デフォルト値は [0.485, 0.456, 0.406]) — 正規化に使用する画像の平均値。do_normalize が True に設定されている場合のみ有効です。
  • image_std (Union[float, list[float], tuple[float, ...]]、kwargs、optional、デフォルト値は [0.229, 0.224, 0.225]) — 正規化に使用する画像の標準偏差。do_normalize が True に設定されている場合のみ有効です。
  • do_center_crop (bool、kwargs、optional、デフォルトは False) — 画像を中央クロップするかどうか。
  • do_pad (bool, kwargs, optional) — 画像をパディングするかどうかを指定します。パディングは、バッチ内の最大サイズに合わせるか、画像ごとに固定の正方形サイズに合わせるかのいずれかで行われます。具体的なパディング戦略はモデルによって異なります。
  • crop_size (Annotated[int | list[int] | tuple[int, ...] | dict[str, int] | None, None], kwargs) — center_crop を適用した後の出力画像のサイズ。
  • data_format (Union[str, ~image_utils.ChannelDimension]、kwargs、任意) — サポートされているのは ChannelDimension.FIRST のみです。slow processors との互換性のために追加されました。
  • input_data_format (Union[str, ~image_utils.ChannelDimension], kwargs, 省略可) — 入力画像のチャネル次元の形式です。設定されていない場合、入力画像からチャネル次元の形式が推測されます。次のいずれかになります:
    • "channels_first" または ChannelDimension.FIRST: (num_channels, height, width) 形式の画像。
    • "channels_last" または ChannelDimension.LAST: (高さ, 幅, チャネル数) 形式の画像。
    • "none" または ChannelDimension.NONE: (height, width) 形式の画像。
  • device (Annotated[Union[str, torch.device, NoneType], None], kwargs) — 動画を処理するデバイスです。未設定の場合、入力動画からデバイスが推論されます。
  • do_sample_frames (bool、kwargs、任意、デフォルトは False) — 処理前に動画からフレームをサンプリングするか、動画全体を処理するかを指定します。
  • video_metadata (Annotated[~video_utils.VideoMetadata | dict | list[dict | ~video_utils.VideoMetadata] | list[list[dict | ~video_utils.VideoMetadata]] | None, None], kwargs) — 動画のメタデータで、総再生時間、fps、総フレーム数に関する情報を含みます。動画からのフレームサンプリングやタイムスタンプの計算に使用されます。動画を処理する前に手動でデコードしようとしている場合を除き、メタデータは渡さないでください。
  • fps (Annotated[int | float | None, None], kwargs) — do_sample_frames=True の場合、1 秒あたりサンプリングするターゲットフレーム数。
  • num_frames (Annotated[int | None, None], kwargs) — do_sample_frames=True の場合、サンプリングするフレームの最大数。
  • return_metadata (bool、kwargs、任意、デフォルトは False) — 動画メタデータを返すかどうかを指定します。動画メタデータは、動画の長さ、fps、デコードバックエンドなどの情報を含むオブジェクトです。
  • return_tensors (Annotated[str | ~utils.generic.TensorType | None, None], kwargs) — 設定されている場合、特定のフレームワークのテンソルを返します。受け入れられる値は以下の通りです:
    • 'pt': PyTorchのtorch.Tensorオブジェクトを返します。
    • 'np': NumPyのnp.ndarrayオブジェクトを返します。
  • **kwargs (VideosKwargs、optional) — テキスト、画像、動画、音声の各モダリティに対する追加の処理オプション。モデル固有のパラメータは上記にリストされています。サポートされている引数の完全なリストについては、TypedDictクラスを参照してください。

VideomtVideoProcessor ビデオプロセッサを構築します。

post_process_semantic_segmentation

< >

( outputstarget_sizes: listreturn_segmentation_scores: bool = False ) → list[torch.Tensor] or list[SemanticSegmentationPostProcessorOutput]

パラメータ

  • outputs (VideomtForUniversalSegmentationOutput) — モデルの生出力です。
  • target_sizes (list[tuple[int, int]]) — 各予測の最終的な要求サイズに対応する(height, width)のタプルのリストです。 長さは、出力のフレーム数と一致する必要があります。
  • return_segmentation_scores (bool、省略可、デフォルトは False) — セグメンテーションマップとともにセグメンテーションスコアを返すかどうか。True の場合、返されるリストの各要素は、segmentation(クラス ID、形状 (height, width))と segmentation_scores(形状 (num_classes, height, width))というフィールドを持つ SemanticSegmentationPostProcessorOutput です。

戻り値

list[torch.Tensor] または list[SemanticSegmentationPostProcessorOutput]

return_segmentation_scores=False(デフォルト)の場合、各要素がクラス ID を持つ (height, width) の形状のセグメンテーションマップである、長さ batch_size のリストが返されます。return_segmentation_scores=True の場合、フィールド segmentation(クラス ID、形状 (height, width))と segmentation_scores(形状 (num_classes, height, width))を持つ SemanticSegmentationPostProcessorOutput のリストが返されます。どちらの場合も、(height, width) はターゲットサイズに対応します。

VideomtForUniversalSegmentation の出力をセマンティックセグメンテーションの予測に変換します。

post_process_instance_segmentation

< >

( outputstarget_sizes: listthreshold: float = 0.5 ) → list[dict]

パラメータ

  • outputs (VideomtForUniversalSegmentationOutput) — モデルの生出力です。
  • target_sizes (list[tuple[int, int]]) — 各予測の最終的な要求サイズに対応する(height, width)のタプルのリストです。 長さは、出力のフレーム数と一致する必要があります。
  • threshold (float、任意、デフォルト値は 0.5)— インスタンスを保持するための最低限の総合スコア。

戻り値

list[dict]

各フレームに対応する辞書のリスト(各辞書には以下が含まれます):

  • "segmentation" — インスタンス ID(背景の場合は -1)を持つ、形状が (height, width) の torch.Tensor。
  • "segments_info" — 各インスタンスについて"id"、"label_id"、"score"を含む辞書のリスト。

VideomtForUniversalSegmentationの出力をインスタンスセグメンテーションの予測に変換します。

post_process_panoptic_segmentation

< >

( outputstarget_sizes: listthreshold: float = 0.8mask_threshold: float = 0.5overlap_mask_area_threshold: float = 0.8label_ids_to_fuse: set[int] | None = None ) → list[dict]

パラメータ

  • outputs (VideomtForUniversalSegmentationOutput) — モデルの生出力です。
  • target_sizes (list[tuple[int, int]]) — 各予測の最終的な要求サイズに対応する(height, width)のタプルのリストです。 長さは、出力のフレーム数と一致する必要があります。
  • threshold (float, 任意、デフォルト値は 0.8) — 予測セグメントを保持するための最低スコア。
  • mask_threshold (float、任意、デフォルトは 0.5)— マスクの確率を二値化するための閾値です。
  • overlap_mask_area_threshold (float、任意、デフォルト値は 0.8) — マスクを単一のセグメントにマージするための重複しきい値。
  • label_ids_to_fuse (set[int], 省略可) — 非連結領域間で融合すべきラベル ID。

戻り値

list[dict]

各フレームに対応する辞書のリスト(各辞書には以下が含まれます):

  • "segmentation" — セグメント ID(背景の場合は -1)を持つ、形状が (height, width) の torch.Tensor。
  • "segments_info" — 各セグメントの"id"、"label_id"、"score"を含む辞書のリスト。

VideomtForUniversalSegmentationの出力をパノプティックセグメンテーション予測に変換します。

VideomtConfig

クラス transformers.VideomtConfig

< >

( transformers_version: str | None = Nonearchitectures: list[str] | None = Noneoutput_hidden_states: bool | None = Falsereturn_dict: bool | None = Truedtype: str | torch.dtype | None = Nonechunk_size_feed_forward: int = 0is_encoder_decoder: bool = Falseid2label: dict[int, str] | dict[str, str] | None = Nonelabel2id: dict[str, int] | dict[str, str] | None = Noneproblem_type: Literal['regression', 'single_label_classification', 'multi_label_classification'] | None = Nonehidden_size: int = 1024num_hidden_layers: int = 24num_attention_heads: int = 16hidden_act: str = 'gelu'hidden_dropout_prob: float | int = 0.0initializer_range: float = 0.02layer_norm_eps: float = 1e-06image_size: int | list[int] | tuple[int, int] = 640patch_size: int | list[int] | tuple[int, int] = 16num_channels: int = 3mlp_ratio: int = 4layerscale_value: float = 1.0drop_path_rate: float | int = 0.0num_upscale_blocks: int = 2attention_dropout: float | int = 0.0use_swiglu_ffn: bool = Falsenum_blocks: int = 4no_object_weight: float = 0.1class_weight: float = 2.0mask_weight: float = 5.0dice_weight: float = 5.0train_num_points: int = 12544oversample_ratio: float = 3.0importance_sample_ratio: float = 0.75num_queries: int = 200num_register_tokens: int = 4 )

パラメータ

  • hidden_size (int、任意、デフォルトは 1024) — 隠れ表現の次元数。
  • num_hidden_layers (int、任意、デフォルトは24) — Transformer デコーダーの隠れ層の数。
  • num_attention_heads (int、任意、デフォルトは 16) — Transformer デコーダーの各アテンション層におけるアテンションヘッドの数。
  • hidden_act (str、任意、デフォルトは gelu) — デコーダーで使用する非線形活性化関数(関数または文字列)。例えば、"gelu"、 "relu"、"silu" など。
  • hidden_dropout_prob (Union[float, int]、任意、デフォルト値は0.0) — embeddings、encoder、pooler 内のすべての全結合層における dropout 確率です。
  • initializer_range (float、任意、デフォルトは 0.02) — すべての重み行列を初期化するための truncated_normal_initializer の標準偏差です。
  • layer_norm_eps (float、任意、デフォルトは 1e-06) — レイヤーノーマル層で使用する epsilon です。
  • image_size (Union[int, list[int], tuple[int, int]]、任意、デフォルトは 640) — 各画像のサイズ(解像度)です。
  • patch_size (Union[int, list[int], tuple[int, int]]、任意、デフォルトは16) — 各パッチのサイズ(解像度)です。
  • num_channels (int、任意、デフォルトは3) — 入力チャネル数。
  • mlp_ratio (int、任意、デフォルトは 4) — MLP の隠れ層の次元と埋め込み次元の比率です。
  • layerscale_value (float、任意、デフォルト値は 1.0) — LayerScale パラメータの初期値です。
  • drop_path_rate (Union[float, int]、任意、デフォルトは 0.0) — パッチ融合におけるドロップパスの率。
  • num_upscale_blocks (int、任意、デフォルト値は 2)— デコーダーまたはセグメンテーションヘッドで使用するアップサンプリングブロックの数。
  • attention_dropout (Union[float, int]、任意、デフォルトは 0.0) — アテンション確率のドロップアウト率です。
  • use_swiglu_ffn (bool、任意、デフォルトは False) — SwiGLUフィードフォワードニューラルネットワークを使用するかどうかを指定します。
  • num_blocks (int、任意、デフォルトは 4) — アーキテクチャにおける特徴量ブロックまたはステージの数。
  • no_object_weight (float、任意、デフォルト値は 0.1)— パノラミック/インスタンスセグメンテーションにおける「no object」クラスの損失重みです。
  • class_weight (float、省略可、デフォルト値は 2.0) — 分類ターゲットの損失重みです。
  • mask_weight (float、任意、デフォルト値は 5.0) — マスク予測の損失重み。
  • dice_weight (float、任意、デフォルトは 5.0) — パノラミックセグメンテーション損失における dice loss の相対的な重み。
  • train_num_points (int、任意、デフォルト値は 12544)— 学習中にマスク損失の計算のためにサンプリングする点の数。
  • oversample_ratio (float、任意、デフォルトは 3.0) — マスク学習におけるポイントサンプリングで使用するオーバーサンプリング比率。
  • importance_sample_ratio (float、任意、デフォルト値: 0.75) — 学習中に重要度に基づいてサンプリングするポイントの比率。
  • num_queries (int、任意、デフォルトは 200) — Transformer におけるオブジェクトクエリの数。
  • num_register_tokens (int、省略可、デフォルト値は 4) — Transformer の入力に追加される、学習可能な register token の数です。

これは VideomtModel の設定を保存するための設定クラスです。指定された引数に基づいて Videomt モデルをインスタンス化し、モデルのアーキテクチャを定義するために使用されます。デフォルト値で設定をインスタンス化すると、tue-mps/videomt-dinov2-small-ytvis2019 と同様の設定が得られます。

設定オブジェクトはPreTrainedConfigを継承し、モデルの出力を制御するために使用できます。詳細については、PreTrainedConfigのドキュメントを参照してください。

例:

>>> from transformers import VideomtConfig, VideomtForUniversalSegmentation

>>> # Initialize configuration
>>> config = VideomtConfig()

>>> # Initialize model
>>> model = VideomtForUniversalSegmentation(config)

>>> # Access config
>>> config = model.config

VideomtPreTrainedModel

クラス transformers.VideomtPreTrainedModel

< >

( config: PreTrainedConfig*inputs**kwargs )

パラメータ

  • config (PreTrainedConfig) — モデルのパラメータをすべて含むモデル設定クラスです。設定ファイルで初期化しても、モデルに関連する重みは読み込まれず、設定のみが読み込まれます。モデルの重みをロードするには、from_pretrained() メソッドを参照してください。

このモデルは PreTrainedModel を継承しています。すべてのモデルに実装されている汎用的なメソッド(ダウンロードや保存、入力埋め込みのリサイズ、ヘッドのプルーニングなど)については、スーパークラスのドキュメントを参照してください。

このモデルは、PyTorchのtorch.nn.Moduleのサブクラスでもあります。 通常のPyTorch Moduleとして使用し、一般的な使用方法や動作に関する詳細については、PyTorchのドキュメントを参照してください。

forward

( *args**kwargs )

ドット区切りパス(例: torch.float32)のモック値: 属性アクセスのチェーン、呼び出しはパススルーデコレータとして動作し、repr はドット区切りパスを返し、ベースクラスとして使用するとプレーンな type ベースに置き換えられます(PEP 560 の __mro_entries__)。これにより、実際のサブクラスは通常のメタクラスを保持し、inspect.signature はモックの __init__ ではなく、実際の __init__ を読み取ります。

VideomtForUniversalSegmentation

クラス transformers.VideomtForUniversalSegmentation

< >

( config: VideomtConfig )

パラメータ

  • config (VideomtConfig) — モデルのパラメータをすべて含むモデル設定クラスです。設定ファイルで初期化しても、モデルに関連する重みは読み込まれず、設定のみが読み込まれます。モデルの重みをロードするには、from_pretrained() メソッドを参照してください。

インスタンス/セマンティック/パンオプティックセグメンテーション用のヘッドを上部に備えたVideomtモデル。

このモデルは PreTrainedModel を継承しています。すべてのモデルに実装されている汎用的なメソッド(ダウンロードや保存、入力埋め込みのリサイズ、ヘッドのプルーニングなど)については、スーパークラスのドキュメントを参照してください。

このモデルは、PyTorchのtorch.nn.Moduleのサブクラスでもあります。 通常のPyTorch Moduleとして使用し、一般的な使用方法や動作に関する詳細については、PyTorchのドキュメントを参照してください。

forward

< >

( pixel_values_videos: typing.Optional[torch.Tensor] = Nonemask_labels: list[torch.Tensor] | None = Noneclass_labels: list[torch.Tensor] | None = Nonepatch_offsets: list[torch.Tensor] | None = None**kwargs: *<class 'transformers.utils.generic.TransformersKwargs'> ) → VideomtForUniversalSegmentationOutput or tuple(torch.FloatTensor)

パラメータ

  • pixel_values_videos (torch.Tensor、任意) — (batch_size, num_frames, num_channels, height, width) の形状を持つ動画入力。
  • mask_labels (list[torch.Tensor]、省略可) — 5次元の動画入力には対応していません。
  • class_labels (list[torch.LongTensor]、任意) — 5次元の動画入力には対応していません。
  • patch_offsets (list[torch.Tensor]、省略可) — 動画入力では使用されず、モジュール互換性のためにのみ保持されています。

戻り値

VideomtForUniversalSegmentationOutput または tuple(torch.FloatTensor)

VideomtForUniversalSegmentationOutput、またはtorch.FloatTensorのタプル(return_dict=Falseが渡された場合、またはconfig.return_dict=Falseの場合)。設定(VideomtConfig)や入力に応じて、さまざまな要素で構成されます。

VideomtForUniversalSegmentationのforwardメソッドは、__call__特殊メソッドをオーバーライドします。

この関数内でフォワードパスの手順を定義する必要がありますが、その後、この関数ではなくModuleインスタンスを呼び出すべきです。前者は前処理と後処理の実行を適切に処理するのに対し、後者はそれらを黙って無視するためです。

  • loss (torch.Tensor, optional) — ラベルが存在する場合に返される、計算された損失。
  • class_queries_logits (torch.FloatTensor, optional) — 各クエリに対して提案されるクラスを表す、形状が(batch_size, num_queries, num_labels + 1)のテンソル。nullクラスを組み込む必要があるため、+ 1が必要です。
  • masks_queries_logits (torch.FloatTensor, オプション) — 各クエリに対する提案マスクを表す、形状が(batch_size, num_queries, height, width)のテンソル。
  • last_hidden_state (torch.FloatTensor、shape (batch_size, num_channels, height, width)) — 最終層の最後の隠れ状態(最終的な特徴マップ)。
  • hidden_states (tuple(torch.FloatTensor)、optional、output_hidden_states=True が渡された場合または config.output_hidden_states=True の場合に返されます)— torch.FloatTensor のタプル(埋め込みの出力用 1 つ + 各ステージの出力用 1 つ)、shape は (batch_size, sequence_length, hidden_size)。モデルの全レイヤーの隠れ状態です。
  • attentions (tuple(tuple(torch.FloatTensor))、optional、output_attentions=True が渡された場合または config.output_attentions=True の場合に返されます) — tuple(torch.FloatTensor) のタプル(レイヤーごとに1つ)、形状は (batch_size, num_heads, sequence_length, sequence_length)。Transformer デコーダーからの Self Attention と Cross Attention の重み。
Update on GitHub