Buckets:
VAE 画像プロセッサ
VaeImageProcessor は、StableDiffusionPipeline が VAE エンコーディング用の画像入力を準備し、デコード後の出力を後処理するための統一 API を提供します。これには、リサイズ、正規化、PIL Image、PyTorch、NumPy 配列間の変換などの変換が含まれます。
VaeImageProcessor を使用しているすべてのパイプラインは、PIL Image、PyTorch テンソル、または NumPy 配列を画像入力として受け入れ、ユーザーが指定した output_type 引数に基づいて出力を返します。エンコードされた画像の潜在変数をパイプラインに直接渡し、output_type 引数(例えば output_type="latent")を指定することで、潜在変数を特定の出力としてパイプラインから取得できます。これにより、1 つのパイプラインで生成された潜在変数を、潜在空間から離れることなく別のパイプラインの入力として渡すことができます。また、異なるパイプライン間で PyTorch テンソルを直接渡すことで、複数のパイプラインを連携して使用することがはるかに容易になります。
VaeImageProcessor[[diffusers.VaeImageProcessor]]
diffusers.VaeImageProcessor[[diffusers.VaeImageProcessor]]
diffusers.VaeImageProcessor(do_resize: bool = True, vae_scale_factor: int = 8, vae_latent_channels: int = 4, resample: str = 'lanczos', reducing_gap: int | None = None, do_normalize: bool = True, do_binarize: bool = False, do_convert_rgb: bool = False, do_convert_grayscale: bool = False)
パラメータ:
do_resize (bool、任意、デフォルトは True) : 画像の (height, width) 次元を vae_scale_factor の倍数にダウンスケールするかどうかを指定します。image_processor.VaeImageProcessor.preprocess() メソッドから height と width 引数を受け取ることができます。
vae_scale_factor (int、任意、デフォルトは 8) : VAE のスケールファクター。do_resize が True の場合、画像はこのファクターの倍数に自動的にリサイズされます。
resample (str、任意、デフォルトはlanczos) : 画像のリサイズ時に使用するリサンプリングフィルタ。
do_normalize (bool、任意、デフォルトはTrue) : 画像を[-1,1]に正規化するか否か。
do_binarize (bool、任意、デフォルトは False) : 画像を 0/1 にバイナリ化するかどうかを指定します。
do_convert_rgb (bool、任意、デフォルトはFalse) : 画像をRGB形式に変換するかどうかを指定します。
do_convert_grayscale (bool、任意、デフォルトはFalse) : 画像をグレースケール形式に変換するかどうかを指定します。
VAE用の画像プロセッサ。
apply_overlay[[diffusers.VaeImageProcessor.apply_overlay]]
apply_overlay(mask: Image, init_image: Image, image: Image, crop_coords: tuple[int, int, int, int] | None = None)
パラメータ:
mask (PIL.Image.Image) : 重ね合わせる領域を強調するマスク画像。
init_image (PIL.Image.Image) : オーバーレイが適用される元の画像。
image (PIL.Image.Image) : 元の画像に重ねる画像。
crop_coords (tuple[int, int, int, int]、optional) : 画像をクロップするための座標。指定された場合、画像はそれに従ってクロップされます。
戻り値: PIL.Image.Image
オーバーレイを適用した最終的な画像。
…
binarize[[diffusers.VaeImageProcessor.binarize]]
binarize(image: Image)
パラメータ:
image (PIL.Image.Image) : 画像の入力です。PIL画像である必要があります。
戻り値: PIL.Image.Image
二値化された画像。0.5未満の値は0に、0.5を超える値は1に設定されます。
マスクを作成します。
ぼかし[[diffusers.VaeImageProcessor.blur]]
blur(image: Image, blur_factor: int = 4)
パラメータ:
image (PIL.Image.Image) : グレースケールに変換するPIL画像。
戻り値: PIL.Image.Image
グレースケール変換されたPIL画像。
画像にガウスぼかしを適用します。
convert_to_grayscale[[diffusers.VaeImageProcessor.convert_to_grayscale]]
convert_to_grayscale(image: Image)
パラメータ:
image (PIL.Image.Image) : 変換対象の入力画像。
戻り値: PIL.Image.Image
グレースケールに変換された画像。
指定されたPIL画像をグレースケールに変換します。
convert_to_rgb[[diffusers.VaeImageProcessor.convert_to_rgb]]
convert_to_rgb(image: Image)
パラメータ:
image (PIL.Image.Image) : RGBに変換するPIL画像。
戻り値: PIL.Image.Image
RGB変換済みのPIL画像。
PIL画像をRGB形式に変換します。
正規化解除[[diffusers.VaeImageProcessor.denormalize]]
denormalize(images: typing.Union[numpy.ndarray, torch.Tensor])
パラメータ:
images (np.ndarray または torch.Tensor) : 非正規化対象の画像配列。
戻り値: np.ndarray または torch.Tensor
デノーマライズされた画像配列。
画像配列を[0,1]の範囲にデノーマライズします。
get_crop_region[[diffusers.VaeImageProcessor.get_crop_region]]
get_crop_region(mask_image: Image, width: int, height: int, pad = 0)
パラメータ:
mask_image (PIL.Image.Image) : マスク画像。
width (int) : 処理対象の画像の幅。
height (int) : 処理対象の画像の高さ。
pad (int, 任意) : クロップ領域に追加するパディング。デフォルト値は 0 です。
戻り値: tuple
(x1, y1, x2, y2)は、画像内のすべてのマスク領域を含む矩形領域を表し、元の画像のアスペクト比と一致します。
画像内のすべてのマスク領域を含む矩形領域を検出し、元の画像のアスペクト比に合わせるために領域を拡張します。例えば、ユーザーが128x32の領域にマスクを描き、処理用のサイズが512x512の場合、領域は128x128に拡張されます。
get_default_height_width[[diffusers.VaeImageProcessor.get_default_height_width]]
get_default_height_width(image: typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor], height: int | None = None, width: int | None = None)
パラメータ:
image (PIL.Image.Image | np.ndarray | torch.Tensor) : 画像入力。PIL画像、NumPy配列、またはPyTorchテンソルのいずれかです。NumPy配列の場合は、形状が[batch, height, width]または[batch, height, width, channels]である必要があります。PyTorchテンソルの場合は、形状が[batch, channels, height, width]である必要があります。
height (int | None、任意、デフォルトはNone) : 前処理された画像の高さ。Noneの場合、image入力の高さが使用されます。
width (int | None、任意、デフォルトはNone) : 前処理された画像の幅。Noneの場合、image入力の幅が使用されます。
戻り値: tuple[int, int]
vae_scale_factor の最も近い整数倍にリサイズされた高さと幅のタプル。
vae_scale_factorの次の整数倍に縮小された画像の高さと幅を返します。
normalize[[diffusers.VaeImageProcessor.normalize]]
normalize(images: typing.Union[numpy.ndarray, torch.Tensor])
パラメータ:
images (np.ndarray または torch.Tensor) : 正規化対象の画像配列。
戻り値: np.ndarray または torch.Tensor
正規化された画像配列。
画像配列を[-1,1]に正規化します。
numpy_to_pil[[diffusers.VaeImageProcessor.numpy_to_pil]]
numpy_to_pil(images: ndarray)
パラメータ:
images (np.ndarray) : PIL形式に変換する画像配列。
戻り値: list[PIL.Image.Image]
PIL画像のリスト。
numpyの画像または画像のバッチをPIL画像に変換します。
numpy_to_pt[[diffusers.VaeImageProcessor.numpy_to_pt]]
numpy_to_pt(images: ndarray)
パラメータ:
images (np.ndarray) : PyTorch形式に変換するNumPy画像配列。
戻り値: torch.Tensor
画像のPyTorchテンソル表現です。
NumPyの画像をPyTorchのテンソルに変換します。
pil_to_numpy[[diffusers.VaeImageProcessor.pil_to_numpy]]
pil_to_numpy(images: list[PIL.Image.Image] | PIL.Image.Image)
パラメータ:
images (PIL.Image.Image または list[PIL.Image.Image]) : NumPy 形式に変換する PIL 画像または画像のリスト。
戻り値: np.ndarray
画像のNumPy配列表現です。
PIL画像またはPIL画像のリストをNumPy配列に変換します。
postprocess[[diffusers.VaeImageProcessor.postprocess]]
postprocess(image: Tensor, output_type: str = 'pil', do_denormalize: list[bool] | None = None)
パラメータ:
image (torch.Tensor) : 画像入力です。B x C x H x W の形状を持つ PyTorch テンソルである必要があります。
output_type (str、任意、デフォルトは pil) : 画像の出力タイプ。pil、np、pt、latent のいずれかです。
do_denormalize (list[bool]、任意、デフォルトはNone) : 画像を [0,1] にデノーマライズするかどうか。None の場合、VaeImageProcessor の設定にある do_normalize の値が使用されます。
戻り値: PIL.Image.Image、np.ndarray または torch.Tensor
後処理された画像。
テンソル形式の画像出力をoutput_typeに後処理します。
preprocess[[diffusers.VaeImageProcessor.preprocess]]
preprocess(image: typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor]], height: int | None = None, width: int | None = None, resize_mode: str = 'default', crops_coords: tuple[int, int, int, int] | None = None)
パラメータ:
image (PipelineImageInput) : 画像入力。受け入れ可能な形式は、PIL画像、NumPy配列、PyTorchテンソルです。サポートされている形式のリストも受け入れます。
height (int, optional) : 前処理済み画像の高さ。None の場合、get_default_height_width() を使用してデフォルトの高さを取得します。
width (int, optional) : 前処理後の幅。Noneの場合、get_default_height_width()を使用してデフォルトの幅を取得します。
resize_mode (str, optional, デフォルトは default) : リサイズモードです。default または fill のいずれかになります。default の場合、指定された幅と高さに収まるように画像をリサイズしますが、元の縦横比が維持されない場合があります。fill の場合、指定された幅と高さに収まるように、縦横比を維持したまま画像をリサイズし、その後、指定された寸法内で画像を中央に配置し、空いた部分を画像のデータで埋めます。crop の場合、指定された幅と高さに収まるように、縦横比を維持したまま画像をリサイズし、その後、指定された寸法内で画像を中央に配置し、余分な部分を切り取ります。なお、resize_mode の fill と crop は、PIL 画像の入力のみサポートされています。
crops_coords (list[tuple[int, int, int, int]], 任意、デフォルトは None) : バッチ内の各画像のクロップ座標。None の場合、画像はクロップされません。
戻り値: torch.Tensor
前処理された画像。
画像の入力を前処理します。
pt_to_numpy[[diffusers.VaeImageProcessor.pt_to_numpy]]
pt_to_numpy(images: Tensor)
パラメータ:
images (torch.Tensor) : NumPy形式に変換するPyTorchテンソル。
戻り値: np.ndarray
画像のNumPy配列表現です。
PyTorchテンソルをNumPy画像に変換します。
resize[[diffusers.VaeImageProcessor.resize]]
resize(image: typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor], height: int, width: int, resize_mode: str = 'default')
パラメータ:
image (PIL.Image.Image、np.ndarray または torch.Tensor) : 画像の入力です。PIL 画像、NumPy 配列、または PyTorch テンソルを指定できます。
height (int) : リサイズ後の高さ。
width (int) : リサイズ後の幅。
resize_mode (str、任意、デフォルトは default) : 使用するリサイズモードです。default または fill のいずれかになります。default の場合、指定された幅と高さに収まるように画像をリサイズしますが、元の縦横比が維持されない場合があります。fill の場合、指定された幅と高さに収まるように、縦横比を維持して画像をリサイズし、その後、指定された寸法内で画像を中央揃えにし、空いた部分を画像のデータで埋めます。crop の場合、指定された幅と高さに収まるように、縦横比を維持して画像をリサイズし、その後、指定された寸法内で画像を中央揃えにし、余分な部分を切り取ります。なお、resize_mode の fill と crop は、PIL 画像の入力のみサポートされています。
戻り値: PIL.Image.Image、np.ndarray または torch.Tensor
リサイズされた画像。
画像をリサイズします。
InpaintProcessor[[diffusers.InpaintProcessor]]
InpaintProcessorはmaskとimageの入力を受け取り、これらをまとめて処理します。オプションとして、padding_mask_cropを受け取り、マスクのオーバーレイを適用することもできます。
diffusers.InpaintProcessor[[diffusers.InpaintProcessor]]
diffusers.InpaintProcessor(do_resize: bool = True, vae_scale_factor: int = 8, vae_latent_channels: int = 4, resample: str = 'lanczos', reducing_gap: int | None = None, do_normalize: bool = True, do_binarize: bool = False, do_convert_grayscale: bool = False, mask_do_normalize: bool = False, mask_do_binarize: bool = True, mask_do_convert_grayscale: bool = True)
インペインティング用の画像とマスクの画像プロセッサ。
postprocess[[diffusers.InpaintProcessor.postprocess]]
postprocess(image: Tensor, output_type: str = 'pil', original_image: PIL.Image.Image | None = None, original_mask: PIL.Image.Image | None = None, crops_coords: tuple[int, int, int, int] | None = None)
画像を後処理し、必要に応じてマスクのオーバーレイを適用します
preprocess[[diffusers.InpaintProcessor.preprocess]]
preprocess(image: Image, mask: PIL.Image.Image | None = None, height: int | None = None, width: int | None = None, padding_mask_crop: int | None = None)
画像とマスクを前処理します。
VaeImageProcessorLDM3D[[diffusers.VaeImageProcessorLDM3D]]
VaeImageProcessorLDM3Dは、RGBおよび深度の入力を受け取り、RGBおよび深度の出力を返します。
diffusers.VaeImageProcessorLDM3D[[diffusers.VaeImageProcessorLDM3D]]
diffusers.VaeImageProcessorLDM3D(do_resize: bool = True, vae_scale_factor: int = 8, resample: str = 'lanczos', do_normalize: bool = True)
パラメータ:
do_resize (bool, 任意, デフォルトは True) : 画像の (高さ, 幅) 次元を vae_scale_factor の倍数にダウンスケールするかどうか。
vae_scale_factor (int、任意、デフォルトは 8) : VAE のスケールファクター。do_resize が True の場合、画像はこのファクターの倍数に自動的にリサイズされます。
resample (str、任意、デフォルトはlanczos) : 画像のリサイズ時に使用するリサンプリングフィルタ。
do_normalize (bool、任意、デフォルトはTrue) : 画像を[-1,1]に正規化するか否か。
VAE LDM3D用の画像プロセッサ。
depth_pil_to_numpy[[diffusers.VaeImageProcessorLDM3D.depth_pil_to_numpy]]
depth_pil_to_numpy(images: list[PIL.Image.Image] | PIL.Image.Image)
パラメータ:
images (list[PIL.Image.Image, PIL.Image.Image]) : 変換対象の入力画像または画像のリスト。
戻り値: np.ndarray
変換された画像のNumPy配列。
PIL画像またはPIL画像のリストをNumPy配列に変換します。
numpy_to_depth[[diffusers.VaeImageProcessorLDM3D.numpy_to_depth]]
numpy_to_depth(images: ndarray)
パラメータ:
images (np.ndarray) : 深度画像の NumPy 配列。単一の画像またはバッチのいずれかです。
戻り値: list[PIL.Image.Image]
入力されたNumPy深度画像から変換されたPIL画像のリスト。
NumPyの深度画像または画像のバッチを、PIL画像のリストに変換します。
numpy_to_pil[[diffusers.VaeImageProcessorLDM3D.numpy_to_pil]]
numpy_to_pil(images: ndarray)
パラメータ:
images (np.ndarray) : 入力となる NumPy 配列。単一の画像またはバッチのいずれかです。
戻り値: list[PIL.Image.Image]
入力NumPy配列から変換されたPIL画像のリスト。
NumPyの画像または画像のバッチを、PIL画像のリストに変換します。
preprocess[[diffusers.VaeImageProcessorLDM3D.preprocess]]
preprocess(rgb: typing.Union[torch.Tensor, PIL.Image.Image, numpy.ndarray], depth: typing.Union[torch.Tensor, PIL.Image.Image, numpy.ndarray], height: int | None = None, width: int | None = None, target_res: int | None = None)
パラメータ:
rgb (torch.Tensor | PIL.Image.Image | np.ndarray) : RGB入力画像。単一の画像またはバッチのいずれかです。
depth (torch.Tensor | PIL.Image.Image | np.ndarray) : 深度入力画像。単一の画像またはバッチのいずれかです。
height (int | None、任意、デフォルトはNone) : 処理後の画像の希望する高さ。Noneの場合、入力画像の高さがデフォルトになります。
width (int | None、任意、デフォルトはNone) : 処理後の画像の希望する幅。Noneの場合、入力画像の幅がデフォルトになります。
target_res (int | None, 任意, デフォルトは None) : 画像のリサイズに使用するターゲット解像度。指定すると、height と width を上書きします。
戻り値: tuple[torch.Tensor, torch.Tensor]
PyTorchテンソルとして処理済みのRGB画像と深度画像を含むタプル。
画像入力を前処理します。受け入れられる形式は、PIL画像、NumPy配列、またはPyTorchテンソルです。
rgblike_to_depthmap[[diffusers.VaeImageProcessorLDM3D.rgblike_to_depthmap]]
rgblike_to_depthmap(image: typing.Union[numpy.ndarray, torch.Tensor])
RGB風の深度画像を深度マップに変換します。
PixArtImageProcessor[[diffusers.PixArtImageProcessor]]
diffusers.PixArtImageProcessor[[diffusers.PixArtImageProcessor]]
diffusers.PixArtImageProcessor(do_resize: bool = True, vae_scale_factor: int = 8, resample: str = 'lanczos', do_normalize: bool = True, do_binarize: bool = False, do_convert_grayscale: bool = False)
パラメータ:
do_resize (bool、任意、デフォルトは True) : 画像の (height, width) 次元を vae_scale_factor の倍数にダウンスケールするかどうかを指定します。image_processor.VaeImageProcessor.preprocess() メソッドから height と width 引数を受け取ることができます。
vae_scale_factor (int、任意、デフォルトは 8) : VAE のスケールファクター。do_resize が True の場合、画像はこのファクターの倍数に自動的にリサイズされます。
resample (str、任意、デフォルトはlanczos) : 画像のリサイズ時に使用するリサンプリングフィルタ。
do_normalize (bool、任意、デフォルトはTrue) : 画像を[-1,1]に正規化するか否か。
do_binarize (bool、任意、デフォルトは False) : 画像を 0/1 にバイナリ化するかどうかを指定します。
do_convert_rgb (bool、任意、デフォルトはFalse) : 画像をRGB形式に変換するかどうかを指定します。
do_convert_grayscale (bool、任意、デフォルトはFalse) : 画像をグレースケール形式に変換するかどうかを指定します。
PixArtの画像リサイズおよびクロップ用の画像プロセッサ。
classify_height_width_bin[[diffusers.PixArtImageProcessor.classify_height_width_bin]]
classify_height_width_bin(height: int, width: int, ratios: dict)
パラメータ:
height (int) : 画像の高さ。
width (int) : 画像の幅。
ratios (dict) : キーがアスペクト比、値が (height, width) のタプルである辞書。
戻り値: tuple[int, int]
最も近いビン化された高さおよび幅。
アスペクト比に基づいて、バインされた高さおよび幅を返します。
resize_and_crop_tensor[[diffusers.PixArtImageProcessor.resize_and_crop_tensor]]
resize_and_crop_tensor(samples: Tensor, new_width: int, new_height: int)
パラメータ:
samples (torch.Tensor) : 形状が (N, C, H, W) のテンソル。N はバッチサイズ、C はチャネル数、H は高さ、W は幅を表します。
new_width (int) : 出力画像の希望する幅。
new_height (int) : 出力画像の希望する高さ。
戻り値: torch.Tensor
リサイズおよびクロップされた画像を含むテンソル。
画像のテンソルを指定されたサイズにリサイズおよびクロップします。
IPAdapterMaskProcessor[[diffusers.IPAdapterMaskProcessor]]
diffusers.IPAdapterMaskProcessor[[diffusers.IPAdapterMaskProcessor]]
diffusers.IPAdapterMaskProcessor(do_resize: bool = True, vae_scale_factor: int = 8, resample: str = 'lanczos', do_normalize: bool = False, do_binarize: bool = True, do_convert_grayscale: bool = True)
パラメータ:
do_resize (bool, 任意, デフォルトは True) : 画像の (高さ, 幅) 次元を vae_scale_factor の倍数にダウンスケールするかどうか。
vae_scale_factor (int、任意、デフォルトは 8) : VAE のスケールファクター。do_resize が True の場合、画像はこのファクターの倍数に自動的にリサイズされます。
resample (str、任意、デフォルトはlanczos) : 画像のリサイズ時に使用するリサンプリングフィルタ。
do_normalize (bool、任意、デフォルトはFalse) : 画像を [-1,1] に正規化するか否か。
do_binarize (bool、任意、デフォルトはTrue) : 画像を 0/1 にバイナリ化するかどうかを指定します。
do_convert_grayscale (bool、任意、デフォルトはTrue) : 画像をグレースケール形式に変換するかどうかを指定します。
IP Adapterの画像マスク用の画像プロセッサ。
ダウンサンプリング[[diffusers.IPAdapterMaskProcessor.downsample]]
downsample(mask: Tensor, batch_size: int, num_queries: int, value_embed_dim: int)
パラメータ:
mask (torch.Tensor) : IPAdapterMaskProcessor.preprocess() で生成された入力マスクテンソル。
batch_size (int) : バッチサイズ。
num_queries (int) : クエリの数。
value_embed_dim (int) : 値埋め込みの次元数。
戻り値: torch.Tensor
ダウンサンプリングされたマスクテンソル。
指定されたマスクテンソルをダウンサンプリングし、スケーリングドットプロダクトアテンションで期待される次元に一致させます。マスクのアスペクト比が出力画像のアスペクト比と一致しない場合、警告が発行されます。
Xet Storage Details
- Size:
- 28.5 kB
- Xet hash:
- 3eb0bbe53ce1709556e329847887ebdde7eda936ece0e3d58bd90aed11c33382
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.