# DPT

## 개요

DPT 모델은 René Ranftl, Alexey Bochkovskiy, Vladlen Koltun이 [Vision Transformers for Dense Prediction](https://huggingface.co/papers/2103.13413)에서 제안했습니다. DPT는 의미론적 분할과 깊이 추정과 같은 밀집 예측(dense prediction) 작업을 위해 [Vision Transformer (ViT)](vit)를 백본으로 활용하는 모델입니다.

해당 논문의 초록은 다음과 같습니다:

*저희는 dense vision transformer를 소개합니다. 이 아키텍처는 dense prediction 작업의 backbone으로 convolutional network 대신 vision transformer를 활용합니다. vision transformer의 다양한 단계에서 생성된 token을 다양한 해상도의 image-like representation으로 조립한 후, convolutional decoder를 사용하여 점진적으로 full-resolution prediction으로 결합합니다. transformer backbone은 일정하고 상대적으로 높은 해상도로 representation을 처리하며, 모든 단계에서 global receptive field를 가집니다. 이러한 특성 덕분에 dense vision transformer는 fully-convolutional network와 비교할 때 더 세밀하고 전역적으로 일관된 prediction을 제공합니다. 실험 결과, 이 아키텍처는 dense prediction 작업에서 상당한 성능 향상을 보여주며, 특히 대량의 학습 데이터가 사용 가능한 경우 그 효과가 두드러집니다. monocular depth estimation의 경우, state-of-the-art fully-convolutional network와 비교했을 때 상대 성능이 최대 28%까지 향상되는 것을 확인했습니다. semantic segmentation에 적용할 경우, dense vision transformer는 ADE20K에서 49.02% mIoU로 새로운 state of the art를 달성했습니다. 또한, NYUv2, KITTI, Pascal Context와 같은 더 작은 데이터셋에서 fine-tuning할 수 있으며, 이러한 데이터셋에서도 새로운 state of the art를 달성함을 추가로 보여줍니다.*

<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/dpt_architecture.jpg"
alt="drawing" width="600"/>

 DPT 아키텍처. 원 논문에서 가져왔습니다.

이 모델은 [nielsr](https://huggingface.co/nielsr)에 의해 기여되었습니다. 원본 코드는 [여기](https://github.com/isl-org/DPT)에서 찾을 수 있습니다.

## 사용 팁

DPT는 [AutoBackbone](/docs/transformers/v5.23.0/ko/main_classes/backbones#transformers.AutoBackbone) 클래스와 호환됩니다. 이를 통해 라이브러리에서 사용할 수 있는 다양한 컴퓨터 비전 백본, 예: `VitDetBackbone` 또는 `Dinov2Backbone`과 함께 DPT 프레임워크를 사용할 수 있습니다. 다음과 같이 생성할 수 있습니다:

```python
from transformers import Dinov2Config, DPTConfig, DPTForDepthEstimation

# initialize with a Transformer-based backbone such as DINOv2
# in that case, we also specify `reshape_hidden_states=False` to get feature maps of shape (batch_size, num_channels, height, width)
backbone_config = Dinov2Config.from_pretrained("facebook/dinov2-base", out_features=["stage1", "stage2", "stage3", "stage4"], reshape_hidden_states=False)

config = DPTConfig(backbone_config=backbone_config)
model = DPTForDepthEstimation(config=config)
```

## 리소스

DPT를 시작하는 데 도움이 되는 공식 Hugging Face 및 커뮤니티(🌎로 표시) 리소스 목록입니다.

- [DPTForDepthEstimation](/docs/transformers/v5.23.0/ko/model_doc/dpt#transformers.DPTForDepthEstimation) 데모 노트북은 [여기](https://github.com/NielsRogge/Transformers-Tutorials/tree/master/DPT)에서 확인할 수 있습니다.

- [시맨틱 세분화 작업 가이드](../tasks/semantic_segmentation)
- [단안 깊이 추정 작업 가이드](../tasks/monocular_depth_estimation)

여기에 포함할 리소스를 제출하고 싶으시면 Pull Request를 열어 주시면 검토하겠습니다! 기존 리소스와 중복되지 않고 새로운 것을 보여주는 것이 이상적입니다.

## DPTConfig[[transformers.DPTConfig]]

#### transformers.DPTConfig[[transformers.DPTConfig]]

```python
transformers.DPTConfig(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, hidden_size: int = 768, num_hidden_layers: None | int = 12, num_attention_heads: int | None = 12, intermediate_size: int | None = 3072, hidden_act: str = 'gelu', hidden_dropout_prob: float | int | None = 0.0, attention_probs_dropout_prob: float | int | None = 0.0, initializer_range: float = 0.02, layer_norm_eps: float | None = 1e-12, image_size: int | list[int] | tuple[int, int] | None = 384, patch_size: int | list[int] | tuple[int, int] | None = 16, num_channels: int | None = 3, is_hybrid: bool = False, qkv_bias: bool | None = True, backbone_out_indices: list[int] | tuple[int, ...] | None = (2, 5, 8, 11), readout_type: typing.Literal['ignore', 'add', 'project'] = 'project', reassemble_factors: list[int | float] | tuple[int | float, ...] = (4, 2, 1, 0.5), neck_hidden_sizes: list[int] | tuple[int, ...] = (96, 192, 384, 768), fusion_hidden_size: int = 256, head_in_index: int = -1, use_batch_norm_in_fusion_residual: bool | None = False, use_bias_in_fusion_residual: bool | None = None, add_projection: bool = False, use_auxiliary_head: bool | None = True, auxiliary_loss_weight: float = 0.4, semantic_loss_ignore_index: int = 255, semantic_classifier_dropout: float | int = 0.1, backbone_featmap_shape: list[int] | tuple[int, ...] | None = (1, 1024, 24, 24), neck_ignore_stages: list[int] | tuple[int, ...] = (0, 1), backbone_config: dict | transformers.configuration_utils.PreTrainedConfig | None = None, pooler_output_size: int | None = None, pooler_act: str = 'tanh')
```

[소스](https://github.com/huggingface/transformers/blob/v5.23.0/src/transformers/models/dpt/configuration_dpt.py#L27)

**매개변수:**

hidden_size (`int`, *선택 사항*, 기본값 `768`) : 숨겨진 표현의 차원.

num_hidden_layers (`int`, *선택 사항*, 기본값 `12`) : Transformer decoder의 숨겨진 레이어 수입니다.

num_attention_heads (`int`, *선택 사항*, 기본값 `12`) : Transformer decoder의 각 attention layer에 사용되는 attention head의 수입니다.

intermediate_size (`int`, *선택 사항*, 기본값 `3072`) : MLP 표현의 차원.

hidden_act (`str`, *선택 사항*, 기본값 `gelu`) : 디코더에서 사용되는 비선형 활성화 함수(함수 또는 문자열). 예를 들어, `"gelu"`, `"relu"`, `"silu"` 등이 있습니다.

hidden_dropout_prob (`Union[float, int]`, *선택 사항*, 기본값 `0.0`) : 임베딩, 인코더, 풀러의 모든 완전 연결 계층에 적용되는 dropout 확률입니다.

attention_probs_dropout_prob (`Union[float, int]`, *선택 사항*, 기본값 `0.0`) : attention 확률에 적용할 dropout 비율입니다.

initializer_range (`float`, *선택 사항*, 기본값 `0.02`) : 모든 가중치 행렬을 초기화하는 truncated_normal_initializer의 표준 편차입니다.

layer_norm_eps (`float`, *선택 사항*, 기본값 `1e-12`) : layer normalization 레이어에서 사용되는 epsilon 값입니다.

image_size (`Union[int, list[int], tuple[int, int]]`, *선택 사항*, 기본값 `384`) : 각 이미지의 크기(해상도).

patch_size (`Union[int, list[int], tuple[int, int]]`, *선택*, 기본값 `16`) : 각 패치의 크기(해상도).

num_channels (`int`, *선택 사항*, 기본값 `3`) : 입력 채널의 수입니다.

is_hybrid (`bool`, *선택 사항*, 기본값 `False`) : 하이브리드 백본을 사용할지 여부입니다. DPT-Hybrid 모델을 로드하는 맥락에서 유용합니다.

qkv_bias (`bool`, *선택 사항*, 기본값 `True`) : 쿼리, 키, 값에 bias를 추가할지 여부.

backbone_out_indices (`list[int]`, *선택 사항*, 기본값 `[2, 5, 8, 11]`) : backbone에서 사용할 중간 hidden state의 인덱스입니다.

readout_type (`str`, *선택 사항*, 기본값 `"project"`) : ViT 백본의 중간 숨겨진 상태에서 readout 토큰(CLS 토큰)을 처리할 때 사용할 readout 유형입니다. [`"ignore"`, `"add"`, `"project"`] 중 하나여야 합니다. - "ignore"는 CLS 토큰을 단순히 무시합니다. - "add"는 표현을 추가하여 CLS 토큰의 정보를 다른 모든 토큰으로 전달합니다. - "project"는 선형 레이어와 GELU 비선형성을 적용하여 표현을 원래의 특징 차원 D로 투사하기 전에 readout을 다른 모든 토큰에 연결(concatenate)하여 다른 토큰으로 정보를 전달합니다.

reassemble_factors (`list[int]`, *선택 사항*, 기본값 `[4, 2, 1, 0.5]`) : reassemble 레이어의 업/다운샘플링 계수입니다.

neck_hidden_sizes (`list[str]`, *선택 사항*, 기본값 `[96, 192, 384, 768]`) : 백본의 feature maps를 투영할 hidden sizes입니다.

fusion_hidden_size (`int`, *선택 사항*, 기본값 256) : 융합 전 채널 수.

head_in_index (`int`, *선택 사항*, 기본값 -1) : 헤드에서 사용할 기능의 인덱스입니다.

use_batch_norm_in_fusion_residual (`bool`, *선택 사항*, 기본값 `False`) : fusion 블록의 pre-activate residual units에서 batch normalization을 사용할지 여부입니다.

use_bias_in_fusion_residual (`bool`, *선택 사항*, 기본값 `True`) : fusion 블록의 pre-activate residual unit에 bias를 사용할지 여부입니다.

add_projection (`bool`, *선택 사항*, 기본값 `False`) : 깊이 추정 헤드 앞에 투영 레이어를 추가할지 여부.

use_auxiliary_head (`bool`, *선택 사항*, 기본값 `True`) : 학습 중에 보조 헤드를 사용할지 여부.

auxiliary_loss_weight (`float`, *선택 사항*, 기본값 0.4) : 보조 헤드의 교차 엔트로피 손실 가중치.

semantic_loss_ignore_index (`int`, *선택 사항*, 기본값 `255`) : 시맨틱 세그멘테이션 모델의 손실 함수가 무시하는 인덱스입니다.

semantic_classifier_dropout (`float`, *선택 사항*, 기본값 0.1) : 의미 분류 헤드에 적용되는 dropout 비율입니다.

backbone_featmap_shape (`list[int]`, *선택 사항*, 기본값 `[1, 1024, 24, 24]`) : `hybrid` 임베딩 유형에서만 사용됩니다. 백본의 피처 맵 형상입니다.

neck_ignore_stages (`list[int]`, *선택 사항*, 기본값 `[0, 1]`) : `hybrid` 임베딩 유형에서만 사용됩니다. 무시할 readout 레이어의 단계입니다.

backbone_config (`Union[dict, ~configuration_utils.PreTrainedConfig]`, *선택*) : 백본 모델의 구성입니다.

pooler_output_size (`int`, *선택 사항*) : 풀러 레이어의 차원입니다. None인 경우 기본값은 `hidden_size`입니다.

pooler_act (`str`, *선택 사항*, 기본값 `"tanh"`) : pooler에서 사용할 활성화 함수입니다.

이것은 DPTModel의 구성을 저장하기 위한 구성 클래스입니다. 지정된 인자에 따라 Dpt 모델을 초기화하여 모델 아키텍처를 정의하는 데 사용됩니다. 기본값으로 구성을 초기화하면 [Intel/dpt-large](https://huggingface.co/Intel/dpt-large)와 유사한 구성이 생성됩니다.

Configuration 객체는 [PreTrainedConfig](/docs/transformers/v5.23.0/ko/main_classes/configuration#transformers.PreTrainedConfig)를 상속하며, 모델 출력을 제어하는 데 사용할 수 있습니다. 자세한 내용은 [PreTrainedConfig](/docs/transformers/v5.23.0/ko/main_classes/configuration#transformers.PreTrainedConfig)의 문서를 참고하세요.

예:

```python
>>> from transformers import DPTModel, DPTConfig

>>> # Initializing a DPT dpt-large style configuration
>>> configuration = DPTConfig()

>>> # Initializing a model from the dpt-large style configuration
>>> model = DPTModel(configuration)

>>> # Accessing the model configuration
>>> configuration = model.config
```

## DPTImageProcessor[[transformers.DPTImageProcessor]]

#### transformers.DPTImageProcessor[[transformers.DPTImageProcessor]]

```python
transformers.DPTImageProcessor(**kwargs: *<class 'transformers.models.dpt.image_processing_dpt.DPTImageProcessorKwargs'>)
```

[소스](https://github.com/huggingface/transformers/blob/v5.23.0/src/transformers/models/dpt/image_processing_dpt.py#L110)

**매개변수:**

do_convert_rgb (`bool`, *kwargs*, *선택*) : 이미지를 RGB로 변환할지 여부.

do_resize (`bool`, *kwargs*, *선택 사항*, 기본값 `True`) : 이미지를 리사이즈할지 여부.

size (`Annotated[int | list[int] | tuple[int, ...] | dict[str, int] | None, None]`, *kwargs*, 기본값 `{'height' : 384, 'width': 384}`): 모델에 대한 최대 입력 차원을 설명합니다.

default_to_square (`bool`, *kwargs*, *선택 사항*, 기본값 `True`) : size가 int인 경우 리사이즈 시 정사각형 이미지로 설정할지 여부.

crop_size (`Annotated[int | list[int] | tuple[int, ...] | dict[str, int] | None, None]`, *kwargs*, 기본값 `None`) : `center_crop`를 적용한 후의 출력 이미지 크기입니다.

resample (`Annotated[Union[int, PILImageResampling, NoneType], None]`, *kwargs*, 기본값 `3`) : 이미지를 리사이즈할 때 사용할 리샘플링 필터입니다. `PILImageResampling` enum 중 하나를 사용할 수 있습니다. `do_resize`가 `True`로 설정된 경우에만 효과가 있습니다.

do_rescale (`bool`, *kwargs*, *선택 사항*, 기본값 `True`) : 이미지를 다시 스케일링할지 여부.

rescale_factor (`float`, *kwargs*, *선택 사항*, 기본값 `0.00392156862745098`) : `do_rescale`이 `True`로 설정된 경우 이미지를 재조정하는 데 사용되는 재조정 계수입니다.

do_normalize (`bool`, *kwargs*, *선택 사항*, 기본값 `True`) : 이미지를 정규화할지 여부.

image_mean (`Union[float, list[float], tuple[float, ...]]`, *kwargs*, *선택*, 기본값은 `[0.5, 0.5, 0.5]`) : 정규화에 사용할 이미지 평균입니다. `do_normalize`가 `True`로 설정된 경우에만 효과가 있습니다.

image_std (`Union[float, list[float], tuple[float, ...]]`, *kwargs*, *선택*, 기본값 `[0.5, 0.5, 0.5]`) : 정규화에 사용할 이미지 표준 편차. `do_normalize`가 `True`로 설정된 경우에만 효과가 있습니다.

do_pad (`bool`, *kwargs*, *선택 사항*, 기본값 `False`) : 이미지를 패딩할지 여부입니다. 패딩은 배치 내 가장 큰 크기로 수행하거나 이미지마다 고정된 정사각형 크기로 수행합니다. 정확한 패딩 전략은 모델에 따라 달라집니다.

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*, *선택 사항*, 기본값 `None`) : 이미지를 중앙 크롭할지 여부.

data_format (`Union[str, ~image_utils.ChannelDimension]`, *kwargs*, *선택*) : `ChannelDimension.FIRST`만 지원됩니다. 느린 프로세서와의 호환성을 위해 추가되었습니다.

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*, *선택*) : 이미지의 크기에 따른 그룹화를 비활성화하여 이미지를 배치 대신 개별적으로 처리할지 여부입니다. None인 경우, 이미지가 CPU에 있으면 True, 그렇지 않으면 False로 설정됩니다. 이 선택은 https://github.com/huggingface/transformers/pull/38157에 자세히 설명된 경험적 관찰에 기반합니다.

image_seq_length (`int`, *kwargs*, *선택*) : 입력의 각 이미지에 사용할 이미지 토큰의 수입니다. 하위 호환성을 위해 추가되었지만, 향후 모델에서는 프로세서 속성으로 설정해야 합니다.

ensure_multiple_of (`int`, *kwargs*, *선택 사항*, 기본값 1) : `do_resize`가 `True`인 경우, 이미지는 이 값의 배수가 되는 크기로 리사이즈됩니다. `preprocess`의 `ensure_multiple_of`로 재정의할 수 있습니다.

size_divisor (`int`, *kwargs*) : 높이와 너비가 모두 나뉘도록 보장하는 크기입니다.

keep_aspect_ratio (`bool`, *kwargs*, *선택 사항*, 기본값 `False`) : `True`인 경우, 종횡비가 유지되도록 이미지가 가능한 최대 크기로 리사이즈됩니다. `preprocess`의 `keep_aspect_ratio`로 재정의할 수 있습니다.

do_reduce_labels (`bool`, *kwargs*, *선택 사항*, 기본값은 `self.do_reduce_labels`) : 세그멘테이션 맵의 모든 라벨 값을 1만큼 줄일지 여부입니다. 일반적으로 0을 배경으로 사용하고 배경 자체가 데이터셋의 모든 클래스에 포함되지 않는 데이터셋(예: ADE20k)에서 사용됩니다. 배경 라벨은 255로 대체됩니다.

DPTImageProcessor 이미지 프로세서를 생성합니다.

#### preprocess[[transformers.DPTImageProcessor.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']], segmentation_maps: typing.Union[ForwardRef('PIL.Image.Image'), numpy.ndarray, ForwardRef('torch.Tensor'), list['PIL.Image.Image'], list[numpy.ndarray], list['torch.Tensor'], NoneType] = None, **kwargs: *<class 'transformers.models.dpt.image_processing_dpt.DPTImageProcessorKwargs'>)
```

[소스](https://github.com/huggingface/transformers/blob/v5.23.0/src/transformers/models/dpt/image_processing_dpt.py#L135)

**매개변수:**

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`로 설정하세요.

segmentation_maps (`ImageInput`, *선택 사항*) : 전처리할 분할 맵.

do_convert_rgb (`bool`, *kwargs*, *선택*) : 이미지를 RGB로 변환할지 여부.

do_resize (`bool`, *kwargs*, *선택*) : 이미지를 리사이즈할지 여부.

size (`Annotated[int | list[int] | tuple[int, ...] | dict[str, int] | None, None]`, *kwargs*) : 모델의 최대 입력 차원을 설명합니다.

default_to_square (`bool`, *kwargs*, *선택*) : 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` enum 중 하나를 사용할 수 있습니다. `do_resize`가 `True`로 설정된 경우에만 효과가 있습니다.

do_rescale (`bool`, *kwargs*, *선택*) : 이미지를 다시 스케일링할지 여부.

rescale_factor (`float`, *kwargs*, *선택*) : `do_rescale`가 `True`로 설정된 경우 이미지를 재조정하는 데 사용되는 재조정 계수입니다.

do_normalize (`bool`, *kwargs*, *선택*) : 이미지를 정규화할지 여부.

image_mean (`Union[float, list[float], tuple[float, ...]]`, *kwargs*, *선택*) : 정규화에 사용할 이미지 평균값. `do_normalize`이 `True`로 설정된 경우에만 효과가 있습니다.

image_std (`Union[float, list[float], tuple[float, ...]]`, *kwargs*, *선택*) : 정규화에 사용할 이미지 표준 편차. `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*, *선택*) : 이미지를 중앙 크롭할지 여부.

data_format (`Union[str, ~image_utils.ChannelDimension]`, *kwargs*, *선택*) : `ChannelDimension.FIRST`만 지원됩니다. 느린 프로세서와의 호환성을 위해 추가되었습니다.

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*, *선택*) : 이미지의 크기에 따른 그룹화를 비활성화하여 이미지를 배치 대신 개별적으로 처리할지 여부입니다. None인 경우, 이미지가 CPU에 있으면 True, 그렇지 않으면 False로 설정됩니다. 이 선택은 https://github.com/huggingface/transformers/pull/38157에 자세히 설명된 경험적 관찰에 기반합니다.

image_seq_length (`int`, *kwargs*, *선택*) : 입력의 각 이미지에 사용할 이미지 토큰의 수입니다. 하위 호환성을 위해 추가되었지만, 향후 모델에서는 프로세서 속성으로 설정해야 합니다.

ensure_multiple_of (`int`, *kwargs*, *선택 사항*, 기본값 1) : `do_resize`가 `True`인 경우, 이미지는 이 값의 배수가 되는 크기로 리사이즈됩니다. `preprocess`의 `ensure_multiple_of`로 재정의할 수 있습니다.

size_divisor (`int`, *kwargs*) : 높이와 너비가 모두 나뉘도록 보장하는 크기입니다.

keep_aspect_ratio (`bool`, *kwargs*, *선택 사항*, 기본값 `False`) : `True`인 경우, 종횡비가 유지되도록 이미지가 가능한 최대 크기로 리사이즈됩니다. `preprocess`의 `keep_aspect_ratio`로 재정의할 수 있습니다.

do_reduce_labels (`bool`, *kwargs*, *선택 사항*, 기본값은 `self.do_reduce_labels`) : 세그멘테이션 맵의 모든 라벨 값을 1만큼 줄일지 여부입니다. 일반적으로 0을 배경으로 사용하고 배경 자체가 데이터셋의 모든 클래스에 포함되지 않는 데이터셋(예: ADE20k)에서 사용됩니다. 배경 라벨은 255로 대체됩니다.

**반환값:** `~image_processing_base.BatchFeature`

- **data** (`dict`) -- __call__ 메서드가 반환하는 리스트/배열/텐서 딕셔너리('pixel_values' 등).
- **tensor_type** (`Union[None, str, TensorType]`, *선택 사항*) -- 초기화 시 PyTorch/Numpy 텐서에서 정수 목록을 변환하려면 여기에 tensor_type을 지정할 수 있습니다.

## DPTImageProcessorPil[[transformers.DPTImageProcessorPil]]

#### transformers.DPTImageProcessorPil[[transformers.DPTImageProcessorPil]]

```python
transformers.DPTImageProcessorPil(**kwargs: *<class 'transformers.models.dpt.image_processing_pil_dpt.DPTImageProcessorKwargs'>)
```

[소스](https://github.com/huggingface/transformers/blob/v5.23.0/src/transformers/models/dpt/image_processing_pil_dpt.py#L110)

**매개변수:**

do_convert_rgb (`bool`, *kwargs*, *선택*) : 이미지를 RGB로 변환할지 여부.

do_resize (`bool`, *kwargs*, *선택 사항*, 기본값 `True`) : 이미지를 리사이즈할지 여부.

size (`Annotated[int | list[int] | tuple[int, ...] | dict[str, int] | None, None]`, *kwargs*, 기본값 `{'height' : 384, 'width': 384}`): 모델에 대한 최대 입력 차원을 설명합니다.

default_to_square (`bool`, *kwargs*, *선택 사항*, 기본값 `True`) : 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*, 기본값 `3`) : 이미지를 리사이즈할 때 사용할 리샘플링 필터입니다. `PILImageResampling` enum 중 하나를 사용할 수 있습니다. `do_resize`가 `True`로 설정된 경우에만 효과가 있습니다.

do_rescale (`bool`, *kwargs*, *선택 사항*, 기본값 `True`) : 이미지를 다시 스케일링할지 여부.

rescale_factor (`float`, *kwargs*, *선택 사항*, 기본값 `0.00392156862745098`) : `do_rescale`이 `True`로 설정된 경우 이미지를 재조정하는 데 사용되는 재조정 계수입니다.

do_normalize (`bool`, *kwargs*, *선택 사항*, 기본값 `True`) : 이미지를 정규화할지 여부.

image_mean (`Union[float, list[float], tuple[float, ...]]`, *kwargs*, *선택*, 기본값은 `[0.5, 0.5, 0.5]`) : 정규화에 사용할 이미지 평균입니다. `do_normalize`가 `True`로 설정된 경우에만 효과가 있습니다.

image_std (`Union[float, list[float], tuple[float, ...]]`, *kwargs*, *선택*, 기본값 `[0.5, 0.5, 0.5]`) : 정규화에 사용할 이미지 표준 편차. `do_normalize`가 `True`로 설정된 경우에만 효과가 있습니다.

do_pad (`bool`, *kwargs*, *선택 사항*, 기본값 `False`) : 이미지를 패딩할지 여부입니다. 패딩은 배치 내 가장 큰 크기로 수행하거나 이미지마다 고정된 정사각형 크기로 수행합니다. 정확한 패딩 전략은 모델에 따라 달라집니다.

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*, *선택*) : 이미지를 중앙 크롭할지 여부.

data_format (`Union[str, ~image_utils.ChannelDimension]`, *kwargs*, *선택*) : `ChannelDimension.FIRST`만 지원됩니다. 느린 프로세서와의 호환성을 위해 추가되었습니다.

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*, *선택*) : 이미지의 크기에 따른 그룹화를 비활성화하여 이미지를 배치 대신 개별적으로 처리할지 여부입니다. None인 경우, 이미지가 CPU에 있으면 True, 그렇지 않으면 False로 설정됩니다. 이 선택은 https://github.com/huggingface/transformers/pull/38157에 자세히 설명된 경험적 관찰에 기반합니다.

image_seq_length (`int`, *kwargs*, *선택*) : 입력의 각 이미지에 사용할 이미지 토큰의 수입니다. 하위 호환성을 위해 추가되었지만, 향후 모델에서는 프로세서 속성으로 설정해야 합니다.

ensure_multiple_of (`int`, *kwargs*, *선택 사항*, 기본값 1) : `do_resize`가 `True`인 경우, 이미지는 이 값의 배수가 되는 크기로 리사이즈됩니다. `preprocess`의 `ensure_multiple_of`로 재정의할 수 있습니다.

size_divisor (`int`, *kwargs*) : 높이와 너비가 모두 나뉘도록 보장하는 크기입니다.

keep_aspect_ratio (`bool`, *kwargs*, *선택 사항*, 기본값 `False`) : `True`인 경우, 종횡비가 유지되도록 이미지가 가능한 최대 크기로 리사이즈됩니다. `preprocess`의 `keep_aspect_ratio`로 재정의할 수 있습니다.

do_reduce_labels (`bool`, *kwargs*, *선택 사항*, 기본값은 `self.do_reduce_labels`) : 세그멘테이션 맵의 모든 라벨 값을 1만큼 줄일지 여부입니다. 일반적으로 0을 배경으로 사용하고 배경 자체가 데이터셋의 모든 클래스에 포함되지 않는 데이터셋(예: ADE20k)에서 사용됩니다. 배경 라벨은 255로 대체됩니다.

DPTImageProcessor 이미지 프로세서를 생성합니다.

#### preprocess[[transformers.DPTImageProcessorPil.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']], segmentation_maps: typing.Union[ForwardRef('PIL.Image.Image'), numpy.ndarray, ForwardRef('torch.Tensor'), list['PIL.Image.Image'], list[numpy.ndarray], list['torch.Tensor'], NoneType] = None, **kwargs: *<class 'transformers.models.dpt.image_processing_pil_dpt.DPTImageProcessorKwargs'>)
```

[소스](https://github.com/huggingface/transformers/blob/v5.23.0/src/transformers/models/dpt/image_processing_pil_dpt.py#L131)

**매개변수:**

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`로 설정하세요.

segmentation_maps (`ImageInput`, *선택 사항*) : 전처리할 분할 맵.

do_convert_rgb (`bool`, *kwargs*, *선택*) : 이미지를 RGB로 변환할지 여부.

do_resize (`bool`, *kwargs*, *선택*) : 이미지를 리사이즈할지 여부.

size (`Annotated[int | list[int] | tuple[int, ...] | dict[str, int] | None, None]`, *kwargs*) : 모델의 최대 입력 차원을 설명합니다.

default_to_square (`bool`, *kwargs*, *선택*) : 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` enum 중 하나를 사용할 수 있습니다. `do_resize`가 `True`로 설정된 경우에만 효과가 있습니다.

do_rescale (`bool`, *kwargs*, *선택*) : 이미지를 다시 스케일링할지 여부.

rescale_factor (`float`, *kwargs*, *선택*) : `do_rescale`가 `True`로 설정된 경우 이미지를 재조정하는 데 사용되는 재조정 계수입니다.

do_normalize (`bool`, *kwargs*, *선택*) : 이미지를 정규화할지 여부.

image_mean (`Union[float, list[float], tuple[float, ...]]`, *kwargs*, *선택*) : 정규화에 사용할 이미지 평균값. `do_normalize`이 `True`로 설정된 경우에만 효과가 있습니다.

image_std (`Union[float, list[float], tuple[float, ...]]`, *kwargs*, *선택*) : 정규화에 사용할 이미지 표준 편차. `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*, *선택*) : 이미지를 중앙 크롭할지 여부.

data_format (`Union[str, ~image_utils.ChannelDimension]`, *kwargs*, *선택*) : `ChannelDimension.FIRST`만 지원됩니다. 느린 프로세서와의 호환성을 위해 추가되었습니다.

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*, *선택*) : 이미지의 크기에 따른 그룹화를 비활성화하여 이미지를 배치 대신 개별적으로 처리할지 여부입니다. None인 경우, 이미지가 CPU에 있으면 True, 그렇지 않으면 False로 설정됩니다. 이 선택은 https://github.com/huggingface/transformers/pull/38157에 자세히 설명된 경험적 관찰에 기반합니다.

