Buckets:

mishig's picture
|
download
raw
3.43 kB
# OpenVINO
🤗 يوفر [Optimum](https://github.com/huggingface/optimum-intel) خطوط أنابيب Stable Diffusion متوافقة مع OpenVINO لتنفيذ الاستدلال على مجموعة متنوعة من معالجات Intel (انظر [القائمة الكاملة](https://docs.openvino.ai/latest/openvino_docs_OV_UG_supported_plugins_Supported_Devices.html) للأجهزة المدعومة).
ستحتاج إلى تثبيت 🤗 Optimum Intel مع خيار `--upgrade-strategy eager` للتأكد من أن [`optimum-intel`](https://github.com/huggingface/optimum-intel) يستخدم أحدث إصدار:
```bash
pip install --upgrade-strategy eager optimum["openvino"]
```
ستُظهر لك هذه الدليل كيفية استخدام خطوط أنابيب Stable Diffusion و Stable Diffusion XL (SDXL) مع OpenVINO.
## Stable Diffusion
لتحميل النموذج وتشغيل الاستدلال، استخدم `OVStableDiffusionPipeline`. إذا كنت ترغب في تحميل نموذج PyTorch وتحويله إلى صيغة OpenVINO على الفور، فاضبط `export=True`:
```python
from optimum.intel import OVStableDiffusionPipeline
model_id = "stable-diffusion-v1-5/stable-diffusion-v1-5"
pipeline = OVStableDiffusionPipeline.from_pretrained(model_id, export=True)
prompt = "sailing ship in storm by Rembrandt"
image = pipeline(prompt).images[0]
# Don't forget to save the exported model
pipeline.save_pretrained("openvino-sd-v1-5")
```
لتسريع الاستدلال بشكل أكبر، أعد تشكيل النموذج بشكل ثابت. إذا قمت بتغيير أي من المعلمات مثل ارتفاع أو عرض المخرجات، فستحتاج إلى إعادة تشكيل نموذجك بشكل ثابت مرة أخرى.
```python
# Define the shapes related to the inputs and desired outputs
batch_size, num_images, height, width = 1, 1, 512, 512
# Statically reshape the model
pipeline.reshape(batch_size, height, width, num_images)
# Compile the model before inference
pipeline.compile()
image = pipeline(
prompt,
height=height,
width=width,
num_images_per_prompt=num_images,
).images[0]
```
يمكنك العثور على مزيد من الأمثلة في [التوثيق](https://huggingface.co/docs/optimum/intel/inference#stable-diffusion) الخاص بـ 🤗 Optimum، كما أن Stable Diffusion مدعوم لتوليد الصور من النص، وتحويل الصورة إلى صورة، وإعادة رسم المناطق (inpainting).
## Stable Diffusion XL
لتحميل وتشغيل الاستدلال مع SDXL، استخدم `OVStableDiffusionXLPipeline`:
```python
from optimum.intel import OVStableDiffusionXLPipeline
model_id = "stabilityai/stable-diffusion-xl-base-1.0"
pipeline = OVStableDiffusionXLPipeline.from_pretrained(model_id)
prompt = "sailing ship in storm by Rembrandt"
image = pipeline(prompt).images[0]
```
لتسريع الاستدلال بشكل أكبر، [أعد تشكيل](#stable-diffusion) النموذج بشكل ثابت كما هو موضح في قسم Stable Diffusion.
يمكنك العثور على مزيد من الأمثلة في [التوثيق](https://huggingface.co/docs/optimum/intel/inference#stable-diffusion-xl) الخاص بـ 🤗 Optimum، كما أن تشغيل SDXL في OpenVINO مدعوم لتوليد الصور من النص وتحويل الصور إلى صور.

Xet Storage Details

Size:
3.43 kB
·
Xet hash:
f40b3a8e331ef13d94b5b3b930377604ff005a9a0eb16811a0e86d303c4c74ba

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.