# معالج صور VAE

يوفر [VaeImageProcessor](/docs/diffusers/v0.43.0/ar/api/image_processor#diffusers.VaeImageProcessor) واجهة برمجة تطبيقات موحّدة لخطوط أنابيب [StableDiffusionPipeline](/docs/diffusers/v0.43.0/ar/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline) لتحضير مدخلات الصور لتشفير VAE ومعالجة المخرجات بعد فك تشفيرها. وتشمل هذه العملية تحويلات مثل تغيير الحجم، والتطبيع، والتحويل بين مصفوفات PIL Image وPyTorch وNumPy.

تقبل جميع خطوط الأنابيب التي تستخدم [VaeImageProcessor](/docs/diffusers/v0.43.0/ar/api/image_processor#diffusers.VaeImageProcessor) صور PIL، أو متجهات PyTorch، أو مصفوفات NumPy كمدخلات للصور، وتعيد المخرجات بناءً على معامل `output_type` الذي يحدده المستخدم. يمكنك تمرير كامنات الصور المشفرة مباشرةً إلى خط الأنابيب، وإرجاع الكامنات من خط الأنابيب كمخرجات محددة باستخدام معامل `output_type` (على سبيل المثال `output_type="latent"`). يتيح لك ذلك أخذ الكامنات المولدة من خط أنابيب واحد وتمريرها إلى خط أنابيب آخر كمدخلات دون الخروج من فضاء الكامنات. كما يجعل من السهل بكثير استخدام خطوط أنابيب متعددة معًا من خلال تمرير متجهات PyTorch مباشرةً بين خطوط الأنابيب المختلفة.

## VaeImageProcessor[[diffusers.VaeImageProcessor]]

#### diffusers.VaeImageProcessor[[diffusers.VaeImageProcessor]]

```python
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)
```

[المصدر](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/image_processor.py#L83)

**المعاملات:**

do_resize (`bool`، *اختياري*، القيمة الافتراضية `True`) : ما إذا كان سيتم تصغير أبعاد الصورة (الارتفاع، العرض) إلى مضاعفات لـ`vae_scale_factor`. يمكنه قبول حجج `height` و`width` من طريقة [image_processor.VaeImageProcessor.preprocess()](/docs/diffusers/v0.43.0/ar/api/image_processor#diffusers.VaeImageProcessor.preprocess).

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]]

```python
apply_overlay(mask: Image, init_image: Image, image: Image, crop_coords: tuple[int, int, int, int] | None = None)
```

[المصدر](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/image_processor.py#L789)

**المعاملات:**

mask (`PIL.Image.Image`) : صورة القناع التي تُبرز المناطق التي سيتم تراكبها.

init_image (`PIL.Image.Image`) : الصورة الأصلية التي يُطبَّق عليها التراكب.

image (`PIL.Image.Image`) : الصورة التي سيتم دمجها فوق الصورة الأصلية.

crop_coords (`tuple[int, int, int, int]`، *اختياري*) : إحداثيات لقص الصورة. إذا تم تقديمها، فسيتم قص الصورة وفقًا لها.

**يعيد:** `PIL.Image.Image`

الصورة النهائية مع تطبيق التراكب.

يطبّق طبقةً فوق الصورة الأصلية تجمع بين القناع والصورة المُعاد رسمها.

#### binarize[[diffusers.VaeImageProcessor.binarize]]

```python
binarize(image: Image)
```

[المصدر](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/image_processor.py#L524)

**المعاملات:**

image (`PIL.Image.Image`) : مدخل الصورة، يجب أن يكون صورة بصيغة PIL.

**يعيد:** `PIL.Image.Image`

الصورة المُثنّاة. تُضبط القيم الأقل من 0.5 إلى 0، وتُضبط القيم الأكبر من 0.5 إلى 1.

أنشئ قناعًا.

#### ضبابية[[diffusers.VaeImageProcessor.blur]]

```python
blur(image: Image, blur_factor: int = 4)
```

[المصدر](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/image_processor.py#L271)

**المعاملات:**

image (`PIL.Image.Image`) : صورة PIL التي سيتم تحويلها إلى رمادية.

**يعيد:** `PIL.Image.Image`

صورة PIL المحوّلة إلى درجات رمادية.

يطبّق ضبابية غاوسية على صورة.

#### convert_to_grayscale[[diffusers.VaeImageProcessor.convert_to_grayscale]]

```python
convert_to_grayscale(image: Image)
```

[المصدر](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/image_processor.py#L254)

**المعاملات:**

image (`PIL.Image.Image`) : الصورة المدخلة للتحويل.

**يعيد:** `PIL.Image.Image`

الصورة المحوّلة إلى درجات رمادية.

يحوّل صورة PIL المعطاة إلى صورة رمادية.

#### convert_to_rgb[[diffusers.VaeImageProcessor.convert_to_rgb]]

```python
convert_to_rgb(image: Image)
```

[المصدر](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/image_processor.py#L237)

**المعاملات:**

image (`PIL.Image.Image`) : صورة PIL التي سيتم تحويلها إلى RGB.

**يعيد:** `PIL.Image.Image`

صورة PIL المحوّلة إلى RGB.

يحوّل صورة PIL إلى تنسيق RGB.

#### إزالة التطبيع[[diffusers.VaeImageProcessor.denormalize]]

```python
denormalize(images: typing.Union[numpy.ndarray, torch.Tensor])
```

[المصدر](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/image_processor.py#L222)

**المعاملات:**

images (`np.ndarray` أو `torch.Tensor`) : مصفوفة الصورة التي سيتم إلغاء تطبيعها.

**يعيد:** `np.ndarray` أو `torch.Tensor`

مصفوفة الصور غير المعيارية.

إزالة تطبيع مصفوفة صورة إلى [0,1].

#### get_crop_region[[diffusers.VaeImageProcessor.get_crop_region]]

```python
get_crop_region(mask_image: Image, width: int, height: int, pad = 0)
```

[المصدر](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/image_processor.py#L288)

**المعاملات:**

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]]

```python
get_default_height_width(image: typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor], height: int | None = None, width: int | None = None)
```

[المصدر](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/image_processor.py#L561)

**المعاملات:**

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]`

مجموعة (tuple) تحتوي على الارتفاع والعرض، وكلاهما مُعاد تحديده إلى أقرب مضاعف صحيح لـ `vae_scale_factor`.

يعيد ارتفاع الصورة وعرضها، بعد تصغيرهما إلى أقرب مضاعف صحيح لـ`vae_scale_factor`.

#### تطبيع[[diffusers.VaeImageProcessor.normalize]]

```python
normalize(images: typing.Union[numpy.ndarray, torch.Tensor])
```

[المصدر](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/image_processor.py#L207)

**المعاملات:**

images (`np.ndarray` أو `torch.Tensor`) : مصفوفة الصورة التي سيتم تطبيعها.

**يعيد:** `np.ndarray` أو `torch.Tensor`

مصفوفة الصور المعيارية.

تطبيع مصفوفة صورة إلى [-1,1].

#### numpy_to_pil[[diffusers.VaeImageProcessor.numpy_to_pil]]

```python
numpy_to_pil(images: ndarray)
```

[المصدر](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/image_processor.py#L128)

**المعاملات:**

images (`np.ndarray`) : مصفوفة الصورة التي سيتم تحويلها إلى تنسيق PIL.

**يعيد:** `list[PIL.Image.Image]`

قائمة من صور PIL.

تحويل صورة numpy أو دفعة من الصور إلى صورة PIL.

#### numpy_to_pt[[diffusers.VaeImageProcessor.numpy_to_pt]]

```python
numpy_to_pt(images: ndarray)
```

[المصدر](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/image_processor.py#L172)

**المعاملات:**

images (`np.ndarray`) : مصفوفة الصورة في NumPy التي سيتم تحويلها إلى صيغة PyTorch.

**يعيد:** `torch.Tensor`

تمثيل PyTorch للمصفوفات (Tensors) للصور.

تحويل صورة NumPy إلى متجه PyTorch.

#### pil_to_numpy[[diffusers.VaeImageProcessor.pil_to_numpy]]

```python
pil_to_numpy(images: list[PIL.Image.Image] | PIL.Image.Image)
```

[المصدر](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/image_processor.py#L152)

**المعاملات:**

images (`PIL.Image.Image` أو `list[PIL.Image.Image]`) : صورة PIL أو قائمة صور لتحويلها إلى صيغة NumPy.

**يعيد:** `np.ndarray`

تمثيل مصفوفة NumPy للصور.

تحويل صورة PIL أو قائمة من صور PIL إلى مصفوفات NumPy.

#### postprocess[[diffusers.VaeImageProcessor.postprocess]]

```python
postprocess(image: Tensor, output_type: str = 'pil', do_denormalize: list[bool] | None = None)
```

[المصدر](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/image_processor.py#L739)

**المعاملات:**

image (`torch.Tensor`) : مدخل الصورة، يجب أن يكون من نوع pytorch tensor بالشكل `B x C x H x W`.

output_type (`str`، *اختياري*، الافتراضي `pil`) : نوع الصورة المُخرَج، يمكن أن يكون أحد `pil`، `np`، `pt`، `latent`.

do_denormalize (`list[bool]`، *اختياري*، القيمة الافتراضية `None`) : ما إذا كان يجب إزالة تطبيع الصورة إلى [0,1]. إذا كانت `None`، فسيتم استخدام قيمة `do_normalize` في إعدادات `VaeImageProcessor`.

**يعيد:** `PIL.Image.Image` أو `np.ndarray` أو `torch.Tensor`

الصورة بعد المعالجة.

معالجة الصورة الناتجة بعد المعالجة من tensor إلى `output_type`.

#### preprocess[[diffusers.VaeImageProcessor.preprocess]]

```python
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)
```

[المصدر](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/image_processor.py#L608)

**المعاملات:**

image (`PipelineImageInput`) : مدخل الصورة، الصيغ المقبولة هي صور PIL، مصفوفات NumPy، وموترات PyTorch؛ كما تقبل قائمة من الصيغ المدعومة.

height (`int`، *اختياري*) : ارتفاع الصورة بعد المعالجة المسبقة. إذا كان `None`، فسيتم استخدام `get_default_height_width()` للحصول على الارتفاع الافتراضي.

width (`int`، *اختياري*) : العرض في المعالجة المسبقة. إذا كان `None`، فسيتم استخدام get_default_height_width()` للحصول على العرض الافتراضي.

resize_mode (`str`، *اختياري*، القيمة الافتراضية `default`) : وضع تغيير الحجم، يمكن أن يكون أحد `default` أو `fill`. إذا كان `default`، فسيتم تغيير حجم الصورة لتناسب العرض والارتفاع المحددين، وقد لا يحافظ على نسبة الأبعاد الأصلية. إذا كان `fill`، فسيتم تغيير حجم الصورة لتناسب العرض والارتفاع المحددين مع الحفاظ على نسبة الأبعاد، ثم يتم توسيط الصورة ضمن الأبعاد، مع ملء الفراغات ببيانات من الصورة. إذا كان `crop`، فسيتم تغيير حجم الصورة لتناسب العرض والارتفاع المحددين مع الحفاظ على نسبة الأبعاد، ثم يتم توسيط الصورة ضمن الأبعاد، مع قص الفائض. لاحظ أن وضعي تغيير الحجم `fill` و`crop` مدعومان فقط لإدخال صور PIL.

crops_coords (`list[tuple[int, int, int, int]]`، *اختياري*، القيمة الافتراضية `None`) : إحداثيات القص لكل صورة في الدفعة. إذا كانت `None`، فلن يتم قص الصورة.

**يعيد:** `torch.Tensor`

الصورة بعد المعالجة المسبقة.

قم بمعالجة مدخل الصورة مسبقًا.

#### pt_to_numpy[[diffusers.VaeImageProcessor.pt_to_numpy]]

```python
pt_to_numpy(images: Tensor)
```

[المصدر](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/image_processor.py#L191)

**المعاملات:**

images (`torch.Tensor`) : متجه PyTorch الذي سيتم تحويله إلى صيغة NumPy.

**يعيد:** `np.ndarray`

تمثيل مصفوفة NumPy للصور.

تحويل متجه PyTorch إلى صورة NumPy.

#### تغيير الحجم[[diffusers.VaeImageProcessor.resize]]

```python
resize(image: typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor], height: int, width: int, resize_mode: str = 'default')
```

[المصدر](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/image_processor.py#L463)

**المعاملات:**

image (`PIL.Image.Image` أو `np.ndarray` أو `torch.Tensor`) : مدخل الصورة، يمكن أن يكون صورة PIL أو مصفوفة numpy أو tensor من pytorch.

height (`int`) : الارتفاع الذي سيتم تغيير حجم الصورة إليه.

width (`int`) : العرض الذي سيتم تغيير حجم الصورة إليه.

resize_mode (`str`، *اختياري*، القيمة الافتراضية `default`) : وضع تغيير الحجم المستخدم، يمكن أن يكون أحد `default` أو `fill`. إذا كان `default`، فسيتم تغيير حجم الصورة لتناسب العرض والارتفاع المحددين، وقد لا يحافظ على نسبة العرض إلى الارتفاع الأصلية. إذا كان `fill`، فسيتم تغيير حجم الصورة لتناسب العرض والارتفاع المحددين مع الحفاظ على نسبة العرض إلى الارتفاع، ثم يتم توسيط الصورة ضمن الأبعاد، مع ملء الفراغات ببيانات من الصورة. إذا كان `crop`، فسيتم تغيير حجم الصورة لتناسب العرض والارتفاع المحددين مع الحفاظ على نسبة العرض إلى الارتفاع، ثم يتم توسيط الصورة ضمن الأبعاد، مع قص الفائض. لاحظ أن وضعي تغيير الحجم `fill` و`crop` مدعومان فقط لإدخال صور PIL.

**يعيد:** `PIL.Image.Image` أو `np.ndarray` أو `torch.Tensor`

الصورة المُعاد تغيير حجمها.

تغيير حجم الصورة.

## InpaintProcessor[[diffusers.InpaintProcessor]]

يقبل [InpaintProcessor](/docs/diffusers/v0.43.0/ar/api/image_processor#diffusers.InpaintProcessor) مدخلات `mask` و`image` ويعالجها معًا. وبشكل اختياري، يمكنه قبول padding_mask_crop وتطبيق تراكب للقناع.

#### diffusers.InpaintProcessor[[diffusers.InpaintProcessor]]

```python
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)
```

[المصدر](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/image_processor.py#L837)

معالج الصور لتعبئة الصور والأقنعة.

#### postprocess[[diffusers.InpaintProcessor.postprocess]]

```python
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)
```

[المصدر](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/image_processor.py#L944)

معالجة الصورة بعد المعالجة، وتطبيق تراكب القناع اختيارياً

#### preprocess[[diffusers.InpaintProcessor.preprocess]]

```python
preprocess(image: Image, mask: PIL.Image.Image | None = None, height: int | None = None, width: int | None = None, padding_mask_crop: int | None = None)
```

[المصدر](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/image_processor.py#L882)

قم بمعالجة الصورة والقناع مسبقًا.

## VaeImageProcessorLDM3D[[diffusers.VaeImageProcessorLDM3D]]

يقبل [VaeImageProcessorLDM3D](/docs/diffusers/v0.43.0/ar/api/image_processor#diffusers.VaeImageProcessorLDM3D) مدخلات RGB وعمق ويعيد مخرجات RGB وعمق.

#### diffusers.VaeImageProcessorLDM3D[[diffusers.VaeImageProcessorLDM3D]]

```python
diffusers.VaeImageProcessorLDM3D(do_resize: bool = True, vae_scale_factor: int = 8, resample: str = 'lanczos', do_normalize: bool = True)
```

[المصدر](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/image_processor.py#L974)

**المعاملات:**

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]]

```python
depth_pil_to_numpy(images: list[PIL.Image.Image] | PIL.Image.Image)
```

[المصدر](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/image_processor.py#L1025)

**المعاملات:**

images (`list[PIL.Image.Image, PIL.Image.Image]`) : الصورة المدخلة أو قائمة الصور التي سيتم تحويلها.

**يعيد:** `np.ndarray`

مصفوفة NumPy للصور المحوّلة.

تحويل صورة PIL أو قائمة من صور PIL إلى مصفوفات NumPy.

#### numpy_to_depth[[diffusers.VaeImageProcessorLDM3D.numpy_to_depth]]

```python
numpy_to_depth(images: ndarray)
```

[المصدر](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/image_processor.py#L1083)

**المعاملات:**

images (`np.ndarray`) : مصفوفة NumPy المدخلة لصور العمق، والتي يمكن أن تكون صورة واحدة أو دفعة.

**يعيد:** `list[PIL.Image.Image]`

قائمة من صور PIL تم تحويلها من صور العمق NumPy المدخلة.

تحويل صورة عمق NumPy أو دفعة من الصور إلى قائمة من صور PIL.

#### numpy_to_pil[[diffusers.VaeImageProcessorLDM3D.numpy_to_pil]]

```python
numpy_to_pil(images: ndarray)
```

[المصدر](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/image_processor.py#L1001)

**المعاملات:**

images (`np.ndarray`) : مصفوفة NumPy المدخلة للصور، والتي يمكن أن تكون صورة واحدة أو دفعة.

**يعيد:** `list[PIL.Image.Image]`

قائمة من صور PIL تم تحويلها من مصفوفة NumPy المدخلة.

تحويل صورة NumPy أو دفعة من الصور إلى قائمة من صور PIL.

#### preprocess[[diffusers.VaeImageProcessorLDM3D.preprocess]]

```python
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)
```

[المصدر](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/image_processor.py#L1161)

**المعاملات:**

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`) : الدقة المستهدفة لتغيير حجم الصور. إذا تم تحديدها، فإنها تتجاوز الارتفاع والعرض.

**يعيد:** `tuple[torch.Tensor, torch.Tensor]`

مجموعة (tuple) تحتوي على صور RGB والعمق المعالجة كمتجهات PyTorch.

قم بمعالجة مدخل الصورة مسبقًا. الصيغ المقبولة هي صور PIL، ومصفوفات NumPy، أو متجهات PyTorch.

#### rgblike_to_depthmap[[diffusers.VaeImageProcessorLDM3D.rgblike_to_depthmap]]

```python
rgblike_to_depthmap(image: typing.Union[numpy.ndarray, torch.Tensor])
```

[المصدر](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/image_processor.py#L1045)

تحويل صورة عمق تشبه صورة RGB إلى خريطة عمق.

## PixArtImageProcessor[[diffusers.PixArtImageProcessor]]

#### diffusers.PixArtImageProcessor[[diffusers.PixArtImageProcessor]]

```python
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)
```

[المصدر](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/image_processor.py#L1381)

**المعاملات:**

do_resize (`bool`، *اختياري*، القيمة الافتراضية `True`) : ما إذا كان سيتم تصغير أبعاد الصورة (الارتفاع، العرض) إلى مضاعفات لـ`vae_scale_factor`. يمكنه قبول حجج `height` و`width` من طريقة [image_processor.VaeImageProcessor.preprocess()](/docs/diffusers/v0.43.0/ar/api/image_processor#diffusers.VaeImageProcessor.preprocess).

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]]

```python
classify_height_width_bin(height: int, width: int, ratios: dict)
```

[المصدر](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/image_processor.py#L1422)

**المعاملات:**

height (`int`) : ارتفاع الصورة.

width (`int`) : عرض الصورة.

ratios (`dict`) : قاموس تكون مفاتيحه نسب أبعاد وقيمته أزواج من (الارتفاع، العرض).

**يعيد:** `tuple[int, int]`

أقرب ارتفاع وعرض مُصنَّف.

يعيد الارتفاع والعرض المُصنَّفين بناءً على نسبة الأبعاد.

#### resize_and_crop_tensor[[diffusers.PixArtImageProcessor.resize_and_crop_tensor]]

```python
resize_and_crop_tensor(samples: Tensor, new_width: int, new_height: int)
```

[المصدر](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/image_processor.py#L1440)

**المعاملات:**

samples (`torch.Tensor`) : متجه (Tensor) على شكل (N, C, H, W) حيث N هو حجم الدفعة (batch size)، وC هو عدد القنوات، وH هو الارتفاع، وW هو العرض.

new_width (`int`) : العرض المطلوب للصور الناتجة.

new_height (`int`) : الارتفاع المطلوب للصور الناتجة.

**يعيد:** `torch.Tensor`

مصفوفة تحتوي على الصور المُعاد تحديدها في الحجم والمُقتطعة.

يُعيد تغيير حجم ومقتطع متجه من الصور إلى الأبعاد المحددة.

## IPAdapterMaskProcessor[[diffusers.IPAdapterMaskProcessor]]

#### diffusers.IPAdapterMaskProcessor[[diffusers.IPAdapterMaskProcessor]]

```python
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)
```

[المصدر](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/image_processor.py#L1277)

**المعاملات:**

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]]

```python
downsample(mask: Tensor, batch_size: int, num_queries: int, value_embed_dim: int)
```

[المصدر](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/image_processor.py#L1318)

**المعاملات:**

mask (`torch.Tensor`) : متجه القناع المُدخل المُولَّد باستخدام `IPAdapterMaskProcessor.preprocess()`.

batch_size (`int`) : حجم الدفعة.

num_queries (`int`) : عدد الاستعلامات.

value_embed_dim (`int`) : بُعد تمثيلات القيم.

**يعيد:** `torch.Tensor`

مصفوفة القناع المُصغّرة.

يُقلّص هذا الدالة حجم مُتجه القناع المُقدَّم (mask tensor) ليتطابق مع الأبعاد المتوقعة لانتباه النقطي المُقيَّم (scaled dot-product attention). إذا لم يتطابق نسبة أبعاد القناع مع نسبة أبعاد الصورة الناتجة، يتم إصدار تحذير.