image_seq_length (`int`, *kwargs*, *선택*) : 입력의 각 이미지에 사용할 이미지 토큰의 수입니다. 하위 호환성을 위해 추가되었지만, 향후 모델에서는 프로세서 속성으로 설정해야 합니다.

ensure_multiple_of (`int`, *kwargs*, *선택 사항*, 기본값 1) : `do_resize`가 `True`인 경우, 이미지는 이 값의 배수가 되는 크기로 리사이즈됩니다. `preprocess`의 `ensure_multiple_of`로 재정의할 수 있습니다.

size_divisor (`int`, *kwargs*) : 높이와 너비가 모두 나뉘도록 보장하는 크기입니다.

keep_aspect_ratio (`bool`, *kwargs*, *선택 사항*, 기본값 `False`) : `True`인 경우, 종횡비가 유지되도록 이미지가 가능한 최대 크기로 리사이즈됩니다. `preprocess`의 `keep_aspect_ratio`로 재정의할 수 있습니다.

do_reduce_labels (`bool`, *kwargs*, *선택 사항*, 기본값은 `self.do_reduce_labels`) : 세그멘테이션 맵의 모든 라벨 값을 1만큼 줄일지 여부입니다. 일반적으로 0을 배경으로 사용하고 배경 자체가 데이터셋의 모든 클래스에 포함되지 않는 데이터셋(예: ADE20k)에서 사용됩니다. 배경 라벨은 255로 대체됩니다.

