Buckets:

mishig's picture
download
raw
47.9 kB
<meta charset="utf-8" /><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;كيفية تشغيل Stable Diffusion باستخدام Core ML&quot;,&quot;local&quot;:&quot;how-to-run-stable-diffusion-with-core-ml&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;نقاط التفتيش لنواة Stable Diffusion&quot;,&quot;local&quot;:&quot;stable-diffusion-core-ml-checkpoints&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;اختيار متغير Core ML الذي سيتم استخدامه&quot;,&quot;local&quot;:&quot;selecting-the-core-ml-variant-to-use&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;الاستدلال باستخدام Core ML في Python&quot;,&quot;local&quot;:&quot;core-ml-inference-in-python&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;تنزيل نقاط التفتيش للنموذج&quot;,&quot;local&quot;:&quot;download-the-model-checkpoints&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;الاستدلال&quot;,&quot;local&quot;:&quot;python-inference&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2},{&quot;title&quot;:&quot;استدلال Core ML في Swift&quot;,&quot;local&quot;:&quot;core-ml-inference-in-swift&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;تنزيل&quot;,&quot;local&quot;:&quot;download&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;الاستدلال&quot;,&quot;local&quot;:&quot;swift-inference&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2},{&quot;title&quot;:&quot;الميزات المدعومة في Diffusers&quot;,&quot;local&quot;:&quot;supported-diffusers-features&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;تطبيق Diffusers الأصلي بلغة Swift&quot;,&quot;local&quot;:&quot;native-diffusers-swift-app&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2}],&quot;depth&quot;:1}"/>
<link href="/docs/diffusers/main/en/_app/immutable/entry/start.0S0_iEoG.js" rel="modulepreload">
<link href="/docs/diffusers/main/en/_app/immutable/chunks/I9eooN77.js" rel="modulepreload">
<link href="/docs/diffusers/main/en/_app/immutable/chunks/Bupkjr9f.js" rel="modulepreload">
<link href="/docs/diffusers/main/en/_app/immutable/entry/app.CPdOxCbw.js" rel="modulepreload">
<link href="/docs/diffusers/main/en/_app/immutable/chunks/CyvZ3FS5.js" rel="modulepreload">
<link href="/docs/diffusers/main/en/_app/immutable/chunks/l0QnnOED.js" rel="modulepreload">
<link href="/docs/diffusers/main/en/_app/immutable/chunks/DnVIJfC5.js" rel="modulepreload">
<link href="/docs/diffusers/main/en/_app/immutable/chunks/DsnmJJEf.js" rel="modulepreload">
<link href="/docs/diffusers/main/en/_app/immutable/nodes/0.DteTvmQZ.js" rel="modulepreload">
<link href="/docs/diffusers/main/en/_app/immutable/chunks/CoSrdQax.js" rel="modulepreload">
<link href="/docs/diffusers/main/en/_app/immutable/nodes/334.6lvvFZQx.js" rel="modulepreload">
<link href="/docs/diffusers/main/en/_app/immutable/chunks/DSPDl1gz.js" rel="modulepreload">
<!--17v8vq3--><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;How to run Stable Diffusion with Core ML&quot;,&quot;local&quot;:&quot;how-to-run-stable-diffusion-with-core-ml&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;Stable Diffusion Core ML Checkpoints&quot;,&quot;local&quot;:&quot;stable-diffusion-core-ml-checkpoints&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Selecting the Core ML Variant to Use&quot;,&quot;local&quot;:&quot;selecting-the-core-ml-variant-to-use&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Core ML Inference in Python&quot;,&quot;local&quot;:&quot;core-ml-inference-in-python&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;Download the Model Checkpoints&quot;,&quot;local&quot;:&quot;download-the-model-checkpoints&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;Inference&quot;,&quot;local&quot;:&quot;python-inference&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Core ML inference in Swift&quot;,&quot;local&quot;:&quot;core-ml-inference-in-swift&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;Download&quot;,&quot;local&quot;:&quot;download&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;Inference&quot;,&quot;local&quot;:&quot;swift-inference&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Supported Diffusers Features&quot;,&quot;local&quot;:&quot;supported-diffusers-features&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Native Diffusers Swift app&quot;,&quot;local&quot;:&quot;native-diffusers-swift-app&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2}],&quot;depth&quot;:1}"/><!---->
<link href="/docs/diffusers/main/en/_app/immutable/assets/0.tn0RQdqM.css" rel="modulepreload"> <!--[--><!--[0--><!--[--><!--[0--><!--[--><p></p> <div class="items-center shrink-0 min-w-[100px] max-sm:min-w-[50px] justify-end ml-auto flex" style="float: inline-end; margin-inline-start: 10px; display: inline-flex; position: relative; z-index: 10;"><div dir="ltr" class="inline-flex rounded-md max-sm:rounded-sm"><button class="inline-flex items-center gap-1 h-7 max-sm:h-7 px-2 max-sm:px-1.5 text-sm font-medium text-gray-800 border border-r-0 rounded-l-md max-sm:rounded-l-sm border-gray-200 bg-white hover:shadow-inner dark:border-gray-850 dark:bg-gray-950 dark:text-gray-200 dark:hover:bg-gray-800" aria-live="polite"><span class="inline-flex items-center justify-center rounded-md p-0.5 max-sm:p-0 hover:text-gray-800 dark:hover:text-gray-200"><svg class="sm:size-3.5 size-3" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----></span> <span dir="auto">Copy page</span></button> <button class="inline-flex items-center justify-center w-6 max-sm:w-5 h-7 max-sm:h-7 disabled:pointer-events-none text-sm text-gray-500 hover:text-gray-700 dark:hover:text-white rounded-r-md max-sm:rounded-r-sm border border-l transition border-gray-200 bg-white hover:shadow-inner dark:border-gray-850 dark:bg-gray-950 dark:text-gray-200 dark:hover:bg-gray-800" aria-haspopup="menu" aria-expanded="false" aria-label="Open copy menu"><svg class="transition-transform text-gray-400 overflow-visible sm:size-3.5 size-3 rotate-0" width="1em" height="1em" viewBox="0 0 12 7" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1 1L6 6L11 1" stroke="currentColor"></path></svg><!----></button></div> <!--[-1--><!--]--></div><!----> <!--[0--><h1 class="relative group"><a id="how-to-run-stable-diffusion-with-core-ml" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#how-to-run-stable-diffusion-with-core-ml"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->كيفية تشغيل Stable Diffusion باستخدام Core ML<!----></span></h1><!--]--><!----> <p><a href="https://developer.apple.com/documentation/coreml" rel="nofollow">Core ML</a> هو تنسيق النماذج ومكتبة تعلم الآلة المدعومة من أطر عمل Apple. إذا كنت مهتمًا بتشغيل نماذج Stable Diffusion داخل تطبيقات macOS أو iOS/iPadOS الخاصة بك، فستوضح لك هذه الدليل كيفية تحويل نقاط التفتيش PyTorch الموجودة مسبقًا إلى تنسيق Core ML واستخدامها للاستدلال باستخدام Python أو Swift.</p> <p>يمكن لنماذج Core ML الاستفادة من جميع محركات الحساب المتاحة في أجهزة Apple: المعالج المركزي (CPU)، ومعالج الرسوميات (GPU)، ومحرك Apple العصبي (أو ANE، وهو مُسرِّع مُحسَّن للمصفوفات متاح في أجهزة Mac المزودة بشريحة Apple Silicon وأجهزة iPhone/iPad الحديثة). اعتمادًا على النموذج والجهاز الذي يعمل عليه، يمكن لـ Core ML أيضًا مزج محركات الحساب وتبديلها، بحيث قد تعمل بعض أجزاء النموذج على المعالج المركزي بينما تعمل أجزاء أخرى على معالج الرسوميات، على سبيل المثال.</p> <blockquote class="tip"><p>يمكنك أيضاً تشغيل قاعدة أكواد بايثون الخاصة بـ<code>diffusers</code> على أجهزة Mac التي تعمل بمعالجات Apple Silicon باستخدام مُسرّع <code>mps</code> المدمج في PyTorch. يتم شرح هذا النهج بالتفصيل في <a href="mps">دليل mps</a>، لكنه غير متوافق مع التطبيقات الأصلية.</p></blockquote> <!--[1--><h2 class="relative group"><a id="stable-diffusion-core-ml-checkpoints" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#stable-diffusion-core-ml-checkpoints"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->نقاط التفتيش لنواة Stable Diffusion<!----></span></h2><!--]--><!----> <p>تُخزَّن أوزان Stable Diffusion (أو نقاط التفتيش) بتنسيق PyTorch، لذا تحتاج إلى تحويلها إلى تنسيق Core ML قبل أن نتمكن من استخدامها داخل التطبيقات الأصلية.</p> <p>لحسن الحظ، طوّر مهندسو Apple أداة تحويل <a href="https://github.com/apple/ml-stable-diffusion#-converting-models-to-core-ml" rel="nofollow">أداة تحويل</a> مبنية على <code>diffusers</code> لتحويل نقاط التفتيش الخاصة بـ PyTorch إلى Core ML.</p> <p>قبل تحويل نموذج، خذ لحظة لاستكشاف Hugging Face Hub – فمن المرجح أن النموذج الذي تهمك متوفر بالفعل بصيغة Core ML:</p> <ul><li>تشمل منظمة <a href="https://huggingface.co/apple" rel="nofollow">Apple</a> إصدارات Stable Diffusion 1.4 و1.5 و2.0 الأساسية و2.1 الأساسية</li> <li>يتضمن <a href="https://huggingface.co/coreml-community" rel="nofollow">مجتمع coreml</a> نماذج مُعدّلة خصيصًا</li> <li>استخدم هذا <a href="https://huggingface.co/models?pipeline_tag=text-to-image&amp;library=coreml&amp;p=2&amp;sort=likes" rel="nofollow">مرشّح</a> لإرجاع جميع نقاط التفتيش المتاحة لنواة Core ML</li></ul> <p>إذا لم تجد النموذج الذي تهمك، فننصحك باتباع التعليمات الخاصة بـ <a href="https://github.com/apple/ml-stable-diffusion#-converting-models-to-core-ml" rel="nofollow">تحويل النماذج إلى Core ML</a> من Apple.</p> <!--[1--><h2 class="relative group"><a id="selecting-the-core-ml-variant-to-use" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#selecting-the-core-ml-variant-to-use"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->اختيار متغير Core ML الذي سيتم استخدامه<!----></span></h2><!--]--><!----> <p>يمكن تحويل نماذج Stable Diffusion إلى متغيرات مختلفة من Core ML مخصصة لأغراض مختلفة:</p> <ul><li><p>نوع كتل الانتباه المستخدمة. تُستخدم عملية الانتباه لـ “الانتباه” إلى العلاقة بين المناطق المختلفة في تمثيلات الصورة وفهم كيفية ارتباط تمثيلات الصورة والنص. نظرًا لأن الانتباه يتطلب جهدًا حسابيًا وذاكرة كبيرة، فإن هناك تنفيذاً مختلفاً يأخذ في الاعتبار خصائص الأجهزة المختلفة. بالنسبة لنماذج Core ML Stable Diffusion، هناك نوعان من الانتباه:</p> <ul><li><code>split_einsum</code> (<a href="https://machinelearning.apple.com/research/neural-engine-transformers" rel="nofollow">الذي قدمته Apple</a>) مُحسَّن لأجهزة ANE، وهي متوفرة في أجهزة iPhone وiPad الحديثة وأجهزة سلسلة M.</li> <li>الانتباه “الأصلي” (التنفيذ الأساسي المستخدم في <code>diffusers</code>) متوافق مع CPU/GPU فقط وليس مع ANE. قد يكون تشغيل النموذج على CPU + GPU باستخدام انتباه <code>original</code> <em>أسرع</em> من استخدام ANE. راجع <a href="https://huggingface.co/blog/fast-mac-diffusers#performance-benchmarks" rel="nofollow">هذا المعيار المرجعي للأداء</a> بالإضافة إلى بعض <a href="https://github.com/huggingface/swift-coreml-diffusers/issues/31" rel="nofollow">القياسات الإضافية التي قدمتها المجتمع</a> للحصول على تفاصيل إضافية.</li></ul></li> <li><p>إطار الاستدلال المدعوم.</p> <ul><li><code>packages</code> مناسبة للاستدلال باستخدام Python. يمكن استخدام ذلك لاختبار نماذج Core ML المحوّلة قبل محاولة دمجها داخل التطبيقات الأصلية، أو إذا كنت ترغب في استكشاف أداء Core ML دون الحاجة إلى دعم التطبيقات الأصلية. على سبيل المثال، يمكن لتطبيق بواجهة مستخدم ويب أن يستخدم بشكل مثالي خلفية Core ML مبنية على Python.</li> <li>يتطلب كود Swift النماذج المُجمّعة <code>compiled</code>. تُقسّم النماذج المُجمّعة <code>compiled</code> في Hub أوزان نموذج UNet الكبير إلى عدة ملفات لضمان التوافق مع أجهزة iOS وiPadOS. يتوافق ذلك مع خيار التحويل <a href="https://github.com/apple/ml-stable-diffusion#-converting-models-to-core-ml" rel="nofollow"><code>--chunk-unet</code></a>. إذا كنت ترغب في دعم التطبيقات الأصلية، فيجب عليك اختيار النسخة <code>compiled</code>.</li></ul></li></ul> <p>تشمل <a href="https://huggingface.co/apple/coreml-stable-diffusion-v1-4/tree/main" rel="nofollow">النماذج</a> الرسمية لنموذج Core ML Stable Diffusion هذه الإصدارات، لكن قد تختلف تلك الخاصة بالمجتمع:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> تم النسخ</div><!----></button><!----></div> <pre class=" "><!---->coreml-stable-<span class="hljs-keyword">diffusion-v1-4
</span>├── README.md
├── <span class="hljs-keyword">original
</span>│ ├── compiled
│ └── packages
└── split_einsum
├── compiled
└── packages<!----></pre></div><!----> <p>يمكنك تنزيل النسخة التي تحتاجها واستخدامها كما هو موضح أدناه.</p> <!--[1--><h2 class="relative group"><a id="core-ml-inference-in-python" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#core-ml-inference-in-python"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->الاستدلال باستخدام Core ML في Python<!----></span></h2><!--]--><!----> <p>قم بتثبيت المكتبات التالية لتشغيل الاستدلال عبر Core ML في Python:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> تم النسخ</div><!----></button><!----></div> <pre class="language-bash "><!---->pip install huggingface_hub
pip install git+https://github.com/apple/ml-stable-diffusion<!----></pre></div><!----> <!--[2--><h3 class="relative group"><a id="download-the-model-checkpoints" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#download-the-model-checkpoints"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->تنزيل نقاط التفتيش للنموذج<!----></span></h3><!--]--><!----> <p>لتشغيل الاستدلال في Python، استخدم إحدى الإصدارات المخزنة في مجلدات <code>packages</code> لأن الإصدارات <code>compiled</code> متوافقة مع Swift فقط. يمكنك اختيار ما إذا كنت تريد استخدام الانتباه <code>original</code> أو <code>split_einsum</code>.</p> <p>هذه هي الطريقة التي يمكنك بها تنزيل متغير <code>original</code> للانتباه من Hub إلى مجلد يُسمى <code>models</code>:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> تم النسخ</div><!----></button><!----></div> <pre class="language-Python "><!----><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> snapshot_download
<span class="hljs-keyword">from</span> pathlib <span class="hljs-keyword">import</span> Path
repo_id = <span class="hljs-string">&quot;apple/coreml-stable-diffusion-v1-4&quot;</span>
variant = <span class="hljs-string">&quot;original/packages&quot;</span>
model_path = Path(<span class="hljs-string">&quot;./models&quot;</span>) / (repo_id.split(<span class="hljs-string">&quot;/&quot;</span>)[-<span class="hljs-number">1</span>] + <span class="hljs-string">&quot;_&quot;</span> + variant.replace(<span class="hljs-string">&quot;/&quot;</span>, <span class="hljs-string">&quot;_&quot;</span>))
snapshot_download(repo_id, allow_patterns=<span class="hljs-string">f&quot;<span class="hljs-subst">{variant}</span>/*&quot;</span>, local_dir=model_path, local_dir_use_symlinks=<span class="hljs-literal">False</span>)
<span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;Model downloaded at <span class="hljs-subst">{model_path}</span>&quot;</span>)<!----></pre></div><!----> <!--[2--><h3 class="relative group"><a id="python-inference" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#python-inference"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->الاستدلال<!----></span></h3><!--]--><!----> <p>بمجرد تنزيل لقطة من النموذج، يمكنك اختباره باستخدام سكربت بايثون الخاص بشركة Apple.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> تم النسخ</div><!----></button><!----></div> <pre class="language-shell "><!---->python -m python_coreml_stable_diffusion.pipeline --prompt &quot;a photo of an astronaut riding a horse on mars&quot; -i ./models/coreml-stable-diffusion-v1-4_original_packages/original/packages -o &lt;/path/to/output/image&gt; --compute-unit CPU_AND_GPU --seed 93<!----></pre></div><!----> <p>مرّر مسار نقطة التفتيش التي تم تنزيلها إلى السكربت باستخدام علم <code>-i</code>. يشير <code>--compute-unit</code> إلى العتاد الذي تريد السماح به للاستدلال. يجب أن يكون أحد الخيارات التالية: <code>ALL</code>، <code>CPU_AND_GPU</code>، <code>CPU_ONLY</code>، <code>CPU_AND_NE</code>. يمكنك أيضاً تقديم مسار مخرجات اختياري، وبذرة (seed) لإعادة الإنتاج.</p> <p>يفترض سكربت الاستدلال أنك تستخدم النسخة الأصلية من نموذج Stable Diffusion، <code>CompVis/stable-diffusion-v1-4</code>. إذا كنت تستخدم نموذجًا آخر، فيجب عليك <em>تحديد</em> معرّفه على Hub في سطر أوامر الاستدلال، باستخدام خيار <code>--model-version</code>. يعمل هذا مع النماذج المدعومة مسبقًا والنماذج المخصصة التي دربتها أو ضبطتها بنفسك.</p> <p>على سبيل المثال، إذا كنت ترغب في استخدام <a href="https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5" rel="nofollow"><code>stable-diffusion-v1-5/stable-diffusion-v1-5</code></a>:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> تم النسخ</div><!----></button><!----></div> <pre class="language-shell "><!---->python -m python_coreml_stable_diffusion.pipeline --prompt &quot;a photo of an astronaut riding a horse on mars&quot; --compute-unit ALL -o output --seed 93 -i models/coreml-stable-diffusion-v1-5_original_packages --model-version stable-diffusion-v1-5/stable-diffusion-v1-5<!----></pre></div><!----> <!--[1--><h2 class="relative group"><a id="core-ml-inference-in-swift" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#core-ml-inference-in-swift"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->استدلال Core ML في Swift<!----></span></h2><!--]--><!----> <p>تكون عملية الاستدلال في Swift أسرع قليلاً من Python لأن النماذج مُجمّعة مسبقًا بصيغة <code>mlmodelc</code>. يكون هذا الفرق ملحوظًا عند بدء تشغيل التطبيق عند تحميل النموذج، لكنه لا ينبغي أن يكون ملحوظًا إذا قمت بتشغيل عدة عمليات توليد بعد ذلك.</p> <!--[2--><h3 class="relative group"><a id="download" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#download"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->تنزيل<!----></span></h3><!--]--><!----> <p>لتشغيل الاستدلال بلغة Swift على جهاز Mac الخاص بك، تحتاج إلى إحدى نسخ نقاط التفتيش <code>compiled</code>. ننصحك بتنزيلها محليًا باستخدام كود Python مشابه للمثال السابق، لكن مع إحدى النسخ <code>compiled</code>:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> تم النسخ</div><!----></button><!----></div> <pre class="language-Python "><!----><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> snapshot_download
<span class="hljs-keyword">from</span> pathlib <span class="hljs-keyword">import</span> Path
repo_id = <span class="hljs-string">&quot;apple/coreml-stable-diffusion-v1-4&quot;</span>
variant = <span class="hljs-string">&quot;original/compiled&quot;</span>
model_path = Path(<span class="hljs-string">&quot;./models&quot;</span>) / (repo_id.split(<span class="hljs-string">&quot;/&quot;</span>)[-<span class="hljs-number">1</span>] + <span class="hljs-string">&quot;_&quot;</span> + variant.replace(<span class="hljs-string">&quot;/&quot;</span>, <span class="hljs-string">&quot;_&quot;</span>))
snapshot_download(repo_id, allow_patterns=<span class="hljs-string">f&quot;<span class="hljs-subst">{variant}</span>/*&quot;</span>, local_dir=model_path, local_dir_use_symlinks=<span class="hljs-literal">False</span>)
<span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;Model downloaded at <span class="hljs-subst">{model_path}</span>&quot;</span>)<!----></pre></div><!----> <!--[2--><h3 class="relative group"><a id="swift-inference" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#swift-inference"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->الاستدلال<!----></span></h3><!--]--><!----> <p>لتنفيذ الاستدلال، يرجى استنساخ مستودع Apple:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> تم النسخ</div><!----></button><!----></div> <pre class="language-bash "><!---->git <span class="hljs-built_in">clone</span> https://github.com/apple/ml-stable-diffusion
<span class="hljs-built_in">cd</span> ml-stable-diffusion<!----></pre></div><!----> <p>ثم استخدم أداة سطر الأوامر من Apple، وهي <a href="https://www.swift.org/package-manager/#" rel="nofollow">Swift Package Manager</a>:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> تم النسخ</div><!----></button><!----></div> <pre class="language-bash "><!---->swift run StableDiffusionSample --resource-path models/coreml-stable-diffusion-v1-4_original_compiled --compute-units all <span class="hljs-string">&quot;a photo of an astronaut riding a horse on mars&quot;</span><!----></pre></div><!----> <p>يجب عليك تحديد في <code>--resource-path</code> أحد نقاط التفتيش التي تم تنزيلها في الخطوة السابقة، لذا تأكد من أنه يحتوي على حزم Core ML المُجمّعة بامتداد <code>.mlmodelc</code>. ويجب أن يكون <code>--compute-units</code> أحد هذه القيم: <code>all</code>، <code>cpuOnly</code>، <code>cpuAndGPU</code>، <code>cpuAndNeuralEngine</code>.</p> <p>لمزيد من التفاصيل، يُرجى الرجوع إلى <a href="https://github.com/apple/ml-stable-diffusion" rel="nofollow">التعليمات في مستودع Apple</a>.</p> <!--[1--><h2 class="relative group"><a id="supported-diffusers-features" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#supported-diffusers-features"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->الميزات المدعومة في Diffusers<!----></span></h2><!--]--><!----> <p>لا تدعم نماذج Core ML وكود الاستدلال العديد من الميزات والخيارات والمرونة التي يوفرها 🧨 Diffusers. فيما يلي بعض القيود التي يجب وضعها في الاعتبار:</p> <ul><li>نماذج Core ML مناسبة للاستدلال فقط. لا يمكن استخدامها للتدريب أو الضبط الدقيق.</li> <li>تم نقل جدولين فقط إلى Swift، الجدول الافتراضي المستخدم في Stable Diffusion و<code>DPMSolverMultistepScheduler</code>، والذي نقلناه إلى Swift من تطبيقنا في <code>diffusers</code>. ننصحك باستخدام <code>DPMSolverMultistepScheduler</code>، لأنه ينتج الجودة نفسها في حوالي نصف عدد الخطوات.</li> <li>تتوفر الموجهات السلبية، ومقياس التوجيه الحر من التصنيف، ومهام تحويل الصورة إلى صورة في كود الاستدلال. أما الميزات المتقدمة مثل التوجيه العمق، وControlNet، ومُحسِّنات الدقة الكامنة، فليست متاحة بعد.</li></ul> <p>تُعد مستودعات <a href="https://github.com/apple/ml-stable-diffusion" rel="nofollow">التحويل والاستدلال</a> الخاصة بشركة Apple ومستودعاتنا <a href="https://github.com/huggingface/swift-coreml-diffusers" rel="nofollow">swift-coreml-diffusers</a> كعروض تقنية تهدف إلى تمكين المطورين الآخرين من البناء عليها.</p> <p>إذا كنت تشعر بأن هناك ميزات مفقودة مهمة، فلا تتردد في فتح طلب ميزة أو، بشكل أفضل، تقديم طلب مساهمة (PR) 🙂.</p> <!--[1--><h2 class="relative group"><a id="native-diffusers-swift-app" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#native-diffusers-swift-app"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->تطبيق Diffusers الأصلي بلغة Swift<!----></span></h2><!--]--><!----> <p>من السهل تشغيل Stable Diffusion على أجهزة Apple الخاصة بك باستخدام <a href="https://github.com/huggingface/swift-coreml-diffusers" rel="nofollow">مستودع Swift مفتوح المصدر الخاص بنا</a>، المبني على <code>diffusers</code> ومستودع Apple للتحويل والاستدلال. يمكنك دراسة الكود وتجميعه باستخدام <a href="https://developer.apple.com/xcode/" rel="nofollow">Xcode</a> وتكييفه حسب احتياجاتك. ولتسهيل الأمر عليك، يتوفر أيضًا <a href="https://apps.apple.com/app/diffusers/id1666309574" rel="nofollow">تطبيق Mac مستقل في App Store</a>، مما يتيح لك تجربته دون الحاجة إلى التعامل مع الكود أو بيئة التطوير المتكاملة. إذا كنت مطورًا وقد حددت أن Core ML هو الحل الأمثل لبناء تطبيق Stable Diffusion الخاص بك، فيمكنك استخدام بقية هذا الدليل للبدء في مشروعك. نتطلع بشوق لرؤية ما ستبنيه 🙂.</p> <a class="!text-gray-400 !no-underline text-sm flex items-center not-prose mt-4" href="https://github.com/huggingface/diffusers/blob/main/docs/source/en/optimization/coreml.md" target="_blank"><svg class="mr-1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M31,16l-7,7l-1.41-1.41L28.17,16l-5.58-5.59L24,9l7,7z"></path><path d="M1,16l7-7l1.41,1.41L3.83,16l5.58,5.59L8,23l-7-7z"></path><path d="M12.419,25.484L17.639,6.552l1.932,0.518L14.351,26.002z"></path></svg><!----> <span><span class="underline">Update</span> on GitHub</span></a><!----> <p></p><!--]--><!----><!--]--><!--]--><!--]--> <!--[-1--><!--]--><!--]-->
<script>
{
__sveltekit_1qsdbwf = {
base: "/docs/diffusers/main/en",
assets: "/docs/diffusers/main/en"
};
const element = document.currentScript.parentElement;
Promise.all([
import("/docs/diffusers/main/en/_app/immutable/entry/start.0S0_iEoG.js"),
import("/docs/diffusers/main/en/_app/immutable/entry/app.CPdOxCbw.js")
]).then(([kit, app]) => {
kit.start(app, element, {
node_ids: [0, 334],
data: [null,null],
form: null,
error: null
});
});
}
</script>

Xet Storage Details

Size:
47.9 kB
·
Xet hash:
b539b5a47a36d695e95158c1c18f32a594d4817c97172d1225adc66dce04b074

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