Buckets:
| # البدء السريع | |
| Diffusers هي مكتبة موجهة للمطورين والباحثين، توفر واجهة برمجة تطبيقات (API) سهلة للاستدلال (Inference) لتوليد الصور والفيديوهات والصوت، بالإضافة إلى العناصر الأساسية لبناء سير عمل جديدة. | |
| توفر مكتبة Diffusers العديد من التحسينات الجاهزة للاستخدام، مما يتيح تحميل وتشغيل النماذج الكبيرة على أنظمة ذات ذاكرة محدودة، أو تسريع الاستدلال. | |
| ستمنحك هذه المقدمة السريعة نظرة عامة على Diffusers وتساعدك على البدء في توليد المحتوى بسرعة. | |
| > [!TIP] | |
| > قبل أن تبدأ، تأكد من أنك تمتلك [حسابًا](https://huggingface.co/join) على Hugging Face لاستخدام النماذج المقيدة مثل [Flux](https://huggingface.co/black-forest-labs/FLUX.1-dev). هل تبني خط أنابيب مخصصًا بدلاً من ذلك؟ راجع [دليل البدء السريع لـ Modular Diffusers](./modular_diffusers/quickstart) و[نظرة عامة](./modular_diffusers/overview). | |
| اتبع دليل [التثبيت](./installation) لتثبيت Diffusers إذا لم يكن مثبتًا بالفعل. | |
| ## موجّه الوكيل | |
| الصق هذا في وكيل البرمجة لديك لإعداد Diffusers للاستدلال. | |
| ```text | |
| Help me get set up with Hugging Face Diffusers for inference. | |
| 1. Install Diffusers for my environment with `uv pip install "diffusers[torch]"`. | |
| 2. If I need gated Hub models, help me authenticate to the Hugging Face Hub. | |
| 3. Install Diffusers coding agent skills with `diffusers-cli skills add diffusers-cli`. Pass `--cursor`, `--claude`, or `--codex` if auto-detect fails. Optionally pass `--all` to install every skill in the registry. | |
| 4. Run a first text-to-image with DiffusionPipeline or `diffusers-cli run`, using a small or current Quickstart model and the right `device_map` for my machine. | |
| 5. Ask what I want next and point me at the matching docs. | |
| ``` | |
| ## DiffusionPipeline | |
| [DiffusionPipeline](/docs/diffusers/v0.43.0/ar/api/pipelines/overview#diffusers.DiffusionPipeline) packages the pieces of a diffusion model (text encoder, scheduler, UNet or DiT, and VAE) into one class for inference. Load with [from_pretrained()](/docs/diffusers/v0.43.0/ar/api/pipelines/overview#diffusers.DiffusionPipeline.from_pretrained), then call the pipeline. | |
| تُغيّر الحُجج في `__call__()` مثل `num_inference_steps` الجودة والسرعة. للاطلاع على تفاصيل التحميل والمكوّنات القابلة للدمج، راجع [تحميل خطوط الأنابيب](./using-diffusers/loading). لاستبدال المجدول، راجع [المجدولون](./using-diffusers/schedulers). | |
| تستخدم الأمثلة أدناه قيم الحجة الافتراضية. | |
| استخدم `.images[0]` للوصول إلى الصورة الناتجة عن التوليد. | |
| ```py | |
| import torch | |
| from diffusers import DiffusionPipeline | |
| pipeline = DiffusionPipeline.from_pretrained( | |
| "Qwen/Qwen-Image", dtype=torch.bfloat16, device_map="cuda" # or "mps", "xpu", "cpu" | |
| ) | |
| prompt = """ | |
| cinematic film still of a cat sipping a margarita in a pool in Palm Springs, California | |
| highly detailed, high budget hollywood movie, cinemascope, moody, epic, gorgeous, film grain | |
| """ | |
| pipeline(prompt).images[0] | |
| ``` | |
| استخدم `.frames[0]` للوصول إلى مخرجات الفيديو المولّد و[export_to_video()](/docs/diffusers/v0.43.0/ar/api/utilities#diffusers.utils.export_to_video) لحفظ الفيديو. | |
| ```py | |
| import torch | |
| from diffusers import AutoencoderKLWan, DiffusionPipeline | |
| from diffusers.utils import export_to_video | |
| vae = AutoencoderKLWan.from_pretrained( | |
| "Wan-AI/Wan2.2-T2V-A14B-Diffusers", | |
| subfolder="vae", | |
| dtype=torch.float32 | |
| ) | |
| pipeline = DiffusionPipeline.from_pretrained( | |
| "Wan-AI/Wan2.2-T2V-A14B-Diffusers", | |
| vae=vae, | |
| dtype=torch.bfloat16, | |
| device_map="cuda" # or "mps", "xpu", "cpu" | |
| ) | |
| prompt = """ | |
| Cinematic video of a sleek cat lounging on a colorful inflatable in a crystal-clear turquoise pool in Palm Springs, | |
| sipping a salt-rimmed margarita through a straw. Golden-hour sunlight glows over mid-century modern homes and swaying palms. | |
| Shot in rich Sony a7S III: with moody, glamorous color grading, subtle lens flares, and soft vintage film grain. | |
| Ripples shimmer as a warm desert breeze stirs the water, blending luxury and playful charm in an epic, gorgeously composed frame. | |
| """ | |
| video = pipeline(prompt=prompt, num_frames=81, num_inference_steps=40).frames[0] | |
| export_to_video(video, "output.mp4", fps=16) | |
| ``` | |
| ## LoRA | |
| تضيف محولات [LoRA](./tutorials/using_peft_for_inference) نقطة تحقق صغيرة لأسلوب أو موضوع فوق خط أنابيب أساسي. حمّل واحدة باستخدام [load_lora_weights()](/docs/diffusers/v0.43.0/ar/api/loaders/lora#diffusers.loaders.QwenImageLoraLoaderMixin.load_lora_weights). بعض محولات LoRA تتطلب عبارة محفّزة. تحقق من بطاقة النموذج الخاصة بمحوّل LoRA. | |
| ```py | |
| import torch | |
| from diffusers import DiffusionPipeline | |
| pipeline = DiffusionPipeline.from_pretrained( | |
| "Qwen/Qwen-Image", dtype=torch.bfloat16, device_map="cuda" # or "mps", "xpu", "cpu" | |
| ) | |
| pipeline.load_lora_weights( | |
| "threecrowco/VolkClipartQwen", | |
| weight_name="pytorch_lora_weights.safetensors", | |
| ) | |
| prompt = """ | |
| Volk clipart style drawing of a cat sipping a margarita in a pool in Palm Springs, California, flat colors, bold outlines, simple shapes | |
| """ | |
| pipeline(prompt).images[0] | |
| ``` | |
| ## التكميم والتحسينات | |
| تحتاج النماذج الكبيرة غالبًا إلى ذاكرة أقل أو سرعة أعلى. استخدم [التكميم](./quantization/overview) لتقليل حجم الأوزان في الذاكرة، و[compile_repeated_blocks()](/docs/diffusers/v0.43.0/ar/api/models/overview#diffusers.ModelMixin.compile_repeated_blocks) لتسريع عمليات التوليد اللاحقة. للاطلاع على [إزاحة النموذج](./optimization/memory#model-offloading) وخيارات أخرى، راجع [التحسين والتوسع](./stable_diffusion). | |
| لتقليل استهلاك الذاكرة، حمّل النموذج بدقة 4 بت باستخدام bitsandbytes. | |
| ```py | |
| import torch | |
| from diffusers import DiffusionPipeline | |
| from diffusers.quantizers import PipelineQuantizationConfig | |
| quant_config = PipelineQuantizationConfig( | |
| quant_backend="bitsandbytes_4bit", | |
| quant_kwargs={"load_in_4bit": True, "bnb_4bit_quant_type": "nf4", "bnb_4bit_compute_dtype": torch.bfloat16}, | |
| components_to_quantize=["transformer", "text_encoder"], | |
| ) | |
| pipeline = DiffusionPipeline.from_pretrained( | |
| "Qwen/Qwen-Image", | |
| dtype=torch.bfloat16, | |
| quantization_config=quant_config, | |
| device_map="cuda" # or "mps", "xpu", "cpu" | |
| ) | |
| prompt = """ | |
| cinematic film still of a cat sipping a margarita in a pool in Palm Springs, California | |
| highly detailed, high budget hollywood movie, cinemascope, moody, epic, gorgeous, film grain | |
| """ | |
| pipeline(prompt).images[0] | |
| ``` | |
| لتسريع التشغيلات اللاحقة، قم بتجميع الكتل المتكررة على المحوّل. أول عملية توليد بعد التجميع تكون بداية باردة وبطيئة. عمليات التوليد اللاحقة أسرع. | |
| ```py | |
| import torch | |
| from diffusers import DiffusionPipeline | |
| pipeline = DiffusionPipeline.from_pretrained( | |
| "Qwen/Qwen-Image", dtype=torch.bfloat16, device_map="cuda" # or "mps", "xpu", "cpu" | |
| ) | |
| pipeline.transformer.compile_repeated_blocks(fullgraph=True) | |
| prompt = """ | |
| cinematic film still of a cat sipping a margarita in a pool in Palm Springs, California | |
| highly detailed, high budget hollywood movie, cinemascope, moody, epic, gorgeous, film grain | |
| """ | |
| pipeline(prompt).images[0] | |
| ``` | |
| ## الخطوات التالية | |
| - [الاستدلال](./using-diffusers/loading) — خطوط الأنابيب، والتوجيه، والمُكيِّفات | |
| - [التحسين والتوسع](./stable_diffusion) — الذاكرة، السرعة، التكميم، والتقديم | |
| - [مُشتِّتات معيارية](./modular_diffusers/overview) — كتل قابلة للتركيب وخطوط أنابيب مخصصة | |
| - [التدريب والتخصيص](./training/overview) — سكربتات التدريب والمُكيِّفات | |
| - [CLI](./using-diffusers/cli) — توليد من سطر الأوامر | |
Xet Storage Details
- Size:
- 8.63 kB
- Xet hash:
- bef199aedb336c4588d4eb631ee9982ef62f775b70efe3484f0f29b2d8335a3f
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.