**반환값:** `~image_processing_base.BatchFeature`

- **data** (`dict`) -- __call__ 메서드가 반환하는 리스트/배열/텐서 딕셔너리('pixel_values' 등).
- **tensor_type** (`Union[None, str, TensorType]`, *선택 사항*) -- 초기화 시 PyTorch/Numpy 텐서에서 정수 목록을 변환하려면 여기에 tensor_type을 지정할 수 있습니다.

#### post_process_semantic_segmentation[[transformers.DPTImageProcessorPil.post_process_semantic_segmentation]]

```python
post_process_semantic_segmentation(outputs, target_sizes: list[tuple] | None = None, return_segmentation_scores: bool = False)
```

[소스](https://github.com/huggingface/transformers/blob/v5.23.0/src/transformers/models/dpt/image_processing_pil_dpt.py#L268)

**매개변수:**

outputs ([DPTForSemanticSegmentation](/docs/transformers/v5.23.0/ko/model_doc/dpt#transformers.DPTForSemanticSegmentation)) : 모델의 원시 출력.

target_sizes (`list[tuple]`, *선택 사항*) : 배치 내 각 이미지의 대상 크기(높이, 너비)를 포함하는 튜플(`tuple[int, int]`) 목록입니다. 설정되지 않으면 예측 결과가 리사이즈되지 않습니다.

return_segmentation_scores (`bool`, *선택 사항*, 기본값 `False`) : 분할 맵과 함께 분할 점수를 반환할지 여부입니다. `True`인 경우, 반환된 리스트의 각 요소는 `segmentation` 필드(클래스 ID, shape `(height, width)`)와 `segmentation_scores` 필드(shape `(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)`는 대상 크기(`target_sizes`가 지정된 경우)에 해당합니다.

[DPTForSemanticSegmentation](/docs/transformers/v5.23.0/ko/model_doc/dpt#transformers.DPTForSemanticSegmentation)의 출력을 의미 분할 맵으로 변환합니다.

#### post_process_depth_estimation[[transformers.DPTImageProcessorPil.post_process_depth_estimation]]

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

[소스](https://github.com/huggingface/transformers/blob/v5.23.0/src/transformers/models/dpt/image_processing_pil_dpt.py#L331)

`DepthEstimatorOutput`의 원시 출력을 최종 깊이 예측으로 변환합니다.

## DPTModel[[transformers.DPTModel]]

#### transformers.DPTModel[[transformers.DPTModel]]

```python
transformers.DPTModel(config: DPTConfig, add_pooling_layer: bool = True)
```

[소스](https://github.com/huggingface/transformers/blob/v5.23.0/src/transformers/models/dpt/modeling_dpt.py#L752)

**매개변수:**

config ([DPTConfig](/docs/transformers/v5.23.0/ko/model_doc/dpt#transformers.DPTConfig)) : 모델의 모든 매개변수를 포함하는 모델 구성 클래스입니다. 구성 파일로 초기화하는 것은 모델과 관련된 가중치를 로드하지 않으며, 구성 정보만 로드합니다. 모델 가중치를 로드하려면 [from_pretrained()](/docs/transformers/v5.23.0/ko/main_classes/model#transformers.PreTrainedModel.from_pretrained) 메서드를 확인하세요.

add_pooling_layer (`bool`, *선택 사항*, 기본값 `True`) : 풀링 레이어를 추가할지 여부

특정 헤드가 위에 없는 순수한 Dpt Model로, 원시 hidden-states를 출력합니다.

이 모델은 [PreTrainedModel](/docs/transformers/v5.23.0/ko/main_classes/model#transformers.PreTrainedModel)에서 상속됩니다. 라이브러리가 모든 모델에 대해 구현하는 일반적 메서드(다운로드 또는 저장, 입력 임베딩 크기 조정, 헤드 프루닝 등)에 대해서는 상위 클래스 문서를 확인하세요.

이 모델은 또한 PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module)의 하위 클래스입니다. 일반적인 PyTorch Module처럼 사용하며, 일반적인 사용법과 동작에 관한 모든 사항은 PyTorch 문서를 참조하세요.

#### forward[[transformers.DPTModel.forward]]

```python
forward(pixel_values: Tensor, **kwargs: *<class 'transformers.utils.generic.TransformersKwargs'>)
```

[소스](https://github.com/huggingface/transformers/blob/v5.23.0/src/transformers/models/dpt/modeling_dpt.py#L780)

**매개변수:**

pixel_values (`torch.Tensor`, shape `(batch_size, num_channels, image_size, image_size)`) : 입력 이미지에 해당하는 텐서입니다. [DPTImageProcessor](/docs/transformers/v5.23.0/ko/model_doc/dpt#transformers.DPTImageProcessor)를 사용하여 픽셀 값을 얻을 수 있습니다. 자세한 내용은 [DPTImageProcessor.__call__()](/docs/transformers/v5.23.0/ko/model_doc/molmo2#transformers.Molmo2ImageProcessor.__call__)를 참조하세요 (`processor_class`는 이미지를 처리하는 데 [DPTImageProcessor](/docs/transformers/v5.23.0/ko/model_doc/dpt#transformers.DPTImageProcessor)를 사용합니다).

**반환값:** `BaseModelOutputWithPoolingAndIntermediateActivations` 또는 `tuple(torch.Tensor)`

`BaseModelOutputWithPoolingAndIntermediateActivations` 또는 `torch.Tensor`의 튜플(`return_dict=False`이 전달되었거나 `config.return_dict=False`인 경우)로, 구성([DPTConfig](/docs/transformers/v5.23.0/ko/model_doc/dpt#transformers.DPTConfig)) 및 입력에 따라 다양한 요소를 포함합니다.

[DPTModel](/docs/transformers/v5.23.0/ko/model_doc/dpt#transformers.DPTModel)의 forward 메서드는 `__call__` 특수 메서드를 오버라이드합니다.

`Module` 인스턴스는 전처리 및 후처리 단계를 실행하는 것을 처리하지만, 이 함수는 해당 단계를 조용히 무시하므로, 순전파(forward pass) 레시피를 이 함수 내에서 정의해야 하더라도 이후에는 이 함수 대신 `Module` 인스턴스를 호출해야 합니다.

- **last_hidden_state** (`torch.Tensor`, shape `(batch_size, sequence_length, hidden_size)`, *선택 사항*) -- 모델의 마지막 레이어 출력에서 생성된 hidden-state 시퀀스입니다.
- **pooler_output** (`torch.Tensor`, shape `(batch_size, hidden_size)`) -- 시퀀스의 첫 번째 토큰(분류 토큰)의 마지막 레이어 hidden-state입니다. 보조 사전학습 작업을 위해 사용되는 레이어들을 통해 추가 처리된 값입니다. 예를 들어 BERT 계열 모델의 경우, 선형 레이어와 tanh 활성화 함수를 통해 처리된 분류 토큰을 반환합니다. 선형 레이어의 가중치는 사전학습 단계에서 다음 문장 예측(분류) 목적 함수를 통해 학습됩니다.
- **hidden_states** (`tuple[torch.Tensor, ...]`, *선택*, `output_hidden_states=True`가 전달되거나 `config.output_hidden_states=True`인 경우 반환) -- shape가 `(batch_size, sequence_length, hidden_size)`인 `torch.Tensor`의 튜플 (모델에 임베딩 레이어가 있는 경우 임베딩 출력 1개 + 각 레이어의 출력 1개).

  각 레이어의 출력에서 모델의 Hidden-states와 선택적 초기 임베딩 출력을 포함합니다.
- **attentions** (`tuple[torch.Tensor, ...]`, *선택*, `output_attentions=True`가 전달되었거나 `config.output_attentions=True`인 경우 반환) -- 각 레이어마다 하나씩 포함된 `torch.Tensor` 튜플로, shape는 `(batch_size, num_heads, sequence_length, sequence_length)`입니다.

  self-attention 헤드에서 가중 평균을 계산하는 데 사용되는 attention softmax 이후의 attention 가중치입니다.
- **intermediate_activations** (`tuple(torch.Tensor)`, *선택 사항*) -- 모델의 다양한 레이어에서 hidden states를 계산하는 데 사용할 수 있는 중간 activations입니다.

예:

```python
```

## DPTForDepthEstimation[[transformers.DPTForDepthEstimation]]

#### transformers.DPTForDepthEstimation[[transformers.DPTForDepthEstimation]]

```python
transformers.DPTForDepthEstimation(config: DPTConfig)
```

[소스](https://github.com/huggingface/transformers/blob/v5.23.0/src/transformers/models/dpt/modeling_dpt.py#L923)

**매개변수:**

config ([DPTConfig](/docs/transformers/v5.23.0/ko/model_doc/dpt#transformers.DPTConfig)) : 모델의 모든 매개변수를 포함하는 모델 구성 클래스입니다. 구성 파일로 초기화하는 것은 모델과 관련된 가중치를 로드하지 않으며, 구성 정보만 로드합니다. 모델 가중치를 로드하려면 [from_pretrained()](/docs/transformers/v5.23.0/ko/main_classes/model#transformers.PreTrainedModel.from_pretrained) 메서드를 확인하세요.

KITTI, NYUv2 등에 사용되는, 상단에 깊이 추정 헤드(3개의 합성곱 계층으로 구성)가 있는 DPT 모델

이 모델은 [PreTrainedModel](/docs/transformers/v5.23.0/ko/main_classes/model#transformers.PreTrainedModel)에서 상속됩니다. 라이브러리가 모든 모델에 대해 구현하는 일반적 메서드(다운로드 또는 저장, 입력 임베딩 크기 조정, 헤드 프루닝 등)에 대해서는 상위 클래스 문서를 확인하세요.

이 모델은 또한 PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module)의 하위 클래스입니다. 일반적인 PyTorch Module처럼 사용하며, 일반적인 사용법과 동작에 관한 모든 사항은 PyTorch 문서를 참조하세요.

#### forward[[transformers.DPTForDepthEstimation.forward]]

```python
forward(pixel_values: Tensor, labels: typing.Optional[torch.LongTensor] = None, **kwargs: *<class 'transformers.utils.generic.TransformersKwargs'>)
```

[소스](https://github.com/huggingface/transformers/blob/v5.23.0/src/transformers/models/dpt/modeling_dpt.py#L942)

**매개변수:**

pixel_values (`torch.Tensor`, shape `(batch_size, num_channels, image_size, image_size)`) : 입력 이미지에 해당하는 텐서입니다. 픽셀 값은 `image_processor_class`를 사용하여 얻을 수 있습니다. 자세한 내용은 `image_processor_class.__call__`를 참조하세요 (`processor_class`는 이미지 처리에 `image_processor_class`를 사용합니다).

labels (`torch.LongTensor`, shape `(batch_size, height, width)`, *선택 사항*) : 손실을 계산하기 위한 ground truth depth estimation 맵.

**반환값:** [DepthEstimatorOutput](/docs/transformers/v5.23.0/ko/main_classes/output#transformers.modeling_outputs.DepthEstimatorOutput) 또는 `tuple(torch.Tensor)`

[DepthEstimatorOutput](/docs/transformers/v5.23.0/ko/main_classes/output#transformers.modeling_outputs.DepthEstimatorOutput) 또는 `torch.Tensor`의 튜플(`return_dict=False`이 전달되었거나 `config.return_dict=False`인 경우)로, 구성(`None`) 및 입력에 따라 다양한 요소를 포함합니다.

[DPTForDepthEstimation](/docs/transformers/v5.23.0/ko/model_doc/dpt#transformers.DPTForDepthEstimation)의 forward 메서드는 `__call__` 특수 메서드를 오버라이드합니다.

`Module` 인스턴스는 전처리 및 후처리 단계를 실행하는 것을 처리하지만, 이 함수는 해당 단계를 조용히 무시하므로, 순전파(forward pass) 레시피를 이 함수 내에서 정의해야 하더라도 이후에는 이 함수 대신 `Module` 인스턴스를 호출해야 합니다.

- **loss** (`torch.Tensor`, shape `(1,)`, *선택*, `labels`이 제공될 때 반환됨) -- 분류(또는 config.num_labels==1인 경우 회귀) 손실.
- **predicted_depth** (shape가 `(batch_size, height, width)`인 `torch.Tensor`) -- 각 픽셀에 대한 예측된 깊이.
- **hidden_states** (`tuple(torch.Tensor)`, *선택 사항*, `output_hidden_states=True`가 전달되었거나 `config.output_hidden_states=True`인 경우 반환됨) -- `torch.Tensor`의 튜플(모델에 임베딩 레이어가 있는 경우 임베딩 출력 1개 + 각 레이어의 출력 1개)로, 모양은 `(batch_size, num_channels, height, width)`입니다.

  각 레이어의 출력에서 모델의 Hidden-states와 선택적 초기 임베딩 출력을 포함합니다.
- **attentions** (`tuple(torch.Tensor)`, *선택 사항*, `output_attentions=True`가 전달되었거나 `config.output_attentions=True`인 경우 반환) -- 각 레이어당 하나씩, shape가 `(batch_size, num_heads, patch_size, sequence_length)`인 `torch.Tensor`의 튜플.

  self-attention 헤드에서 가중 평균을 계산하는 데 사용되는 attention softmax 이후의 attention 가중치입니다.

예:
```python
>>> from transformers import AutoImageProcessor, DPTForDepthEstimation
>>> import torch
>>> import numpy as np
>>> from PIL import Image
>>> from huggingface_hub.utils import httpx
>>> from io import BytesIO

>>> url = "http://images.cocodataset.org/val2017/000000039769.jpg"
>>> with httpx.stream("GET", url) as response:
...     image = Image.open(BytesIO(response.read()))

>>> image_processor = AutoImageProcessor.from_pretrained("Intel/dpt-large")
>>> model = DPTForDepthEstimation.from_pretrained("Intel/dpt-large")

>>> # prepare image for the model
>>> inputs = image_processor(images=image, return_tensors="pt")

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

>>> # interpolate to original size
>>> post_processed_output = image_processor.post_process_depth_estimation(
...     outputs,
...     target_sizes=[(image.height, image.width)],
... )

>>> # visualize the prediction
>>> predicted_depth = post_processed_output[0]["predicted_depth"]
>>> depth = predicted_depth * 255 / predicted_depth.max()
>>> depth = depth.detach().cpu().numpy()
>>> depth = Image.fromarray(depth.astype("uint8"))
```

## DPTForSemanticSegmentation[[transformers.DPTForSemanticSegmentation]]

#### transformers.DPTForSemanticSegmentation[[transformers.DPTForSemanticSegmentation]]

```python
transformers.DPTForSemanticSegmentation(config: DPTConfig)
```

[소스](https://github.com/huggingface/transformers/blob/v5.23.0/src/transformers/models/dpt/modeling_dpt.py#L1070)

**매개변수:**

config ([DPTConfig](/docs/transformers/v5.23.0/ko/model_doc/dpt#transformers.DPTConfig)) : 모델의 모든 매개변수를 포함하는 모델 구성 클래스입니다. 구성 파일로 초기화하는 것은 모델과 관련된 가중치를 로드하지 않으며, 구성 정보만 로드합니다. 모델 가중치를 로드하려면 [from_pretrained()](/docs/transformers/v5.23.0/ko/main_classes/model#transformers.PreTrainedModel.from_pretrained) 메서드를 확인하세요.

…

이 모델은 [PreTrainedModel](/docs/transformers/v5.23.0/ko/main_classes/model#transformers.PreTrainedModel)에서 상속됩니다. 라이브러리가 모든 모델에 대해 구현하는 일반적 메서드(다운로드 또는 저장, 입력 임베딩 크기 조정, 헤드 프루닝 등)에 대해서는 상위 클래스 문서를 확인하세요.

이 모델은 또한 PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module)의 하위 클래스입니다. 일반적인 PyTorch Module처럼 사용하며, 일반적인 사용법과 동작에 관한 모든 사항은 PyTorch 문서를 참조하세요.

#### forward[[transformers.DPTForSemanticSegmentation.forward]]

```python
forward(pixel_values: typing.Optional[torch.Tensor] = None, labels: typing.Optional[torch.LongTensor] = None, **kwargs: *<class 'transformers.utils.generic.TransformersKwargs'>)
```

[소스](https://github.com/huggingface/transformers/blob/v5.23.0/src/transformers/models/dpt/modeling_dpt.py#L1086)

**매개변수:**

pixel_values (`torch.Tensor`, shape `(batch_size, num_channels, image_size, image_size)`, *선택 사항*) : 입력 이미지에 해당하는 텐서입니다. 픽셀 값은 `image_processor_class`를 사용하여 얻을 수 있습니다. 자세한 내용은 `image_processor_class.__call__`를 참조하세요 (`processor_class`는 이미지 처리에 `image_processor_class`를 사용합니다).

labels (`torch.LongTensor`, shape `(batch_size, height, width)`, *선택 사항*) : 손실을 계산하기 위한 ground truth semantic segmentation 맵입니다. 인덱스는 `[0, ..., config.num_labels - 1]` 범위에 있어야 합니다. `config.num_labels > 1`인 경우, 분류 손실(Cross-Entropy)이 계산됩니다.

**반환값:** [SemanticSegmenterOutput](/docs/transformers/v5.23.0/ko/main_classes/output#transformers.modeling_outputs.SemanticSegmenterOutput) 또는 `tuple(torch.Tensor)`

[SemanticSegmenterOutput](/docs/transformers/v5.23.0/ko/main_classes/output#transformers.modeling_outputs.SemanticSegmenterOutput) 또는 `torch.Tensor`의 튜플(`return_dict=False`가 전달되거나 `config.return_dict=False`인 경우)로, 구성(`None`) 및 입력에 따라 다양한 요소를 포함합니다.

[DPTForSemanticSegmentation](/docs/transformers/v5.23.0/ko/model_doc/dpt#transformers.DPTForSemanticSegmentation)의 forward 메서드는 `__call__` 특수 메서드를 오버라이드합니다.

`Module` 인스턴스는 전처리 및 후처리 단계를 실행하는 것을 처리하지만, 이 함수는 해당 단계를 조용히 무시하므로, 순전파(forward pass) 레시피를 이 함수 내에서 정의해야 하더라도 이후에는 이 함수 대신 `Module` 인스턴스를 호출해야 합니다.

- **loss** (`torch.Tensor`, shape `(1,)`, *선택*, `labels`이 제공될 때 반환됨) -- 분류(또는 config.num_labels==1인 경우 회귀) 손실.
- **logits** (shape `(batch_size, config.num_labels, logits_height, logits_width)`의 `torch.Tensor`) -- 각 픽셀에 대한 분류 점수입니다.

  

  반환되는 logits는 입력으로 전달된 `pixel_values`와 반드시 동일한 크기를 갖지 않습니다. 이는 사용자가 후처리 단계에서 logits를 원본 이미지 크기로 리사이즈할 때 두 번의 보간을 수행하여 품질이 저하되는 것을 방지하기 위한 것입니다. 항상 logits의 shape을 확인하고 필요에 따라 리사이즈해야 합니다.

  
- **hidden_states** (`tuple(torch.Tensor)`, *선택*, `output_hidden_states=True`가 전달되거나 `config.output_hidden_states=True`일 때 반환) -- shape가 `(batch_size, patch_size, hidden_size)`인 `torch.Tensor`의 튜플 (모델에 임베딩 레이어가 있는 경우 임베딩 출력 1개 + 각 레이어의 출력 1개).

  각 레이어의 출력에서 모델의 Hidden-states와 선택적 초기 임베딩 출력을 포함합니다.
- **attentions** (`tuple(torch.Tensor)`, *선택 사항*, `output_attentions=True`가 전달되었거나 `config.output_attentions=True`인 경우 반환) -- 각 레이어당 하나씩, shape가 `(batch_size, num_heads, patch_size, sequence_length)`인 `torch.Tensor`의 튜플.

  self-attention 헤드에서 가중 평균을 계산하는 데 사용되는 attention softmax 이후의 attention 가중치입니다.

예:
```python
>>> from transformers import AutoImageProcessor, DPTForSemanticSegmentation
>>> from PIL import Image
>>> from huggingface_hub.utils import httpx
>>> from io import BytesIO

>>> url = "http://images.cocodataset.org/val2017/000000039769.jpg"
>>> with httpx.stream("GET", url) as response:
...     image = Image.open(BytesIO(response.read()))

>>> image_processor = AutoImageProcessor.from_pretrained("Intel/dpt-large-ade")
>>> model = DPTForSemanticSegmentation.from_pretrained("Intel/dpt-large-ade")

>>> inputs = image_processor(images=image, return_tensors="pt")

>>> outputs = model(**inputs)
>>> logits = outputs.logits
```

