# 画像プロセッサ用のユーティリティ

このページでは、画像プロセッサで使用されるすべてのユーティリティ関数をリストしています。主に、画像の処理に使用される関数型の変換です。

これらの多くは、ライブラリの画像プロセッサのコードを研究する場合にのみ有用です。

## 画像変換[[transformers.image_transforms.center_crop]]

#### transformers.image_transforms.center_crop[[transformers.image_transforms.center_crop]]

```python
transformers.image_transforms.center_crop(image: ndarray, size: tuple[int, int], data_format: str | transformers.image_utils.ChannelDimension | None = None, input_data_format: str | transformers.image_utils.ChannelDimension | None = None)
```

[ソース](https://github.com/huggingface/transformers/blob/v5.23.0/src/transformers/image_transforms.py#L448)

**パラメータ:**

image (`np.ndarray`) : 切り抜く画像。

size (`tuple[int, int]`) : 切り抜かれた画像のターゲットサイズ。

data_format (`str` または `ChannelDimension`、*任意*) : 出力画像のチャネル次元の形式です。以下のいずれかになります: - `"channels_first"` または `ChannelDimension.FIRST`: (num_channels, height, width) 形式の画像。 - `"channels_last"` または `ChannelDimension.LAST`: (height, width, num_channels) 形式の画像。 未設定の場合、入力画像の推定された形式が使用されます。

input_data_format (`str` または `ChannelDimension`、*任意*) : 入力画像のチャネル次元の形式です。以下のいずれかになります: - `"channels_first"` または `ChannelDimension.FIRST`: (num_channels, height, width) 形式の画像。 - `"channels_last"` または `ChannelDimension.LAST`: (height, width, num_channels) 形式の画像。 未設定の場合、入力画像から推定された形式が使用されます。

**戻り値:** `np.ndarray`

切り抜かれた画像。

`image`を中央クロップにより指定された`size`に切り出します。画像が指定されたサイズにクロップできないほど小さい場合は、パディングが適用されます（そのため、返される結果は常に`size`のサイズになります）。

#### transformers.image_transforms.center_to_corners_format[[transformers.image_transforms.center_to_corners_format]]

```python
transformers.image_transforms.center_to_corners_format(bboxes_center: TensorType)
```

[ソース](https://github.com/huggingface/transformers/blob/v5.23.0/src/transformers/image_transforms.py#L553)

バウンディングボックスを中心形式から角形式に変換します。

center形式: ボックスの中心座標と幅、高さの寸法 (center_x, center_y, width, height) を含みます。 corners形式: ボックスの左上隅と右下隅の座標 (top_left_x, top_left_y, bottom_right_x, bottom_right_y) を含みます。

#### transformers.image_transforms.corners_to_center_format[[transformers.image_transforms.corners_to_center_format]]

```python
transformers.image_transforms.corners_to_center_format(bboxes_corners: TensorType)
```

[ソース](https://github.com/huggingface/transformers/blob/v5.23.0/src/transformers/image_transforms.py#L596)

バウンディングボックスをコーナー形式からセンター形式に変換します。

corners形式: ボックスの左上隅と右下隅の座標(top_left_x, top_left_y, bottom_right_x, bottom_right_y)を含む center形式: ボックスの中心の座標と幅、高さの寸法(center_x, center_y, width, height)を含む

#### transformers.image_transforms.id_to_rgb[[transformers.image_transforms.id_to_rgb]]

```python
transformers.image_transforms.id_to_rgb(id_map)
```

[ソース](https://github.com/huggingface/transformers/blob/v5.23.0/src/transformers/image_transforms.py#L643)

一意のIDをRGBカラーに変換します。

#### transformers.image_transforms.normalize[[transformers.image_transforms.normalize]]

```python
transformers.image_transforms.normalize(image: ndarray, mean: float | collections.abc.Collection[float], std: float | collections.abc.Collection[float], data_format: transformers.image_utils.ChannelDimension | None = None, input_data_format: str | transformers.image_utils.ChannelDimension | None = None)
```

[ソース](https://github.com/huggingface/transformers/blob/v5.23.0/src/transformers/image_transforms.py#L387)

**パラメータ:**

image (`np.ndarray`) : 正規化対象の画像。

mean (`float` または `Collection[float]`) : 正規化に使用する平均値。

std (`float` または `Collection[float]`) : 正規化に使用する標準偏差。

data_format (`ChannelDimension`, *任意*) : 出力画像のチャネル次元の形式です。設定されていない場合、入力から推測された形式が使用されます。

input_data_format (`ChannelDimension`, *任意*) : 入力画像のチャネル次元の形式です。設定されていない場合、入力から推定された形式が使用されます。

`image`を、`mean`と`std`で指定された平均と標準偏差を用いて正規化します。

image = (image - mean) / std

#### transformers.image_transforms.pad[[transformers.image_transforms.pad]]

```python
transformers.image_transforms.pad(image: ndarray, padding: int | tuple[int, int] | collections.abc.Iterable[tuple[int, int]], mode: PaddingMode = <PaddingMode.CONSTANT: 'constant'>, constant_values: float | collections.abc.Iterable[float] = 0.0, data_format: str | transformers.image_utils.ChannelDimension | None = None, input_data_format: str | transformers.image_utils.ChannelDimension | None = None)
```

[ソース](https://github.com/huggingface/transformers/blob/v5.23.0/src/transformers/image_transforms.py#L673)

**パラメータ:**

image (`np.ndarray`) : パディングを行う画像。

padding (`int` または `tuple[int, int]` または `Iterable[tuple[int, int]]`) : 高さ軸と幅軸の端に適用するパディング。以下の3つの形式のいずれかを使用できます。 - `((before_height, after_height), (before_width, after_width))` 各軸ごとに個別のパディング幅を指定します。 - `((before, after),)` 高さと幅の両方に同じ before と after のパディングを適用します。 - `(pad,)` または int は、すべての軸で before = after = pad 幅とするショートカットです。

mode (`PaddingMode`) : 使用するパディングモード。以下のいずれかです: - `"constant"`: 一定の値でパディングします。 - `"reflect"`: 各軸に沿って、ベクトルの先頭と末尾の値を鏡面反射させたベクトルでパディングします。 - `"replicate"`: 各軸に沿って、配列の端の最後の値を複製してパディングします。 - `"symmetric"`: 配列の端に沿って鏡面反射させたベクトルでパディングします。

constant_values (`float` または `Iterable[float]`、*任意*) : `mode` が `"constant"` の場合に、パディングに使用する値。

data_format (`str` または `ChannelDimension`、*任意*) : 出力画像のチャネル次元の形式。以下のいずれかになります: - `"channels_first"` または `ChannelDimension.FIRST`: (num_channels, height, width) 形式の画像。 - `"channels_last"` または `ChannelDimension.LAST`: (height, width, num_channels) 形式の画像。未設定の場合、入力画像と同じ形式が使用されます。

input_data_format (`str` または `ChannelDimension`、*任意*) : 入力画像のチャネル次元の形式です。以下のいずれかになります: - `"channels_first"` または `ChannelDimension.FIRST`: (num_channels, height, width) 形式の画像。 - `"channels_last"` または `ChannelDimension.LAST`: (height, width, num_channels) 形式の画像。 未設定の場合、入力画像から推定された形式が使用されます。

**戻り値:** `np.ndarray`

パディングされた画像。

`image`を指定された (height, width) の `padding` および `mode` でパディングします。

#### transformers.image_transforms.rgb_to_id[[transformers.image_transforms.rgb_to_id]]

```python
transformers.image_transforms.rgb_to_id(color)
```

[ソース](https://github.com/huggingface/transformers/blob/v5.23.0/src/transformers/image_transforms.py#L632)

RGBカラーを一意なIDに変換します。

#### transformers.image_transforms.rescale[[transformers.image_transforms.rescale]]

```python
transformers.image_transforms.rescale(image: ndarray, scale: float, data_format: transformers.image_utils.ChannelDimension | None = None, dtype: dtype = <class 'numpy.float32'>, input_data_format: str | transformers.image_utils.ChannelDimension | None = None)
```

[ソース](https://github.com/huggingface/transformers/blob/v5.23.0/src/transformers/image_transforms.py#L92)

**パラメータ:**

image (`np.ndarray`) : 再スケーリングする画像。

scale (`float`) : 画像をリスケールする際に使用するスケール。

data_format (`ChannelDimension`, *任意*) : 画像のチャネル次元の形式です。指定しない場合、入力画像と同じになります。

dtype (`np.dtype`、*任意*、デフォルトは`np.float32`) : 出力画像のdtypeです。デフォルトは`np.float32`です。feature extractorとの後方互換性のために使用されます。

input_data_format (`ChannelDimension`, *任意*) : 入力画像のチャネル次元の形式です。指定しない場合、入力画像から推論されます。

**戻り値:** `np.ndarray`

リサイズされた画像。

`image`を`scale`で再スケーリングします。

#### transformers.image_transforms.resize[[transformers.image_transforms.resize]]

```python
transformers.image_transforms.resize(image: ndarray, size: tuple[int, int], resample: typing.Optional[ForwardRef('PILImageResampling')] = None, reducing_gap: int | None = None, data_format: transformers.image_utils.ChannelDimension | None = None, return_numpy: bool = True, input_data_format: str | transformers.image_utils.ChannelDimension | None = None)
```

[ソース](https://github.com/huggingface/transformers/blob/v5.23.0/src/transformers/image_transforms.py#L316)

**パラメータ:**

image (`np.ndarray`) : リサイズする画像。

size (`tuple[int, int]`) : 画像のリサイズに使用するサイズ。

resample (`int`, *任意*, デフォルトは `PILImageResampling.BILINEAR`) : リサンプリングに使用するフィルタ。

reducing_gap (`int`, *optional*) : 2段階で画像をリサイズすることにより最適化を適用します。`reducing_gap` が大きいほど、結果はフェアなリサンプリングに近づきます。詳細については、対応する Pillow のドキュメントを参照してください。

data_format (`ChannelDimension`, *任意*) : 出力画像のチャネル次元の形式です。設定されていない場合、入力から推測された形式が使用されます。

return_numpy (`bool`、*任意*、デフォルトは `True`) : リサイズされた画像を numpy 配列として返すかどうか。False の場合、`PIL.Image.Image` オブジェクトが返されます。

input_data_format (`ChannelDimension`, *任意*) : 入力画像のチャネル次元の形式です。設定されていない場合、入力から推定された形式が使用されます。

**戻り値:** `np.ndarray`

リサイズされた画像。

PILライブラリを使用して、`size`で指定された`(height, width)`に`image`をリサイズします。

#### transformers.image_transforms.to_pil_image[[transformers.image_transforms.to_pil_image]]

```python
transformers.image_transforms.to_pil_image(image: typing.Union[numpy.ndarray, ForwardRef('PIL.Image.Image'), ForwardRef('torch.Tensor')], do_rescale: bool | None = None, image_mode: str | None = None, input_data_format: str | transformers.image_utils.ChannelDimension | None = None)
```

[ソース](https://github.com/huggingface/transformers/blob/v5.23.0/src/transformers/image_transforms.py#L157)

**パラメータ:**

image (`PIL.Image.Image` または `numpy.ndarray` または `torch.Tensor`) : `PIL.Image` 形式に変換する画像。

do_rescale (`bool`, *任意*) : スケーリング係数を適用するかどうか（ピクセル値を0から255の整数にするため）。画像の型が浮動小数点型であり、`int` へのキャストで精度が失われる場合は `True` がデフォルトとなり、それ以外の場合は `False` となります。

image_mode (`str`、*任意*) : PIL画像に使用するモード。未設定の場合、入力画像のタイプに対するデフォルトモードが使用されます。

input_data_format (`ChannelDimension`, *任意*) : 入力画像のチャネル次元の形式です。設定されていない場合、入力から推定された形式が使用されます。

**戻り値:** `PIL.Image.Image`

変換された画像。

`image`をPIL Imageに変換します。必要に応じて、リスケールし、チャネル次元を最後の軸に戻します。

## ImageProcessingMixin[[transformers.ImageProcessingMixin]]

#### transformers.ImageProcessingMixin[[transformers.ImageProcessingMixin]]

```python
transformers.ImageProcessingMixin(**kwargs)
```

[ソース](https://github.com/huggingface/transformers/blob/v5.23.0/src/transformers/image_processing_base.py#L61)

これは、シーケンシャルおよび画像のフィーチャーエクストラクターに対して保存/読み込み機能を提供するために使用されるイメージプロセッサーのミックスインです。

#### fetch_images[[transformers.ImageProcessingMixin.fetch_images]]

```python
fetch_images(image_url_or_urls: str | list[str] | list[list[str]])
```

[ソース](https://github.com/huggingface/transformers/blob/v5.23.0/src/transformers/image_processing_base.py#L489)

単一のURLまたはURLのリストを、対応する`PIL.Image`オブジェクトに変換します。

単一のurlが渡された場合、戻り値は単一のオブジェクトになります。リストが渡された場合、オブジェクトのリストが返されます。

#### from_dict[[transformers.ImageProcessingMixin.from_dict]]

```python
from_dict(image_processor_dict: dict[str, typing.Any], **kwargs)
```

[ソース](https://github.com/huggingface/transformers/blob/v5.23.0/src/transformers/image_processing_base.py#L366)

**パラメータ:**

image_processor_dict (`dict[str, Any]`) : 画像プロセッサオブジェクトをインスタンス化するために使用される辞書。この辞書は、[to_dict()](/docs/transformers/v5.23.0/ja/internal/image_processing_utils#transformers.ImageProcessingMixin.to_dict) メソッドを活用して事前学習済みチェックポイントから取得できます。

kwargs (`dict[str, Any]`) : 画像プロセッサオブジェクトの初期化に使用する追加のパラメータ。

**戻り値:** [ImageProcessingMixin](/docs/transformers/v5.23.0/ja/internal/image_processing_utils#transformers.ImageProcessingMixin)

これらのパラメータからインスタンス化された画像プロセッサオブジェクト。

パラメータの Python 辞書から [ImageProcessingMixin](/docs/transformers/v5.23.0/ja/internal/image_processing_utils#transformers.ImageProcessingMixin) の型をインスタンス化します。

#### from_json_file[[transformers.ImageProcessingMixin.from_json_file]]

```python
from_json_file(json_file: str | os.PathLike)
```

[ソース](https://github.com/huggingface/transformers/blob/v5.23.0/src/transformers/image_processing_base.py#L419)

**パラメータ:**

json_file (`str` または `os.PathLike`) : パラメータを含む JSON ファイルへのパス。

**戻り値:** [ImageProcessingMixin](/docs/transformers/v5.23.0/ja/internal/image_processing_utils#transformers.ImageProcessingMixin) 型の画像プロセッサ

その JSON ファイルからインスタンス化された image_processor オブジェクト。

パラメータの JSON ファイルへのパスから、[ImageProcessingMixin](/docs/transformers/v5.23.0/ja/internal/image_processing_utils#transformers.ImageProcessingMixin) 型の画像プロセッサをインスタンス化します。

#### from_pretrained[[transformers.ImageProcessingMixin.from_pretrained]]

```python
from_pretrained(pretrained_model_name_or_path: str | os.PathLike, cache_dir: str | os.PathLike | None = None, force_download: bool = False, local_files_only: bool = False, token: str | bool | None = None, revision: str = 'main', **kwargs)
```

[ソース](https://github.com/huggingface/transformers/blob/v5.23.0/src/transformers/image_processing_base.py#L84)

**パラメータ:**

pretrained_model_name_or_path (`str` または `os.PathLike`) : 以下のいずれかです: - huggingface.co のモデルリポジトリにホストされている事前学習済み *model id* の文字列。 - [save_pretrained()](/docs/transformers/v5.23.0/ja/internal/image_processing_utils#transformers.ImageProcessingMixin.save_pretrained) メソッドを使用して保存された image processor ファイルを含む *ディレクトリ* へのパス。例: `./my_model_directory/`。 - 保存された image processor の JSON *ファイル* へのパス。例: `./my_model_directory/preprocessor_config.json`。

cache_dir (`str` または `os.PathLike`、*任意*) : 標準のキャッシュを使用しない場合、ダウンロードした事前学習済みモデルの画像プロセッサをキャッシュするディレクトリのパス。

force_download (`bool`、*任意*、デフォルトは`False`) : 存在する場合はキャッシュされたバージョンを上書きして、イメージプロセッサのファイルを（再）ダウンロードを強制するかどうか。

proxies (`dict[str, str]`, *省略可*) : プロトコルまたはエンドポイントごとに使用するプロキシサーバーの辞書。例: `{'http': 'foo.bar:3128', 'http://hostname': 'foo.bar:4012'}.` 各リクエストでこれらのプロキシが使用されます。

token (`str` または `bool`、*省略可*) : リモートファイルの HTTP ベアラ認証に使用するトークン。`True` の場合、または指定されていない場合は、`hf auth login` を実行した際に生成されたトークン（`~/.huggingface` に保存）が使用されます。

revision (`str`、*任意*、デフォルトは`"main"`) : 使用する特定のモデルバージョンです。huggingface.co ではモデルやその他の成果物を保存するために git ベースのシステムを使用しているため、ブランチ名、タグ名、コミット ID など、git で許可されている任意の識別子を`revision`に指定できます。     Hub で作成したプルリクエストをテストするには、`revision="refs/pr/<pr_number>"`を渡すことができます。

return_unused_kwargs (`bool`、*任意*、デフォルトは`False`) : `False`の場合、この関数は最終的なimage processorオブジェクトのみを返します。`True`の場合、この関数は`Tuple(image_processor, unused_kwargs)`を返します。ここで、*unused_kwargs*は、キーがimage processorの属性でないキー/値のペアで構成される辞書です。つまり、`image_processor`の更新に使用されず、それ以外は無視される`kwargs`の部分です。

subfolder (`str`、*任意*、デフォルトは`""`) : 関連するファイルが huggingface.co 上のモデルリポジトリ内のサブフォルダに配置されている場合、ここにフォルダ名を指定できます。

kwargs (`dict[str, Any]`, *省略可*) : kwargs 内の、キーが image processor の属性である値は、読み込まれた値の上書きに使用されます。キーが image processor の属性で*ない*キー/値ペアの動作は、`return_unused_kwargs` キーワード引数によって制御されます。

**戻り値:**

型が[ImageProcessingMixin](/docs/transformers/v5.23.0/ja/internal/image_processing_utils#transformers.ImageProcessingMixin)の画像プロセッサ。

画像プロセッサから[ImageProcessingMixin](/docs/transformers/v5.23.0/ja/internal/image_processing_utils#transformers.ImageProcessingMixin)の型をインスタンス化します。

例:

```python
# We can't instantiate directly the base class *ImageProcessingMixin* so let's show the examples on a
# derived class: *CLIPImageProcessor*
image_processor = CLIPImageProcessor.from_pretrained(
    "openai/clip-vit-base-patch32"
)  # Download image_processing_config from huggingface.co and cache.
image_processor = CLIPImageProcessor.from_pretrained(
    "./test/saved_model/"
)  # E.g. image processor (or model) was saved using *save_pretrained('./test/saved_model/')*
image_processor = CLIPImageProcessor.from_pretrained("./test/saved_model/preprocessor_config.json")
image_processor = CLIPImageProcessor.from_pretrained(
    "openai/clip-vit-base-patch32", do_normalize=False, foo=False
)
assert image_processor.do_normalize is False
image_processor, unused_kwargs = CLIPImageProcessor.from_pretrained(
    "openai/clip-vit-base-patch32", do_normalize=False, foo=False, return_unused_kwargs=True
)
assert image_processor.do_normalize is False
assert unused_kwargs == {"foo": False}
```

#### get_image_processor_dict[[transformers.ImageProcessingMixin.get_image_processor_dict]]

```python
get_image_processor_dict(pretrained_model_name_or_path: str | os.PathLike, **kwargs)
```

[ソース](https://github.com/huggingface/transformers/blob/v5.23.0/src/transformers/image_processing_base.py#L238)

**パラメータ:**

pretrained_model_name_or_path (`str` または `os.PathLike`) : パラメータの辞書を取得したい事前学習済みチェックポイントの識別子。

subfolder (`str`、*任意*、デフォルトは`""`) : 関連するファイルが huggingface.co 上のモデルリポジトリ内のサブフォルダに配置されている場合、ここにフォルダ名を指定できます。

image_processor_filename (`str`、*任意*、デフォルトは `"config.json"`) : モデルディレクトリ内で、image processor の設定に使用するファイル名。

**戻り値:** `tuple[Dict, Dict]`

画像プロセッサオブジェクトをインスタンス化するために使用される辞書です。

`pretrained_model_name_or_path` から、`from_dict` を使用して `~image_processor_utils.ImageProcessingMixin` 型の image processor をインスタンス化するために使用するパラメータの辞典を解決します。

#### push_to_hub[[transformers.ImageProcessingMixin.push_to_hub]]

```python
push_to_hub(repo_id: str, commit_message: str | None = None, commit_description: str | None = None, private: bool | None = None, token: bool | str | None = None, revision: str | None = None, create_pr: bool = False, max_shard_size: int | str | None = '50GB', tags: list[str] | None = None)
```

[ソース](https://github.com/huggingface/transformers/blob/v5.23.0/src/transformers/utils/hub.py#L822)

**パラメータ:**

repo_id (`str`) : 画像プロセッサをプッシュするリポジトリの名前です。特定の組織にプッシュする場合は、組織名を含む必要があります。

commit_message (`str`, *任意*) : push 時にコミットするメッセージ。デフォルトは `"Upload image processor"` です。

commit_description (`str`, *任意*) : 作成されるコミットの説明

private (`bool`, *optional*) : リポジトリを非公開にするかどうか。`None`（デフォルト）の場合、組織のデフォルトが非公開でない限り、リポジトリは公開になります。リポジトリが既に存在する場合、この値は無視されます。

token (`bool` または `str`、*省略可*) : リモートファイルの HTTP ベアラ認証に使用するトークン。`True`（デフォルト）の場合、`hf auth login` を実行した際に生成されたトークン（`~/.huggingface` に保存）が使用されます。

revision (`str`, *任意*) : アップロードしたファイルをプッシュするブランチ。

create_pr (`bool`, *任意*, デフォルトは `False`) : アップロードしたファイルで PR を作成するか、直接コミットするかどうかを指定します。

max_shard_size (`int` または `str`、*任意*、デフォルトは `"50GB"`) : モデルにのみ適用されます。シャード化される前のチェックポイントの最大サイズ。シャード化されたチェックポイントは、それぞれがこのサイズ未満になります。文字列で指定する場合は、数字の後に単位（`"5MB"` など）を続ける必要があります。

tags (`list[str]`、*任意*) : Hub にプッシュするタグのリスト。

画像プロセッサのファイルを🤗 Model Hubにアップロードします。

例:

```python
from transformers import AutoImageProcessor

image processor = AutoImageProcessor.from_pretrained("google-bert/bert-base-cased")

# Push the image processor to your namespace with the name "my-finetuned-bert".
image processor.push_to_hub("my-finetuned-bert")

# Push the image processor to an organization with the name "my-finetuned-bert".
image processor.push_to_hub("huggingface/my-finetuned-bert")
```

#### register_for_auto_class[[transformers.ImageProcessingMixin.register_for_auto_class]]

```python
register_for_auto_class(auto_class = 'AutoImageProcessor')
```

[ソース](https://github.com/huggingface/transformers/blob/v5.23.0/src/transformers/image_processing_base.py#L467)

**パラメータ:**

auto_class (`str` または `type`、*省略可能*、デフォルトは `"AutoImageProcessor "`) : この新しい image processor を登録する auto クラス。

このクラスを指定された auto クラスに登録します。ライブラリ内のものはすでに`AutoImageProcessor `にマッピングされているため、このメソッドはカスタム画像プロセッサでのみ使用する必要があります。

#### save_pretrained[[transformers.ImageProcessingMixin.save_pretrained]]

```python
save_pretrained(save_directory: str | os.PathLike, push_to_hub: bool = False, **kwargs)
```

[ソース](https://github.com/huggingface/transformers/blob/v5.23.0/src/transformers/image_processing_base.py#L190)

**パラメータ:**

save_directory (`str` または `os.PathLike`) : 画像プロセッサの JSON ファイルを保存するディレクトリ（存在しない場合は作成されます）。

push_to_hub (`bool`、*任意*、デフォルトは`False`) : モデルを保存した後、Hugging Face モデルハブにプッシュするかどうかを指定します。プッシュ先のリポジトリは`repo_id`で指定できます（指定しない場合、`save_directory`の名前があなたのネームスペース内でデフォルトとして使用されます）。

kwargs (`dict[str, Any]`、*省略可*) : [push_to_hub()](/docs/transformers/v5.23.0/ja/main_classes/model#transformers.utils.PushToHubMixin.push_to_hub) メソッドに渡される追加のキーワード引数。

画像プロセッサオブジェクトをディレクトリ `save_directory` に保存し、[from_pretrained()](/docs/transformers/v5.23.0/ja/internal/image_processing_utils#transformers.ImageProcessingMixin.from_pretrained) クラスメソッドを使って再読み込みできるようにします。

#### to_dict[[transformers.ImageProcessingMixin.to_dict]]

```python
to_dict()
```

[ソース](https://github.com/huggingface/transformers/blob/v5.23.0/src/transformers/image_processing_base.py#L407)

**戻り値:** `dict[str, Any]`

この image processor インスタンスを構成するすべての属性の辞書。

このインスタンスをPythonの辞書にシリアライズします。

#### to_json_file[[transformers.ImageProcessingMixin.to_json_file]]

```python
to_json_file(json_file_path: str | os.PathLike)
```

[ソース](https://github.com/huggingface/transformers/blob/v5.23.0/src/transformers/image_processing_base.py#L453)

**パラメータ:**

json_file_path (`str` または `os.PathLike`) : この image_processor インスタンスのパラメータを保存する JSON ファイルへのパス。

このインスタンスをJSONファイルに保存します。

#### to_json_string[[transformers.ImageProcessingMixin.to_json_string]]

```python
to_json_string()
```

[ソース](https://github.com/huggingface/transformers/blob/v5.23.0/src/transformers/image_processing_base.py#L438)

**戻り値:** `str`

この feature_extractor インスタンスを構成するすべての属性を JSON 形式で含む文字列。

このインスタンスをJSON文字列にシリアライズします。

