# TIPSv2 DPT

    
        
        
    

## 概要

Dense Prediction Transformer Head (DPT) を備えた [TIPSv2](./tipsv2) については、詳細は [TIPSv2](./tipsv2) のドキュメントを参照してください。<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/tipsv2_architecture.jpg" alt="tipsv2 architecture overview" width="600"/>

このモデルは[guarin](https://huggingface.co/guarin)によって提供されました。元のコードは[こちら](https://github.com/google-deepmind/tips)で確認できます。

すべてのオリジナルのTIPSv2 DPTチェックポイントは、[TIPSv2](https://huggingface.co/collections/google/tipsv2)コレクションの下で確認できます。

> [!TIP]
> TIPSv2のビジョンおよび言語バックボーン、ならびにゼロショット画像分類については、[TIPSv2](./tipsv2)を参照してください。

```python
from transformers import pipeline

pipe = pipeline(task="depth-estimation", model="google/tipsv2-b14-dpt", device_map="auto")
out = pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/room.jpg")
out["depth"]  # PIL Image normalized to [min, max] of predicted_depth

# Visualization
import matplotlib.pyplot as plt
from transformers.image_utils import load_image

image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/room.jpg")

figure, axes = plt.subplots(1, 2, figsize=(10, 5))
axes[0].imshow(image)
axes[1].imshow(out["depth"])
axes[1].set_title("Depth")
for axis in axes:
    axis.axis("off")
plt.show()
```

<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/tipsv2_depth_estimation.jpg"
alt="tipsv2 depth estimation pipeline" width="600"/>

```python
from transformers import pipeline

pipe = pipeline(task="image-segmentation", model="google/tipsv2-b14-dpt", device_map="auto")
out = pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/room.jpg")
out[0]["label"] # string class label
out[0]["mask"]  # PIL Image with binary mask set to class id

# Visualization
import matplotlib.pyplot as plt
from transformers.image_utils import load_image

image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/room.jpg")

figure, axes = plt.subplots(1, 2, figsize=(10, 5))
axes[0].imshow(image)
axes[1].imshow(out[0]["mask"], cmap="gray")
axes[1].set_title(out[0]["label"])
for axis in axes:
    axis.axis("off")
plt.show()
```

<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/tipsv2_pipeline_segmentation.jpg"
alt="tipsv2 image segmentation pipeline" width="600"/>

[Tipsv2DptForDensePrediction](/docs/transformers/main/ja/model_doc/tipsv2_dpt#transformers.Tipsv2DptForDensePrediction) を使用すると、共有バックボーンに対して単一のフォワードパスで、深度、法線、セグメンテーションの3つのタスクをすべて実行できます。

```python
import torch
from transformers import Tipsv2DptForDensePrediction, AutoImageProcessor
from transformers.image_utils import load_image

model_id = "google/tipsv2-b14-dpt"
model = Tipsv2DptForDensePrediction.from_pretrained(model_id, device_map="auto")
image_processor = AutoImageProcessor.from_pretrained(model_id)

image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/room.jpg")
inputs = image_processor(images=image, return_tensors="pt").to(model.device)

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

outputs.predicted_depth # (batch_size, height, width) tensor with predicted depth in meters
outputs.normals # (batch_size, 3, height, width) tensor with normals in XYZ format (unnormalized)
outputs.segmentation_logits # # (batch_size, config.num_labels, height, width) tensor with segmentation logits

depth_results = image_processor.post_process_depth_estimation(outputs, target_sizes=[(image.height, image.width)])
normal_results = image_processor.post_process_normal_estimation(outputs, target_sizes=[(image.height, image.width)])
segmentation_results = image_processor.post_process_semantic_segmentation(outputs, target_sizes=[(image.height, image.width)])

predicted_depth = depth_results[0]["predicted_depth"]  # (height, width) tensor with predicted depth in meters
normals = normal_results[0]["normals"] # (3, height, width) tensor with normals in XYZ format (L2-normalized)
segmentation = segmentation_results[0] # (height, width) tensor with class ids

# Visualization
import matplotlib.pyplot as plt

# Convert L2-normalized normals in [-1, 1] to RGB in [0, 255]
normals_rgb = ((normals + 1.0) / 2.0 * 255.0).clamp(0, 255).to(torch.uint8)

figure, axes = plt.subplots(2, 2, figsize=(10, 6))
axes[0, 0].imshow(image)
axes[0, 1].imshow(predicted_depth.cpu())
axes[0, 1].set_title("Depth")
axes[1, 0].imshow(normals_rgb.permute(1, 2, 0).cpu())
axes[1, 0].set_title("Normals")
axes[1, 1].imshow(segmentation.cpu())
axes[1, 1].set_title("Segmentation")
for axis in axes.flat:
    axis.axis("off")
plt.show()
```

<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/tipsv2_all_tasks.jpg"
alt="tipsv2 all tasks" width="600"/>

```python
import torch
from transformers import AutoModelForDepthEstimation, AutoImageProcessor
from transformers.image_utils import load_image

model_id = "google/tipsv2-b14-dpt"
model = AutoModelForDepthEstimation.from_pretrained(model_id, device_map="auto")
image_processor = AutoImageProcessor.from_pretrained(model_id)

image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/room.jpg")
inputs = image_processor(images=image, return_tensors="pt").to(model.device)

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

results = image_processor.post_process_depth_estimation(outputs, target_sizes=[(image.height, image.width)])
predicted_depth = results[0]["predicted_depth"] # (height, width) tensor with predicted depth in meters

# Visualization
import matplotlib.pyplot as plt

figure, axes = plt.subplots(1, 2, figsize=(10, 5))
axes[0].imshow(image)
axes[1].imshow(predicted_depth.cpu())
axes[1].set_title("Depth")
for axis in axes:
    axis.axis("off")
plt.show()
```

<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/tipsv2_depth_estimation.jpg"
alt="tipsv2 depth estimation" width="600"/>

```python
import torch
from transformers import Tipsv2DptForNormalEstimation, AutoImageProcessor
from transformers.image_utils import load_image

model_id = "google/tipsv2-b14-dpt"
model = Tipsv2DptForNormalEstimation.from_pretrained(model_id, device_map="auto")
image_processor = AutoImageProcessor.from_pretrained(model_id)

image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/room.jpg")
inputs = image_processor(images=image, return_tensors="pt").to(model.device)

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

results = image_processor.post_process_normal_estimation(outputs, target_sizes=[(image.height, image.width)])
normals = results[0]["normals"]  # (3, height, width) tensor with normals in XYZ format (L2-normalized)

# Visualization
import matplotlib.pyplot as plt

# Convert L2-normalized normals in [-1, 1] to RGB in [0, 255]
normals_rgb = ((normals + 1.0) / 2.0 * 255.0).clamp(0, 255).to(torch.uint8)

figure, axes = plt.subplots(1, 2, figsize=(10, 5))
axes[0].imshow(image)
axes[1].imshow(normals_rgb.permute(1, 2, 0).cpu())
axes[1].set_title("Normals")
for axis in axes:
    axis.axis("off")
plt.show()
```

<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/tipsv2_normal_estimation.jpg"
alt="tipsv2 normal estimation" width="600"/>

```python
import torch
from transformers import AutoModelForSemanticSegmentation, AutoImageProcessor
from transformers.image_utils import load_image

model_id = "google/tipsv2-b14-dpt"
model = AutoModelForSemanticSegmentation.from_pretrained(model_id, device_map="auto")
image_processor = AutoImageProcessor.from_pretrained(model_id)

image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/room.jpg")
inputs = image_processor(images=image, return_tensors="pt").to(model.device)

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

results = image_processor.post_process_semantic_segmentation(outputs, target_sizes=[(image.height, image.width)])
segmentation_map = results[0]  # (height, width) tensor with class ids

# Visualization
import matplotlib.pyplot as plt

figure, axes = plt.subplots(1, 2, figsize=(10, 5))
axes[0].imshow(image)
axes[1].imshow(segmentation_map.cpu())
axes[1].set_title("Segmentation")
for axis in axes:
    axis.axis("off")
plt.show()
```

<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/tipsv2_semantic_segmentation.jpg"
alt="tipsv2 semantic segmentation" width="600"/>

## 注記

- [Tipsv2DptForDensePrediction](/docs/transformers/main/ja/model_doc/tipsv2_dpt#transformers.Tipsv2DptForDensePrediction) は、単一の共有バックボーンによるフォワードパスを実行し、`predicted_depth`、`normals`、`segmentation_logits` の3つの出力を同時に生成します。同じ画像に対してこれら3つのタスクすべてが必要な場合に使用してください。
- [Tipsv2DptForDepthEstimation](/docs/transformers/main/ja/model_doc/tipsv2_dpt#transformers.Tipsv2DptForDepthEstimation)、[Tipsv2DptForNormalEstimation](/docs/transformers/main/ja/model_doc/tipsv2_dpt#transformers.Tipsv2DptForNormalEstimation)、[Tipsv2DptForSemanticSegmentation](/docs/transformers/main/ja/model_doc/tipsv2_dpt#transformers.Tipsv2DptForSemanticSegmentation) は、他のヘッドを破棄する単一タスク用のバリアントです。パイプライン内での使用や、単一タスクでの推論に利用してください。

## Tipsv2DptConfig[[transformers.Tipsv2DptConfig]]

#### transformers.Tipsv2DptConfig[[transformers.Tipsv2DptConfig]]

```python
transformers.Tipsv2DptConfig(transformers_version: str | None = None, architectures: list[str] | None = None, output_hidden_states: bool | None = False, return_dict: bool | None = True, dtype: str | torch.dtype | None = None, chunk_size_feed_forward: int = 0, is_encoder_decoder: bool = False, id2label: dict[int, str] | dict[str, str] | None = None, label2id: dict[str, int] | dict[str, str] | None = None, problem_type: Literal['regression', 'single_label_classification', 'multi_label_classification'] | None = None, backbone_config: dict | transformers.configuration_utils.PreTrainedConfig | None = None, neck_hidden_sizes: list[int] | tuple[int, ...] | None = None, fusion_hidden_size: int = 256, reassemble_factors: list[int | float] | tuple[int | float, ...] | None = None, readout_activation: str = 'gelu_pytorch_tanh', num_depth_bins: int = 256, min_depth: float = 0.001, max_depth: float = 10.0, depth_decoder_activation: str = 'relu', semantic_loss_ignore_index: int = 255)
```

[ソース](https://github.com/huggingface/transformers/blob/main/src/transformers/models/tipsv2_dpt/configuration_tipsv2_dpt.py#L30)

**パラメータ:**

backbone_config (`Union[dict, ~configuration_utils.PreTrainedConfig]`、*optional*) : バックボーンモデルの設定です。

neck_hidden_sizes (`list[int]`、*optional*、デフォルトは`[96, 192, 384, 768]`) : バックボーンのフィーチャマップを投影するための隠れ層サイズです。

fusion_hidden_size (`int`、*optional*、デフォルトは 256) : フュージョン前のチャネル数。

reassemble_factors (`list[float]`、*optional*、デフォルトは`[4, 2, 1, 0.5]`) : reassemble 層の上/下サンプリング係数です。

readout_activation (`str`、*任意*、デフォルトは`"gelu_pytorch_tanh"`) : readout projection layerの後に適用される活性化関数。

num_depth_bins (`int`、*optional*、デフォルトは 256) : 深度推定ヘッドで使用される深度ビン（depth bins）の数。

min_depth (`float`、*optional*、デフォルト値は 0.001) : 深度ビン計算における最小深度値（メートル）。

max_depth (`float`、*optional*、デフォルト値は 10.0) : 深度ビン計算における最大深度値（メートル）。

depth_decoder_activation (`str`, *任意*, デフォルトは `"relu"`) : depth decoder projection layer の後に適用される活性化関数。

semantic_loss_ignore_index (`int`、*optional*、デフォルトは 255) : セマンティックセグメンテーションのクロスエントロピー損失で無視するラベルのインデックス。

これはTipsv2 DptModelの設定を保存するための設定クラスです。指定された引数に基づいてTipsv2 Dptモデルをインスタンス化し、モデルのアーキテクチャを定義するために使用されます。デフォルト値で設定をインスタンス化すると、[google/tipsv2-b14-dpt](https://huggingface.co/google/tipsv2-b14-dpt)の設定に類似した設定が得られます。

設定オブジェクトは [PreTrainedConfig](/docs/transformers/main/ja/main_classes/configuration#transformers.PreTrainedConfig) を継承し、モデルの出力を制御するために使用できます。詳細については、[PreTrainedConfig](/docs/transformers/main/ja/main_classes/configuration#transformers.PreTrainedConfig) のドキュメントを参照してください。

例:

```python
>>> from transformers import Tipsv2DptConfig, Tipsv2DptForDensePrediction

>>> configuration = Tipsv2DptConfig()
>>> model = Tipsv2DptForDensePrediction(configuration)
>>> configuration = model.config
```

## Tipsv2DptImageProcessor[[transformers.Tipsv2DptImageProcessor]]

#### transformers.Tipsv2DptImageProcessor[[transformers.Tipsv2DptImageProcessor]]

```python
transformers.Tipsv2DptImageProcessor(**kwargs: *<class 'transformers.processing_utils.ImagesKwargs'>)
```

[ソース](https://github.com/huggingface/transformers/blob/main/src/transformers/models/tipsv2_dpt/image_processing_tipsv2_dpt.py#L32)

**パラメータ:**

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' : 448, 'width': 448}`): モデルへの最大入力次元を説明します。

default_to_square (`bool`, *kwargs*, *任意*、デフォルトは `True`) : size が整数の場合、リサイズ時に正方形の画像をデフォルトとするかどうか。

crop_size (`Annotated[int | list[int] | tuple[int, ...] | dict[str, int] | None, None]`, *kwargs*) : `center_crop` を適用した後の出力画像のサイズ。

resample (`Annotated[Union[int, PILImageResampling, NoneType], None]`, *kwargs*、デフォルト値は`2`) : 画像のリサイズ時に使用するリサンプリングフィルタです。これは列挙型`PILImageResampling`のいずれかになります。`do_resize`が`True`に設定されている場合のみ、効果が現れます。

do_rescale (`bool`, *kwargs*, *optional*, デフォルトは `True`) : 画像をリスケールするかどうか。

rescale_factor (`float`, *kwargs*, *optional*, デフォルトは `0.00392156862745098`) : `do_rescale` が `True` に設定されている場合、画像をリスケールするための係数。

do_normalize (`bool`, *kwargs*, *optional*, デフォルトは `False`) : 画像を正規化するかどうかを指定します。

image_mean (`Union[float, list[float], tuple[float, ...]]`, *kwargs*, *optional*) : 正規化に使用する画像の平均値。`do_normalize` が `True` に設定されている場合のみ有効です。

image_std (`Union[float, list[float], tuple[float, ...]]`, *kwargs*, *optional*) : 正規化に使用する画像の標準偏差。`do_normalize` が `True` に設定されている場合のみ有効です。

do_pad (`bool`, *kwargs*, *任意*) : 画像にパディングを適用するかどうか。パディングは、バッチ内の最大サイズに合わせるか、画像ごとに固定の正方形サイズに合わせるかのいずれかで行われます。正確なパディング戦略はモデルによって異なります。

pad_size (`Annotated[int | list[int] | tuple[int, ...] | dict[str, int] | None, None]`, *kwargs*) : 画像をパディングするサイズを`{"height": int, "width" int}`で指定します。前処理に提供されたすべての画像サイズより大きい必要があります。`pad_size`が指定されない場合、バッチ内の最大の幅と高さにパディングされます。`do_pad=True.`の場合にのみ適用されます。

do_center_crop (`bool`, *kwargs*, *optional*) : 画像を中央クロップするかどうか。

data_format (`Union[str, ~image_utils.ChannelDimension]`、*kwargs*、*optional*) : 対応するのは `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`: (height, width, num_channels) 形式の画像。 - `"none"` または `ChannelDimension.NONE`: (height, width) 形式の画像。

device (`Annotated[Union[str, torch.device, NoneType], None]`, *kwargs*) : 動画を処理するデバイスです。未設定の場合、入力動画からデバイスが推論されます。

return_tensors (`Annotated[str | ~utils.generic.TensorType | None, None]`, *kwargs*) : `'pt'`に設定されている場合はスタックされたテンソルを返し、それ以外の場合はテンソルのリストを返します。

disable_grouping (`bool`, *kwargs*, *optional*) : 画像をサイズごとにグループ化してバッチ処理するのではなく、個別に処理するためにグループ化を無効にするかどうかを指定します。None の場合、画像が CPU にある場合は True、それ以外の場合は False に設定されます。この選択は、https://github.com/huggingface/transformers/pull/38157 に詳しく記載されている実証的な観察に基づいています。

image_seq_length (`int`, *kwargs*, *optional*) : 入力内の各画像に使用される画像トークンの数です。後方互換性のために追加されましたが、将来のモデルではプロセッサの属性として設定されるべきです。`'pt'`に設定されている場合はスタックされたテンソルを返し、それ以外の場合はテンソルのリストを返します。

disable_grouping (`bool`, *kwargs*, *optional*) : 画像をサイズごとにグループ化してバッチ処理するのではなく、個別に処理するためにグループ化を無効にするかどうかを指定します。None の場合、画像が CPU にある場合は True、それ以外の場合は False に設定されます。この選択は、https://github.com/huggingface/transformers/pull/38157 に詳しく記載されている実証的な観察に基づいています。

image_seq_length (`int`, *kwargs*, *optional*) : 入力内の各画像に使用される画像トークンの数です。後方互換性のために追加されましたが、将来のモデルではプロセッサの属性として設定されるべきです。`'pt'`に設定されている場合はスタックされたテンソルを返し、それ以外の場合はテンソルのリストを返します。

disable_grouping (`bool`, *kwargs*, *optional*) : 画像をサイズごとにグループ化してバッチ処理するのではなく、個別に処理するためにグループ化を無効にするかどうかを指定します。None の場合、画像が CPU にある場合は True、それ以外の場合は False に設定されます。この選択は、https://github.com/huggingface/transformers/pull/38157 に詳しく記載されている実証的な観察に基づいています。

image_seq_length (`int`, *kwargs*, *optional*) : 入力内の各画像に使用される画像トークンの数です。後方互換性のために追加されましたが、将来のモデルではプロセッサの属性として設定されるべきです。`'pt'`に設定されている場合はスタックされたテンソルを返し、それ以外の場合はテンソルのリストを返します。

disable_grouping (`bool`, *kwargs*, *optional*) : 画像をサイズごとにグループ化してバッチ処理するのではなく、個別に処理するためにグループ化を無効にするかどうかを指定します。None の場合、画像が CPU にある場合は True、それ以外の場合は False に設定されます。この選択は、https://github.com/huggingface/transformers/pull/38157 に詳しく記載されている実証的な観察に基づいています。

image_seq_length (`int`, *kwargs*, *optional*) : 入力内の各画像に使用される画像トークンの数です。後方互換性のために追加されましたが、将来のモデルではプロセッサの属性として設定されるべきです。`'pt'`に設定されている場合はスタックされたテンソルを返し、それ以外の場合はテンソルのリストを返します。

disable_grouping (`bool`, *kwargs*, *optional*) : 画像をサイズごとにグループ化してバッチ処理するのではなく、個別に処理するためにグループ化を無効にするかどうかを指定します。None の場合、画像が CPU にある場合は True、それ以外の場合は False に設定されます。この選択は、https://github.com/huggingface/transformers/pull/38157 に詳しく記載されている実証的な観察に基づいています。

image_seq_length (`int`, *kwargs*, *optional*) : 入力内の各画像に使用される画像トークンの数です。後方互換性のために追加されましたが、将来のモデルではプロセッサの属性として設定されるべきです。`'pt'`に設定されている場合はスタックされたテンソルを返し、それ以外の場合はテンソルのリストを返します。

disable_grouping (`bool`, *kwargs*, *optional*) : 画像をサイズごとにグループ化してバッチ処理するのではなく、個別に処理するためにグループ化を無効にするかどうかを指定します。None の場合、画像が CPU にある場合は True、それ以外の場合は False に設定されます。この選択は、https://github.com/huggingface/transformers/pull/38157 に詳しく記載されている実証的な観察に基づいています。

image_seq_length (`int`, *kwargs*, *optional*) : 入力内の各画像に使用される画像トークンの数です。後方互換性のために追加されましたが、将来のモデルではプロセッサの属性として設定されるべきです。`'pt'`に設定されている場合はスタックされたテンソルを返し、それ以外の場合はテンソルのリストを返します。

disable_grouping (`bool`, *kwargs*, *optional*) : 画像をサイズごとにグループ化してバッチ処理するのではなく、個別に処理するためにグループ化を無効にするかどうかを指定します。None の場合、画像が CPU にある場合は True、それ以外の場合は False に設定されます。この選択は、https://github.com/huggingface/transformers/pull/38157 に詳しく記載されている実証的な観察に基づいています。

image_seq_length (`int`, *kwargs*, *optional*) : 入力内の各画像に使用される画像トークンの数です。後方互換性のために追加されましたが、将来のモデルではプロセッサの属性として設定されるべきです。`'pt'`に設定されている場合はスタックされたテンソルを返し、それ以外の場合はテンソルのリストを返します。

disable_grouping (`bool`, *kwargs*, *optional*) : 画像をサイズごとにグループ化してバッチ処理するのではなく、個別に処理するためにグループ化を無効にするかどうかを指定します。None の場合、画像が CPU にある場合は True、それ以外の場合は False に設定されます。この選択は、https://github.com/huggingface/transformers/pull/38157 に詳しく記載されている実証的な観察に基づいています。

image_seq_length (`int`, *kwargs*, *optional*) : 入力内の各画像に使用される画像トークンの数です。後方互換性のために追加されましたが、将来のモデルではプロセッサの属性として設定されるべきです。`'pt'`に設定されている場合はスタックされたテンソルを返し、それ以外の場合はテンソルのリストを返します。

disable_grouping (`bool`, *kwargs*, *optional*) : 画像をサイズごとにグループ化してバッチ処理するのではなく、個別に処理するためにグループ化を無効にするかどうかを指定します。None の場合、画像が CPU にある場合は True、それ以外の場合は False に設定されます。この選択は、https://github.com/huggingface/transformers/pull/38157 に詳しく記載されている実証的な観察に基づいています。

image_seq_length (`int`, *kwargs*, *optional*) : 入力内の各画像に使用される画像トークンの数です。後方互換性のために追加されましたが、将来のモデルではプロセッサの属性として設定されるべきです。`'pt'`に設定されている場合はスタックされたテンソルを返し、それ以外の場合はテンソルのリストを返します。

disable_grouping (`bool`, *kwargs*, *optional*) : 画像をサイズごとにグループ化してバッチ処理するのではなく、個別に処理するためにグループ化を無効にするかどうかを指定します。None の場合、画像が CPU にある場合は True、それ以外の場合は False に設定されます。この選択は、https://github.com/huggingface/transformers/pull/38157 に詳しく記載されている実証的な観察に基づいています。

image_seq_length (`int`, *kwargs*, *optional*) : 入力内の各画像に使用される画像トークンの数です。後方互換性のために追加されましたが、将来のモデルではプロセッサの属性として設定されるべきです。`'pt'`に設定されている場合はスタックされたテンソルを返し、それ以外の場合はテンソルのリストを返します。

disable_grouping (`bool`, *kwargs*, *optional*) : 画像をサイズごとにグループ化してバッチ処理するのではなく、個別に処理するためにグループ化を無効にするかどうかを指定します。None の場合、画像が CPU にある場合は True、それ以外の場合は False に設定されます。この選択は、https://github.com/huggingface/transformers/pull/38157 に詳しく記載されている実証的な観察に基づいています。

image_seq_length (`int`, *kwargs*, *optional*) : 入力内の各画像に使用される画像トークンの数です。後方互換性のために追加されましたが、将来のモデルではプロセッサの属性として設定されるべきです。`'pt'`に設定されている場合はスタックされたテンソルを返し、それ以外の場合はテンソルのリストを返します。

disable_grouping (`bool`, *kwargs*, *optional*) : 画像をサイズごとにグループ化してバッチ処理するのではなく、個別に処理するためにグループ化を無効にするかどうかを指定します。None の場合、画像が CPU にある場合は True、それ以外の場合は False に設定されます。この選択は、https://github.com/huggingface/transformers/pull/38157 に詳しく記載されている実証的な観察に基づいています。

image_seq_length (`int`, *kwargs*, *optional*) : 入力内の各画像に使用される画像トークンの数です。後方互換性のために追加されましたが、将来のモデルではプロセッサの属性として設定されるべきです。`'pt'`に設定されている場合はスタックされたテンソルを返し、それ以外の場合はテンソルのリストを返します。

disable_grouping (`bool`, *kwargs*, *optional*) : 画像をサイズごとにグループ化してバッチ処理するのではなく、個別に処理するためにグループ化を無効にするかどうかを指定します。None の場合、画像が CPU にある場合は True、それ以外の場合は False に設定されます。この選択は、https://github.com/huggingface/transformers/pull/38157 に詳しく記載されている実証的な観察に基づいています。

image_seq_length (`int`, *kwargs*, *optional*) : 入力内の各画像に使用される画像トークンの数です。後方互換性のために追加されましたが、将来のモデルではプロセッサの属性として設定されるべきです。`'pt'`に設定されている場合はスタックされたテンソルを返し、それ以外の場合はテンソルのリストを返します。

disable_grouping (`bool`, *kwargs*, *optional*) : 画像をサイズごとにグループ化してバッチ処理するのではなく、個別に処理するためにグループ化を無効にするかどうかを指定します。None の場合、画像が CPU にある場合は True、それ以外の場合は False に設定されます。この選択は、https://github.com/huggingface/transformers/pull/38157 に詳しく記載されている実証的な観察に基づいています。

image_seq_length (`int`, *kwargs*, *optional*) : 入力内の各画像に使用される画像トークンの数です。後方互換性のために追加されましたが、将来のモデルではプロセッサの属性として設定されるべきです。`'pt'`に設定されている場合はスタックされたテンソルを返し、それ以外の場合はテンソルのリストを返します。

disable_grouping (`bool`, *kwargs*, *optional*) : 画像をサイズごとにグループ化してバッチ処理するのではなく、個別に処理するためにグループ化を無効にするかどうかを指定します。None の場合、画像が CPU にある場合は True、それ以外の場合は False に設定されます。この選択は、https://github.com/huggingface/transformers/pull/38157 に詳しく記載されている実証的な観察に基づいています。

image_seq_length (`int`, *kwargs*, *optional*) : 入力内の各画像に使用される画像トークンの数です。後方互換性のために追加されましたが、将来のモデルではプロセッサの属性として設定されるべきです。`'pt'`に設定されている場合はスタックされたテンソルを返し、それ以外の場合はテンソルのリストを返します。

disable_grouping (`bool`, *kwargs*, *optional*) : 画像をサイズごとにグループ化してバッチ処理するのではなく、個別に処理するためにグループ化を無効にするかどうかを指定します。None の場合、画像が CPU にある場合は True、それ以外の場合は False に設定されます。この選択は、https://github.com/huggingface/transformers/pull/38157 に詳しく記載されている実証的な観察に基づいています。

image_seq_length (`int`, *kwargs*, *optional*) : 入力内の各画像に使用される画像トークンの数です。後方互換性のために追加されましたが、将来のモデルではプロセッサの属性として設定されるべきです。`'pt'`に設定されている場合はスタックされたテンソルを返し、それ以外の場合はテンソルのリストを返します。

disable_grouping (`bool`, *kwargs*, *optional*) : 画像をサイズごとにグループ化してバッチ処理するのではなく、個別に処理するためにグループ化を無効にするかどうかを指定します。None の場合、画像が CPU にある場合は True、それ以外の場合は False に設定されます。この選択は、https://github.com/huggingface/transformers/pull/38157 に詳しく記載されている実証的な観察に基づいています。

image_seq_length (`int`, *kwargs*, *optional*) : 入力内の各画像に使用される画像トークンの数です。後方互換性のために追加されましたが、将来のモデルではプロセッサの属性として設定されるべきです。`'pt'`に設定されている場合はスタックされたテンソルを返し、それ以外の場合はテンソルのリストを返します。

disable_grouping (`bool`, *kwargs*, *optional*) : 画像をサイズごとにグループ化してバッチ処理するのではなく、個別に処理するためにグループ化を無効にするかどうかを指定します。None の場合、画像が CPU にある場合は True、それ以外の場合は False に設定されます。この選択は、https://github.com/huggingface/transformers/pull/38157 に詳しく記載されている実証的な観察に基づいています。

image_seq_length (`int`, *kwargs*, *optional*) : 入力内の各画像に使用される画像トークンの数です。後方互換性のために追加されましたが、将来のモデルではプロセッサの属性として設定されるべきです。`'pt'`に設定されている場合はスタックされたテンソルを返し、それ以外の場合はテンソルのリストを返します。

disable_grouping (`bool`, *kwargs*, *optional*) : 画像をサイズごとにグループ化してバッチ処理するのではなく、個別に処理するためにグループ化を無効にするかどうかを指定します。None の場合、画像が CPU にある場合は True、それ以外の場合は False に設定されます。この選択は、https://github.com/huggingface/transformers/pull/38157 に詳しく記載されている実証的な観察に基づいています。

image_seq_length (`int`, *kwargs*, *任意*) : 入力内の各画像に使用される画像トークンの数です。後方互換性のために追加されましたが、将来のモデルではプロセッサの属性として設定されるべきです。

`'pt'`に設定されている場合はスタックされたテンソルを返し、それ以外の場合はテンソルのリストを返します。 --

Tipsv2DptImageProcessor の画像プロセッサを構築します。

disable_grouping (`bool`, *kwargs*, *任意*): 画像をサイズごとにグループ化してバッチ処理する機能を無効にし、個別に処理するかどうかを指定します。None の場合、画像が CPU にある場合は True、それ以外の場合は False に設定されます。この選択は、ここ https://github.com/huggingface/transformers/pull/38157 に詳しく記載されている実証的な観察に基づいています。 image_seq_length (`int`, *kwargs*, *任意*): 入力内の各画像に使用される画像トークンの数です。後方互換性のために追加されましたが、将来のモデルではプロセッサの属性として設定されるべきです。

#### preprocess[[transformers.Tipsv2DptImageProcessor.preprocess]]

```python
preprocess(images: typing.Union[ForwardRef('PIL.Image.Image'), numpy.ndarray, ForwardRef('torch.Tensor'), list['PIL.Image.Image'], list[numpy.ndarray], list['torch.Tensor']], *args, image_like_kwargs: dict[str, typing.Any] | None = None, **kwargs: *<class 'transformers.processing_utils.ImagesKwargs'>)
```

[ソース](https://github.com/huggingface/transformers/blob/main/src/transformers/image_processing_utils.py#L382)

**パラメータ:**

images (`Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor]]`) : 前処理対象の画像。ピクセル値が 0 から 255 の範囲にある単一の画像またはバッチの画像を想定しています。ピクセル値が 0 から 1 の範囲にある画像を渡す場合は、`do_rescale=False` を設定してください。

image_like_kwargs (`dict[str, Any]`、*省略可*) : 追加の画像類似の入力も前処理対象にするための開発者向けフラグです。引数として kwarg を渡す方法が機能しない場合のみ使用してください。例えば、`preprocess(images, masks=masks)` が推奨される方法ですが、一部のモデルでは引数の優先順位の問題が発生します。そのような場合は、代わりに `preprocess(images, image_like_inputs={"masks": masks})` を使用できます。

do_convert_rgb (`bool`, *kwargs*, *optional*) : 画像を RGB に変換するかどうか。

do_resize (`bool`, *kwargs*, *optional*) : 画像をリサイズするかどうか。

size (`Annotated[int | list[int] | tuple[int, ...] | dict[str, int] | None, None]`, *kwargs*) : モデルへの最大入力次元を記述します。

default_to_square (`bool`, *kwargs*, *optional*) : size が int の場合、リサイズ時に正方形の画像をデフォルトとするかどうか。

crop_size (`Annotated[int | list[int] | tuple[int, ...] | dict[str, int] | None, None]`, *kwargs*) : `center_crop` を適用した後の出力画像のサイズ。

resample (`Annotated[Union[int, PILImageResampling, NoneType], None]`, *kwargs*) : 画像をリサイズする場合に使用するリサンプリングフィルタ。`PILImageResampling` の列挙型のいずれかです。`do_resize` が `True` に設定されている場合のみ有効です。

do_rescale (`bool`, *kwargs*, *任意*) : 画像をリスケールするかどうか。

rescale_factor (`float`, *kwargs*, *optional*) : `do_rescale` が `True` に設定されている場合、画像をリサイズするためのリスケール係数。

do_normalize (`bool`, *kwargs*, *optional*) : 画像を正規化するかどうかを指定します。

image_mean (`Union[float, list[float], tuple[float, ...]]`, *kwargs*, *optional*) : 正規化に使用する画像の平均値。`do_normalize` が `True` に設定されている場合のみ有効です。

image_std (`Union[float, list[float], tuple[float, ...]]`, *kwargs*, *optional*) : 正規化に使用する画像の標準偏差。`do_normalize` が `True` に設定されている場合のみ有効です。

do_pad (`bool`, *kwargs*, *任意*) : 画像にパディングを適用するかどうか。パディングは、バッチ内の最大サイズに合わせるか、画像ごとに固定の正方形サイズに合わせるかのいずれかで行われます。正確なパディング戦略はモデルによって異なります。

pad_size (`Annotated[int | list[int] | tuple[int, ...] | dict[str, int] | None, None]`, *kwargs*) : 画像をパディングするサイズを`{"height": int, "width" int}`で指定します。前処理に提供されたすべての画像サイズより大きい必要があります。`pad_size`が指定されない場合、バッチ内の最大の幅と高さにパディングされます。`do_pad=True.`の場合にのみ適用されます。

do_center_crop (`bool`, *kwargs*, *optional*) : 画像を中央クロップするかどうか。

data_format (`Union[str, ~image_utils.ChannelDimension]`、*kwargs*、*optional*) : 対応するのは `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`: (height, width, num_channels) 形式の画像。 - `"none"` または `ChannelDimension.NONE`: (height, width) 形式の画像。

device (`Annotated[Union[str, torch.device, NoneType], None]`, *kwargs*) : 動画を処理するデバイスです。未設定の場合、入力動画からデバイスが推論されます。

return_tensors (`Annotated[str | ~utils.generic.TensorType | None, None]`, *kwargs*) : `'pt'`に設定されている場合はスタックされたテンソルを返し、それ以外の場合はテンソルのリストを返します。

disable_grouping (`bool`, *kwargs*, *optional*) : 画像をサイズごとにグループ化してバッチ処理するのではなく、個別に処理するためにグループ化を無効にするかどうかを指定します。None の場合、画像が CPU にある場合は True、それ以外の場合は False に設定されます。この選択は、https://github.com/huggingface/transformers/pull/38157 に詳しく記載されている実証的な観察に基づいています。

image_seq_length (`int`, *kwargs*, *任意*) : 入力内の各画像に使用される画像トークンの数です。後方互換性のために追加されましたが、将来のモデルではプロセッサの属性として設定されるべきです。

**戻り値:** `~image_processing_base.BatchFeature`

- **data** (`dict`) -- __call__ メソッドによって返されるリスト/配列/テンソルの辞書（'pixel_values' など）。
- **tensor_type** (`Union[None, str, TensorType]`、*省略可*) -- 初期化時に PyTorch/Numpy の Tensor 内の整数リストを変換するために、ここで tensor_type を指定できます。

画像または画像のバッチを前処理します。

#### post_process_depth_estimation[[transformers.Tipsv2DptImageProcessor.post_process_depth_estimation]]

```python
post_process_depth_estimation(outputs, target_sizes: transformers.utils.generic.TensorType | list[tuple[int, int]] | None = None)
```

[ソース](https://github.com/huggingface/transformers/blob/main/src/transformers/models/tipsv2_dpt/image_processing_tipsv2_dpt.py#L40)

**パラメータ:**

outputs (`DepthEstimatorOutput` または `Tipsv2DptDensePredictorOutput`) : モデルの生出力。

target_sizes ([TensorType](/docs/transformers/main/ja/internal/file_utils#transformers.TensorType) または `list[tuple[int, int]]`、*optional*) : 形状が `(batch_size, 2)` のテンソル、またはバッチ内の各画像のターゲットサイズ（高さ、幅）を含むタプルのリスト（`tuple[int, int]`）。None の場合、予測結果はリサイズされません。

**戻り値:** `list[dict[str, torch.Tensor]]`

処理された深度予測を表すテンソルの辞書のリストです。

[Tipsv2DptForDepthEstimation](/docs/transformers/main/ja/model_doc/tipsv2_dpt#transformers.Tipsv2DptForDepthEstimation) または [Tipsv2DptForDensePrediction](/docs/transformers/main/ja/model_doc/tipsv2_dpt#transformers.Tipsv2DptForDensePrediction) の出力を、最終的な深度予測に変換します。

#### post_process_normal_estimation[[transformers.Tipsv2DptImageProcessor.post_process_normal_estimation]]

```python
post_process_normal_estimation(outputs, target_sizes: transformers.utils.generic.TensorType | list[tuple[int, int]] | None = None)
```

[ソース](https://github.com/huggingface/transformers/blob/main/src/transformers/models/tipsv2_dpt/image_processing_tipsv2_dpt.py#L76)

**パラメータ:**

outputs (`Tipsv2DptNormalEstimatorOutput` または `Tipsv2DptDensePredictorOutput`) : モデルの生出力。

target_sizes ([TensorType](/docs/transformers/main/ja/internal/file_utils#transformers.TensorType) または `list[tuple[int, int]]`、*optional*) : 形状が `(batch_size, 2)` のテンソル、またはバッチ内の各画像のターゲットサイズ（高さ、幅）を含むタプルのリスト（`tuple[int, int]`）。None の場合、予測結果はリサイズされません。

**戻り値:**

`list[dict[str, torch.Tensor]]` の長さ `batch_size` のリスト。各 dict は `"normals"` キーを持ち、これは `(3, height, width)` の形状のテンソルにマッピングされ、各チャネル（XYZ 表面法線）について `[-1, 1]` の範囲で L2 正規化された単位ベクトルを保持します。

[Tipsv2DptForNormalEstimation](/docs/transformers/main/ja/model_doc/tipsv2_dpt#transformers.Tipsv2DptForNormalEstimation) または [Tipsv2DptForDensePrediction](/docs/transformers/main/ja/model_doc/tipsv2_dpt#transformers.Tipsv2DptForDensePrediction) の出力を、L2正規化された法線マップに変換します。

#### post_process_semantic_segmentation[[transformers.Tipsv2DptImageProcessor.post_process_semantic_segmentation]]

```python
post_process_semantic_segmentation(outputs, target_sizes: transformers.utils.generic.TensorType | list[tuple[int, int]] | None = None, return_segmentation_scores: bool = False)
```

[ソース](https://github.com/huggingface/transformers/blob/main/src/transformers/models/tipsv2_dpt/image_processing_tipsv2_dpt.py#L113)

**パラメータ:**

outputs (`SemanticSegmenterOutput` または `Tipsv2DptDensePredictorOutput`) : モデルの生出力。

target_sizes [([TensorType](/docs/transformers/main/ja/internal/file_utils#transformers.TensorType) or `list[tuple[int, int]]`, *optional*) : バッチ内の各画像のターゲットサイズ（高さ、幅）を含む、形状が`(batch_size, 2)`のTensor、または`tuple[int, int]`のタプルのリスト。Noneに設定した場合、予測結果はリサイズされません。

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

[Tipsv2DptForSemanticSegmentation](/docs/transformers/main/ja/model_doc/tipsv2_dpt#transformers.Tipsv2DptForSemanticSegmentation) または [Tipsv2DptForDensePrediction](/docs/transformers/main/ja/model_doc/tipsv2_dpt#transformers.Tipsv2DptForDensePrediction) の出力をセマンティックセグメンテーションマップに変換します。

## Tipsv2DptForDensePrediction[[transformers.Tipsv2DptForDensePrediction]]

#### transformers.Tipsv2DptForDensePrediction[[transformers.Tipsv2DptForDensePrediction]]

```python
transformers.Tipsv2DptForDensePrediction(config: Tipsv2DptConfig)
```

[ソース](https://github.com/huggingface/transformers/blob/main/src/transformers/models/tipsv2_dpt/modeling_tipsv2_dpt.py#L390)

**パラメータ:**

config ([Tipsv2DptConfig](/docs/transformers/main/ja/model_doc/tipsv2_dpt#transformers.Tipsv2DptConfig)) : モデルのパラメータをすべて含むモデル設定クラスです。設定ファイルで初期化しても、モデルに関連する重みは読み込まれず、設定のみが読み込まれます。モデルの重みをロードするには、[from_pretrained()](/docs/transformers/main/ja/main_classes/model#transformers.PreTrainedModel.from_pretrained) メソッドを確認してください。

深度推定、表面法線推定、セマンティックセグメンテーションの3つの独立したヘッドを備えたTIPSv2-DPTモデル — 単一の共有バックボーンによるフォワードパスを実行します。

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

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

#### forward[[transformers.Tipsv2DptForDensePrediction.forward]]

```python
forward(pixel_values: FloatTensor, **kwargs: Unpack)
```

[ソース](https://github.com/huggingface/transformers/blob/main/src/transformers/models/tipsv2_dpt/modeling_tipsv2_dpt.py#L408)

**パラメータ:**

pixel_values (`torch.FloatTensor`、shape `(batch_size, num_channels, image_size, image_size)`) : 入力画像に対応するテンソルです。ピクセル値は[Tipsv2DptImageProcessor](/docs/transformers/main/ja/model_doc/tipsv2_dpt#transformers.Tipsv2DptImageProcessor)を使用して取得できます。詳細は[Tipsv2DptImageProcessor.__call__()](/docs/transformers/main/ja/model_doc/molmo2#transformers.Molmo2ImageProcessor.__call__)を参照してください（`processor_class`は画像の処理に[Tipsv2DptImageProcessor](/docs/transformers/main/ja/model_doc/tipsv2_dpt#transformers.Tipsv2DptImageProcessor)を使用します）。

**戻り値:** `Tipsv2DptDensePredictorOutput` または `tuple(torch.FloatTensor)`

`Tipsv2DptDensePredictorOutput`、または`torch.FloatTensor`のタプル（`return_dict=False`が渡された場合、または`config.return_dict=False`の場合）。設定（[Tipsv2DptConfig](/docs/transformers/main/ja/model_doc/tipsv2_dpt#transformers.Tipsv2DptConfig)）や入力に応じて、さまざまな要素で構成されます。

[Tipsv2DptForDensePrediction](/docs/transformers/main/ja/model_doc/tipsv2_dpt#transformers.Tipsv2DptForDensePrediction)のforwardメソッドは、`__call__`特殊メソッドをオーバーライドします。

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

- **predicted_depth** (`torch.FloatTensor`、形状 `(batch_size, height, width)`、*任意*) -- 各ピクセルの予測深度。
- **normals** (`torch.FloatTensor`、形状 `(batch_size, 3, height, width)`) -- 正規化されていない生ノーマルマップの予測値。
- **segmentation_logits** (`torch.FloatTensor`、形状 `(batch_size, config.num_labels, height, width)`) -- 各ピクセルの分類スコア。
  
  返される logits は、入力として渡された `pixel_values` と同じサイズであるとは限りません。これは、ユーザーが後処理として logits を元の画像サイズにリサイズする際に、2回の補間処理による品質の低下を避けるためです。常に logits の形状を確認し、必要に応じてリサイズしてください。
  
- **hidden_states** (`tuple[torch.FloatTensor, ...]`、*optional*、`output_hidden_states=True` が渡された場合または `config.output_hidden_states=True` の場合に返されます) -- `torch.FloatTensor` のタプル（埋め込み層を持つモデルの場合、埋め込みの出力用が 1 つ、各層の出力用が 1 つずつ）で、形状は `(batch_size, sequence_length, hidden_size)` です。

  各層の出力におけるモデルのHidden-states、および任意の初期埋め込み出力。
- **attentions** (`tuple[torch.FloatTensor, ...]`、*optional*、`output_attentions=True` が渡された場合または `config.output_attentions=True` の場合に返されます) -- `torch.FloatTensor` のタプル（レイヤーごとに1つ）で、形状は `(batch_size, num_heads, sequence_length, sequence_length)` です。

  アテンションのsoftmax後のアテンション重み。自己アテンションヘッド内で加重平均を計算するために使用されます。

例:

```python
>>> import torch
>>> from transformers import Tipsv2DptForDensePrediction, AutoImageProcessor
>>> from transformers.image_utils import load_image

>>> model_id = "google/tipsv2-b14-dpt"
>>> model = Tipsv2DptForDensePrediction.from_pretrained(model_id, device_map="auto")
>>> image_processor = AutoImageProcessor.from_pretrained(model_id)

>>> image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/room.jpg")
>>> inputs = image_processor(images=image, return_tensors="pt").to(model.device)

>>> with torch.no_grad():
...     outputs = model(**inputs)

>>> # outputs.predicted_depth: (batch_size, height, width) tensor with predicted depth in meters
>>> # outputs.normals: (batch_size, 3, height, width) tensor with normals in XYZ format (unnormalized)
>>> # outputs.segmentation_logits: (batch_size, config.num_labels, height, width) tensor with segmentation logits
>>> depth_results = image_processor.post_process_depth_estimation(outputs, target_sizes=[(image.height, image.width)])
>>> normal_results = image_processor.post_process_normal_estimation(outputs, target_sizes=[(image.height, image.width)])
>>> segmentation_results = image_processor.post_process_semantic_segmentation(outputs, target_sizes=[(image.height, image.width)])

>>> predicted_depth = depth_results[0]["predicted_depth"]  # (height, width) tensor with predicted depth in meters
>>> normals = normal_results[0]["normals"]  # (3, height, width) tensor with normals in XYZ format (L2-normalized)
>>> segmentation = segmentation_results[0]  # (height, width) tensor with class ids
```

## Tipsv2DptForDepthEstimation[[transformers.Tipsv2DptForDepthEstimation]]

#### transformers.Tipsv2DptForDepthEstimation[[transformers.Tipsv2DptForDepthEstimation]]

```python
transformers.Tipsv2DptForDepthEstimation(config: Tipsv2DptConfig)
```

[ソース](https://github.com/huggingface/transformers/blob/main/src/transformers/models/tipsv2_dpt/modeling_tipsv2_dpt.py#L480)

**パラメータ:**

config ([Tipsv2DptConfig](/docs/transformers/main/ja/model_doc/tipsv2_dpt#transformers.Tipsv2DptConfig)) : モデルのパラメータをすべて含むモデル設定クラスです。設定ファイルで初期化しても、モデルに関連する重みは読み込まれず、設定のみが読み込まれます。モデルの重みをロードするには、[from_pretrained()](/docs/transformers/main/ja/main_classes/model#transformers.PreTrainedModel.from_pretrained) メソッドを確認してください。

単眼深度推定ヘッドを備えたTIPSv2-DPTモデル。

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

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

#### forward[[transformers.Tipsv2DptForDepthEstimation.forward]]

```python
forward(pixel_values: FloatTensor, labels: typing.Optional[torch.FloatTensor] = None, **kwargs: Unpack)
```

[ソース](https://github.com/huggingface/transformers/blob/main/src/transformers/models/tipsv2_dpt/modeling_tipsv2_dpt.py#L496)

**パラメータ:**

pixel_values (`torch.FloatTensor`、shape `(batch_size, num_channels, image_size, image_size)`) : 入力画像に対応するテンソルです。ピクセル値は[Tipsv2DptImageProcessor](/docs/transformers/main/ja/model_doc/tipsv2_dpt#transformers.Tipsv2DptImageProcessor)を使用して取得できます。詳細は[Tipsv2DptImageProcessor.__call__()](/docs/transformers/main/ja/model_doc/molmo2#transformers.Molmo2ImageProcessor.__call__)を参照してください（`processor_class`は画像の処理に[Tipsv2DptImageProcessor](/docs/transformers/main/ja/model_doc/tipsv2_dpt#transformers.Tipsv2DptImageProcessor)を使用します）。

labels (`torch.LongTensor`、形状 `(batch_size, height, width)`、*任意*) : ロスの計算に使用する正解の深度推定マップ。

**戻り値:** [DepthEstimatorOutput](/docs/transformers/main/ja/main_classes/output#transformers.modeling_outputs.DepthEstimatorOutput) または `tuple(torch.FloatTensor)`

設定（[Tipsv2DptConfig](/docs/transformers/main/ja/model_doc/tipsv2_dpt#transformers.Tipsv2DptConfig)）や入力に応じて、さまざまな要素で構成される、[DepthEstimatorOutput](/docs/transformers/main/ja/main_classes/output#transformers.modeling_outputs.DepthEstimatorOutput)または`torch.FloatTensor`のタプル（`return_dict=False`が渡された場合、または`config.return_dict=False`の場合）。

[Tipsv2DptForDepthEstimation](/docs/transformers/main/ja/model_doc/tipsv2_dpt#transformers.Tipsv2DptForDepthEstimation)のforwardメソッドは、`__call__`という特殊メソッドをオーバーライドします。

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

- **loss** (`torch.FloatTensor`、shape `(1,)`、*optional*、`labels` が指定された場合に返されます) -- 分類（または config.num_labels==1 の場合は回帰）の損失。
- **predicted_depth** (`torch.FloatTensor`、shape `(batch_size, height, width)`) -- 各ピクセルの予測深度。
- **hidden_states** (`tuple(torch.FloatTensor)`、*optional*、`output_hidden_states=True` が渡された場合または `config.output_hidden_states=True` の場合に返されます) -- `torch.FloatTensor` のタプル（モデルに埋め込み層がある場合はその出力用 + 各層の出力用）で、形状は `(batch_size, num_channels, height, width)` です。

  各層の出力におけるモデルのHidden-states、および任意の初期埋め込み出力。
- **attentions** (`tuple(torch.FloatTensor)`、*optional*、`output_attentions=True` が渡された場合または `config.output_attentions=True` の場合に返されます) -- `torch.FloatTensor` のタプル（各レイヤーごとに1つ）、形状は `(batch_size, num_heads, patch_size, sequence_length)`。

  アテンションのsoftmax後のアテンション重み。自己アテンションヘッド内で加重平均を計算するために使用されます。

例:

```python
>>> import torch
>>> from transformers import AutoModelForDepthEstimation, AutoImageProcessor
>>> from transformers.image_utils import load_image

>>> model_id = "google/tipsv2-b14-dpt"
>>> model = AutoModelForDepthEstimation.from_pretrained(model_id, device_map="auto")
>>> image_processor = AutoImageProcessor.from_pretrained(model_id)

>>> image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/room.jpg")
>>> inputs = image_processor(images=image, return_tensors="pt").to(model.device)

>>> with torch.no_grad():
...     outputs = model(**inputs)

>>> results = image_processor.post_process_depth_estimation(outputs, target_sizes=[(image.height, image.width)])
>>> predicted_depth = results[0]["predicted_depth"]  # (height, width) tensor with predicted depth in meters
```

## Tipsv2DptForNormalEstimation[[transformers.Tipsv2DptForNormalEstimation]]

#### transformers.Tipsv2DptForNormalEstimation[[transformers.Tipsv2DptForNormalEstimation]]

```python
transformers.Tipsv2DptForNormalEstimation(config: Tipsv2DptConfig)
```

[ソース](https://github.com/huggingface/transformers/blob/main/src/transformers/models/tipsv2_dpt/modeling_tipsv2_dpt.py#L556)

**パラメータ:**

config ([Tipsv2DptConfig](/docs/transformers/main/ja/model_doc/tipsv2_dpt#transformers.Tipsv2DptConfig)) : モデルのパラメータをすべて含むモデル設定クラスです。設定ファイルで初期化しても、モデルに関連する重みは読み込まれず、設定のみが読み込まれます。モデルの重みをロードするには、[from_pretrained()](/docs/transformers/main/ja/main_classes/model#transformers.PreTrainedModel.from_pretrained) メソッドを確認してください。

表面法線推定ヘッドを備えたTIPSv2-DPTモデル。

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

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

#### forward[[transformers.Tipsv2DptForNormalEstimation.forward]]

```python
forward(pixel_values: FloatTensor, labels: typing.Optional[torch.FloatTensor] = None, **kwargs: Unpack)
```

[ソース](https://github.com/huggingface/transformers/blob/main/src/transformers/models/tipsv2_dpt/modeling_tipsv2_dpt.py#L569)

**パラメータ:**

pixel_values (`torch.FloatTensor`、shape `(batch_size, num_channels, image_size, image_size)`) : 入力画像に対応するテンソルです。ピクセル値は[Tipsv2DptImageProcessor](/docs/transformers/main/ja/model_doc/tipsv2_dpt#transformers.Tipsv2DptImageProcessor)を使用して取得できます。詳細は[Tipsv2DptImageProcessor.__call__()](/docs/transformers/main/ja/model_doc/molmo2#transformers.Molmo2ImageProcessor.__call__)を参照してください（`processor_class`は画像の処理に[Tipsv2DptImageProcessor](/docs/transformers/main/ja/model_doc/tipsv2_dpt#transformers.Tipsv2DptImageProcessor)を使用します）。

labels (`torch.FloatTensor`、形状 `(batch_size, sequence_length)`、*任意*) : マスクド言語モデリング損失を計算するためのラベル。インデックスは `[0, ..., config.vocab_size]` の範囲内であるか、-100 である必要があります（`input_ids` のドキュメント文字列を参照）。インデックスが `-100` に設定されたトークンは無視（マスク）され、損失は `[0, ..., config.vocab_size]` の範囲内のラベルを持つトークンのみに対して計算されます。

**戻り値:** `Tipsv2DptNormalEstimatorOutput` または `tuple(torch.FloatTensor)`

`Tipsv2DptNormalEstimatorOutput`、または`torch.FloatTensor`のタプル（`return_dict=False`が渡された場合、または`config.return_dict=False`の場合）。設定（[Tipsv2DptConfig](/docs/transformers/main/ja/model_doc/tipsv2_dpt#transformers.Tipsv2DptConfig)）や入力に応じて、さまざまな要素で構成されます。

[Tipsv2DptForNormalEstimation](/docs/transformers/main/ja/model_doc/tipsv2_dpt#transformers.Tipsv2DptForNormalEstimation)のforwardメソッドは、`__call__`特殊メソッドをオーバーライドします。

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

- **loss** (`torch.FloatTensor`、shape `(1,)`、*optional*、`labels` が提供された場合に返されます) -- 正規推定損失。
- **normals** (`torch.FloatTensor`、形状 `(batch_size, num_labels, height, width)`) -- モデルが出力する生のノーマルマップの予測値（正規化されていません）。
- **hidden_states** (`tuple(torch.FloatTensor)`、*optional*、`output_hidden_states=True` が渡された場合または `config.output_hidden_states=True` の場合に返されます) -- `torch.FloatTensor` のタプル（埋め込みの出力用 1 つ + 各ステージの出力用 1 つ）で、形状は `(batch_size, sequence_length, hidden_size)` です。各レイヤーの出力におけるモデルの隠れ状態と、初期埋め込みの出力です。
- **attentions** (`tuple(torch.FloatTensor)`、*optional*、`output_attentions=True` が渡された場合または `config.output_attentions=True` の場合に返されます) -- `torch.FloatTensor` のタプル（レイヤーごとに1つ）、形状は `(batch_size, num_heads, sequence_length, sequence_length)`。アテンションの softmax 後のアテンション重み。

例:

```python
>>> import torch
>>> from transformers import Tipsv2DptForNormalEstimation, AutoImageProcessor
>>> from transformers.image_utils import load_image

>>> model_id = "google/tipsv2-b14-dpt"
>>> model = Tipsv2DptForNormalEstimation.from_pretrained(model_id, device_map="auto")
>>> image_processor = AutoImageProcessor.from_pretrained(model_id)

>>> image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/room.jpg")
>>> inputs = image_processor(images=image, return_tensors="pt").to(model.device)

>>> with torch.no_grad():
...     outputs = model(**inputs)

>>> results = image_processor.post_process_normal_estimation(outputs, target_sizes=[(image.height, image.width)])
>>> normals = results[0]["normals"]  # (3, height, width) tensor with normals in XYZ format (L2-normalized)
```

## Tipsv2DptForSemanticSegmentation[[transformers.Tipsv2DptForSemanticSegmentation]]

#### transformers.Tipsv2DptForSemanticSegmentation[[transformers.Tipsv2DptForSemanticSegmentation]]

```python
transformers.Tipsv2DptForSemanticSegmentation(config: Tipsv2DptConfig)
```

[ソース](https://github.com/huggingface/transformers/blob/main/src/transformers/models/tipsv2_dpt/modeling_tipsv2_dpt.py#L628)

**パラメータ:**

config ([Tipsv2DptConfig](/docs/transformers/main/ja/model_doc/tipsv2_dpt#transformers.Tipsv2DptConfig)) : モデルのパラメータをすべて含むモデル設定クラスです。設定ファイルで初期化しても、モデルに関連する重みは読み込まれず、設定のみが読み込まれます。モデルの重みをロードするには、[from_pretrained()](/docs/transformers/main/ja/main_classes/model#transformers.PreTrainedModel.from_pretrained) メソッドを確認してください。

セマンティックセグメンテーションヘッドを備えたTIPSv2-DPTモデル。

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

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

#### forward[[transformers.Tipsv2DptForSemanticSegmentation.forward]]

```python
forward(pixel_values: FloatTensor, labels: typing.Optional[torch.LongTensor] = None, **kwargs: Unpack)
```

[ソース](https://github.com/huggingface/transformers/blob/main/src/transformers/models/tipsv2_dpt/modeling_tipsv2_dpt.py#L641)

**パラメータ:**

pixel_values (`torch.FloatTensor`、shape `(batch_size, num_channels, image_size, image_size)`) : 入力画像に対応するテンソルです。ピクセル値は[Tipsv2DptImageProcessor](/docs/transformers/main/ja/model_doc/tipsv2_dpt#transformers.Tipsv2DptImageProcessor)を使用して取得できます。詳細は[Tipsv2DptImageProcessor.__call__()](/docs/transformers/main/ja/model_doc/molmo2#transformers.Molmo2ImageProcessor.__call__)を参照してください（`processor_class`は画像の処理に[Tipsv2DptImageProcessor](/docs/transformers/main/ja/model_doc/tipsv2_dpt#transformers.Tipsv2DptImageProcessor)を使用します）。

labels (`torch.LongTensor`、shape `(batch_size, height, width)`、*任意*) : ロスの計算に使用する正解のセマンティックセグメンテーションマップ。インデックスは `[0, ..., config.num_labels - 1]` の範囲である必要があります。`config.num_labels > 1` の場合、分類ロス（Cross-Entropy）が計算されます。

**戻り値:** [SemanticSegmenterOutput](/docs/transformers/main/ja/main_classes/output#transformers.modeling_outputs.SemanticSegmenterOutput) または `tuple(torch.FloatTensor)`

設定（[Tipsv2DptConfig](/docs/transformers/main/ja/model_doc/tipsv2_dpt#transformers.Tipsv2DptConfig)）や入力に応じて、さまざまな要素で構成される、[SemanticSegmenterOutput](/docs/transformers/main/ja/main_classes/output#transformers.modeling_outputs.SemanticSegmenterOutput)または`torch.FloatTensor`のタプル（`return_dict=False`が渡された場合、または`config.return_dict=False`の場合）。

[Tipsv2DptForSemanticSegmentation](/docs/transformers/main/ja/model_doc/tipsv2_dpt#transformers.Tipsv2DptForSemanticSegmentation)のforwardメソッドは、`__call__`特殊メソッドをオーバーライドします。

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

- **loss** (`torch.FloatTensor`、shape `(1,)`、*optional*、`labels` が指定された場合に返されます) -- 分類（または config.num_labels==1 の場合は回帰）の損失。
- **logits** (`torch.FloatTensor`、shape `(batch_size, config.num_labels, logits_height, logits_width)`) -- 各ピクセルの分類スコア。

  

  返される logits は、入力として渡された `pixel_values` と同じサイズであるとは限りません。これは、ユーザーが後処理として logits を元の画像サイズにリサイズする際に、2回の補間処理による品質の低下を避けるためです。常に logits の形状を確認し、必要に応じてリサイズしてください。

  
- **hidden_states** (`tuple(torch.FloatTensor)`、*optional*、`output_hidden_states=True` が渡された場合または `config.output_hidden_states=True` の場合に返されます) -- `torch.FloatTensor` のタプル（埋め込み層を持つモデルの場合、埋め込みの出力用が 1 つ、各層の出力用が 1 つずつ）で、形状は `(batch_size, patch_size, hidden_size)` です。

  各層の出力におけるモデルのHidden-states、および任意の初期埋め込み出力。
- **attentions** (`tuple(torch.FloatTensor)`、*optional*、`output_attentions=True` が渡された場合または `config.output_attentions=True` の場合に返されます) -- `torch.FloatTensor` のタプル（各レイヤーごとに1つ）、形状は `(batch_size, num_heads, patch_size, sequence_length)`。

  アテンションのsoftmax後のアテンション重み。自己アテンションヘッド内で加重平均を計算するために使用されます。

例:

```python
>>> import torch
>>> from transformers import AutoModelForSemanticSegmentation, AutoImageProcessor
>>> from transformers.image_utils import load_image

>>> model_id = "google/tipsv2-b14-dpt"
>>> model = AutoModelForSemanticSegmentation.from_pretrained(model_id, device_map="auto")
>>> image_processor = AutoImageProcessor.from_pretrained(model_id)

>>> image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/room.jpg")
>>> inputs = image_processor(images=image, return_tensors="pt").to(model.device)

>>> with torch.no_grad():
...     outputs = model(**inputs)

>>> results = image_processor.post_process_semantic_segmentation(outputs, target_sizes=[(image.height, image.width)])
>>> segmentation_map = results[0]  # (height, width) tensor with class ids
```

