CINXE.COM

GitHub - apple/ml-stable-diffusion: Stable Diffusion with Core ML on Apple Silicon

<!DOCTYPE html> <html lang="en" data-color-mode="auto" data-light-theme="light" data-dark-theme="dark" data-a11y-animated-images="system" data-a11y-link-underlines="true" > <head> <meta charset="utf-8"> <link rel="dns-prefetch" href="https://github.githubassets.com"> <link rel="dns-prefetch" href="https://avatars.githubusercontent.com"> <link rel="dns-prefetch" href="https://github-cloud.s3.amazonaws.com"> <link rel="dns-prefetch" href="https://user-images.githubusercontent.com/"> <link rel="preconnect" href="https://github.githubassets.com" crossorigin> <link rel="preconnect" href="https://avatars.githubusercontent.com"> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/light-74231a1f3bbb.css" /><link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/dark-8a995f0bacd4.css" /><link data-color-theme="dark_dimmed" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/dark_dimmed-f37fb7684b1f.css" /><link data-color-theme="dark_high_contrast" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/dark_high_contrast-9ac301c3ebe5.css" /><link data-color-theme="dark_colorblind" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/dark_colorblind-cd826e8636dc.css" /><link data-color-theme="light_colorblind" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/light_colorblind-f91b0f603451.css" /><link data-color-theme="light_high_contrast" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/light_high_contrast-83beb16e0ecf.css" /><link data-color-theme="light_tritanopia" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/light_tritanopia-6e122dab64fc.css" /><link data-color-theme="dark_tritanopia" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/dark_tritanopia-18119e682df0.css" /> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/primer-primitives-225433424a87.css" /> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/primer-aaa714e5674d.css" /> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/global-0a3c53b9d1c2.css" /> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/github-ea73c9cb5377.css" /> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/repository-4fce88777fa8.css" /> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/code-0210be90f4d3.css" /> <script type="application/json" id="client-env">{"locale":"en","featureFlags":["copilot_immersive_issue_preview","copilot_new_references_ui","copilot_chat_repo_custom_instructions_preview","copilot_no_floating_button","copilot_topics_as_references","copilot_read_shared_conversation","copilot_duplicate_thread","copilot_buffered_streaming","dotcom_chat_client_side_skills","experimentation_azure_variant_endpoint","failbot_handle_non_errors","geojson_azure_maps","ghost_pilot_confidence_truncation_25","ghost_pilot_confidence_truncation_40","github_models_gateway_parse_params","github_models_o3_mini_streaming","insert_before_patch","issues_react_remove_placeholders","issues_react_blur_item_picker_on_close","marketing_pages_search_explore_provider","primer_react_css_modules_ga","react_data_router_pull_requests","react_override_default_key","remove_child_patch","sample_network_conn_type","swp_enterprise_contact_form","site_proxima_australia_update","viewscreen_sandbox","issues_react_create_milestone","issues_react_cache_fix_workaround","lifecycle_label_name_updates","copilot_task_oriented_assistive_prompts","issue_types_prevent_private_type_creation","refresh_image_video_src","react_router_dispose_on_disconnect","codespaces_prebuild_region_target_update","turbo_app_id_restore","copilot_code_review_sign_up_closed"]}</script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/wp-runtime-42bf55717c0c.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_oddbird_popover-polyfill_dist_popover_js-9da652f58479.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_arianotify-polyfill_ariaNotify-polyfill_js-node_modules_github_mi-3abb8f-46b9f4874d95.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/ui_packages_failbot_failbot_ts-75968cfb5298.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/environment-f04cb2a9fc8c.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_primer_behaviors_dist_esm_index_mjs-0dbb79f97f8f.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_selector-observer_dist_index_esm_js-f690fd9ae3d5.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_relative-time-element_dist_index_js-62d275b7ddd9.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_text-expander-element_dist_index_js-78748950cb0c.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_auto-complete-element_dist_index_js-node_modules_github_catalyst_-8e9f78-a90ac05d2469.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_filter-input-element_dist_index_js-node_modules_github_remote-inp-b5f1d7-a1760ffda83d.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_markdown-toolbar-element_dist_index_js-ceef33f593fa.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_file-attachment-element_dist_index_js-node_modules_primer_view-co-c44a69-efa32db3a345.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/github-elements-394f8eb34f19.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/element-registry-25113a65b77f.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_braintree_browser-detection_dist_browser-detection_js-node_modules_githu-2906d7-2a07a295af40.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_lit-html_lit-html_js-be8cb88f481b.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_mini-throttle_dist_index_js-node_modules_morphdom_dist_morphdom-e-7c534c-a4a1922eb55f.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_turbo_dist_turbo_es2017-esm_js-a03ee12d659a.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_remote-form_dist_index_js-node_modules_delegated-events_dist_inde-893f9f-b6294cf703b7.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_color-convert_index_js-e3180fe3bcb3.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_quote-selection_dist_index_js-node_modules_github_session-resume_-947061-e7a6c4a19f98.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/ui_packages_updatable-content_updatable-content_ts-eb3147a21e96.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_behaviors_task-list_ts-app_assets_modules_github_sso_ts-ui_packages-900dde-768abe60b1f8.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_sticky-scroll-into-view_ts-3e000c5d31a9.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_behaviors_ajax-error_ts-app_assets_modules_github_behaviors_include-87a4ae-4c160a67a3f8.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_behaviors_commenting_edit_ts-app_assets_modules_github_behaviors_ht-83c235-e429cff6ceb1.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/behaviors-124f4ce2c2c0.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_delegated-events_dist_index_js-node_modules_github_catalyst_lib_index_js-f6223d90c7ba.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/notifications-global-01e85cd1be94.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_virtualized-list_es_index_js-node_modules_github_template-parts_lib_index_js-94dc7a2157c1.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_remote-form_dist_index_js-node_modules_delegated-events_dist_inde-70450e-4b93df70b903.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_ref-selector_ts-3e9d848bab5f.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/codespaces-f76fb2dd7b91.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_filter-input-element_dist_index_js-node_modules_github_remote-inp-3eebbd-0763620ad7bf.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_mini-throttle_dist_decorators_js-node_modules_delegated-events_di-e161aa-9d41fb1b6c9e.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_file-attachment-element_dist_index_js-node_modules_github_remote--3c9c82-b71ef90fbdc7.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/repositories-e6e7c7ff47a3.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_mini-throttle_dist_index_js-node_modules_github_catalyst_lib_inde-dbbea9-26cce2010167.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/code-menu-1c0aedc134b1.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/primer-react-602097a4b0db.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/react-core-0bc17999cb79.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/react-lib-f1bca44e0926.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/octicons-react-cf2f2ab8dab4.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_emotion_is-prop-valid_dist_emotion-is-prop-valid_esm_js-node_modules_emo-62da9f-2df2f32ec596.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_mini-throttle_dist_index_js-node_modules_stacktrace-parser_dist_s-e7dcdd-9a233856b02c.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_oddbird_popover-polyfill_dist_popover-fn_js-55fea94174bf.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/notifications-subscriptions-menu-57956eade845.js"></script> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/primer-react.8157a56b30ae88a1b356.module.css" /> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/notifications-subscriptions-menu.1bcff9205c241e99cff2.module.css" /> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/primer-react.8157a56b30ae88a1b356.module.css" /> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/notifications-subscriptions-menu.1bcff9205c241e99cff2.module.css" /> <title>GitHub - apple/ml-stable-diffusion: Stable Diffusion with Core ML on Apple Silicon</title> <meta name="route-pattern" content="/:user_id/:repository" data-turbo-transient> <meta name="route-controller" content="files" data-turbo-transient> <meta name="route-action" content="disambiguate" data-turbo-transient> <meta name="current-catalog-service-hash" content="f3abb0cc802f3d7b95fc8762b94bdcb13bf39634c40c357301c4aa1d67a256fb"> <meta name="request-id" content="B5A0:2946B:246CE5:290814:67EBAF25" data-pjax-transient="true"/><meta name="html-safe-nonce" content="e81581b8d607f13d68ccd829f8d4980ece715c2cf8ca5dba219d0b7a462693fc" data-pjax-transient="true"/><meta name="visitor-payload" content="eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNUEwOjI5NDZCOjI0NkNFNToyOTA4MTQ6NjdFQkFGMjUiLCJ2aXNpdG9yX2lkIjoiODQxNjkwOTU3NzA3MTM0MTM0OSIsInJlZ2lvbl9lZGdlIjoic291dGhlYXN0YXNpYSIsInJlZ2lvbl9yZW5kZXIiOiJzb3V0aGVhc3Rhc2lhIn0=" data-pjax-transient="true"/><meta name="visitor-hmac" content="15c01425c36c683e1595eb42ce5dea95f8ba19d82fb8a34b18d1f21f8fe73b99" data-pjax-transient="true"/> <meta name="hovercard-subject-tag" content="repository:566576114" data-turbo-transient> <meta name="github-keyboard-shortcuts" content="repository,copilot" data-turbo-transient="true" /> <meta name="selected-link" value="repo_source" data-turbo-transient> <link rel="assets" href="https://github.githubassets.com/"> <meta name="google-site-verification" content="Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I"> <meta name="octolytics-url" content="https://collector.github.com/github/collect" /> <meta name="analytics-location" content="/&lt;user-name&gt;/&lt;repo-name&gt;" data-turbo-transient="true" /> <meta name="user-login" content=""> <meta name="viewport" content="width=device-width"> <meta name="description" content="Stable Diffusion with Core ML on Apple Silicon. Contribute to apple/ml-stable-diffusion development by creating an account on GitHub."> <link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="GitHub"> <link rel="fluid-icon" href="https://github.com/fluidicon.png" title="GitHub"> <meta property="fb:app_id" content="1401488693436528"> <meta name="apple-itunes-app" content="app-id=1477376905, app-argument=https://github.com/apple/ml-stable-diffusion" /> <meta name="twitter:image" content="https://opengraph.githubassets.com/125fcc1217bd25815041ba01468aba67f4b4946f1f0b7a887446255d592a2306/apple/ml-stable-diffusion" /><meta name="twitter:site" content="@github" /><meta name="twitter:card" content="summary_large_image" /><meta name="twitter:title" content="GitHub - apple/ml-stable-diffusion: Stable Diffusion with Core ML on Apple Silicon" /><meta name="twitter:description" content="Stable Diffusion with Core ML on Apple Silicon. Contribute to apple/ml-stable-diffusion development by creating an account on GitHub." /> <meta property="og:image" content="https://opengraph.githubassets.com/125fcc1217bd25815041ba01468aba67f4b4946f1f0b7a887446255d592a2306/apple/ml-stable-diffusion" /><meta property="og:image:alt" content="Stable Diffusion with Core ML on Apple Silicon. Contribute to apple/ml-stable-diffusion development by creating an account on GitHub." /><meta property="og:image:width" content="1200" /><meta property="og:image:height" content="600" /><meta property="og:site_name" content="GitHub" /><meta property="og:type" content="object" /><meta property="og:title" content="GitHub - apple/ml-stable-diffusion: Stable Diffusion with Core ML on Apple Silicon" /><meta property="og:url" content="https://github.com/apple/ml-stable-diffusion" /><meta property="og:description" content="Stable Diffusion with Core ML on Apple Silicon. Contribute to apple/ml-stable-diffusion development by creating an account on GitHub." /> <meta name="hostname" content="github.com"> <meta name="expected-hostname" content="github.com"> <meta http-equiv="x-pjax-version" content="fdacc214ab06f2b16bbda8409a06b74ee2890906eebb262b86ec1d832caf890a" data-turbo-track="reload"> <meta http-equiv="x-pjax-csp-version" content="e26f9f0ba624ee85cc7ac057d8faa8618a4f25a85eab052c33d018ac0f6b1a46" data-turbo-track="reload"> <meta http-equiv="x-pjax-css-version" content="159e03504eed5183f9787c72780a7d8c1460af30746ab09d728b048c41719efa" data-turbo-track="reload"> <meta http-equiv="x-pjax-js-version" content="0d9cd8178e36edfd373079ae98b19a2cf08a342e128df8f1653aa24bc094e9cf" data-turbo-track="reload"> <meta name="turbo-cache-control" content="no-preview" data-turbo-transient=""> <meta data-hydrostats="publish"> <meta name="go-import" content="github.com/apple/ml-stable-diffusion git https://github.com/apple/ml-stable-diffusion.git"> <meta name="octolytics-dimension-user_id" content="10639145" /><meta name="octolytics-dimension-user_login" content="apple" /><meta name="octolytics-dimension-repository_id" content="566576114" /><meta name="octolytics-dimension-repository_nwo" content="apple/ml-stable-diffusion" /><meta name="octolytics-dimension-repository_public" content="true" /><meta name="octolytics-dimension-repository_is_fork" content="false" /><meta name="octolytics-dimension-repository_network_root_id" content="566576114" /><meta name="octolytics-dimension-repository_network_root_nwo" content="apple/ml-stable-diffusion" /> <link rel="canonical" href="https://github.com/apple/ml-stable-diffusion" data-turbo-transient> <meta name="turbo-body-classes" content="logged-out env-production page-responsive"> <meta name="browser-stats-url" content="https://api.github.com/_private/browser/stats"> <meta name="browser-errors-url" content="https://api.github.com/_private/browser/errors"> <meta name="release" content="571ff0af2e98ca41b67a0fec323aaaef4656a2b1"> <link rel="mask-icon" href="https://github.githubassets.com/assets/pinned-octocat-093da3e6fa40.svg" color="#000000"> <link rel="alternate icon" class="js-site-favicon" type="image/png" href="https://github.githubassets.com/favicons/favicon.png"> <link rel="icon" class="js-site-favicon" type="image/svg+xml" href="https://github.githubassets.com/favicons/favicon.svg" data-base-href="https://github.githubassets.com/favicons/favicon"> <meta name="theme-color" content="#1e2327"> <meta name="color-scheme" content="light dark" /> <link rel="manifest" href="/manifest.json" crossOrigin="use-credentials"> </head> <body class="logged-out env-production page-responsive" style="word-wrap: break-word;"> <div data-turbo-body class="logged-out env-production page-responsive" style="word-wrap: break-word;"> <div class="position-relative header-wrapper js-header-wrapper "> <a href="#start-of-content" data-skip-target-assigned="false" class="px-2 py-4 color-bg-accent-emphasis color-fg-on-emphasis show-on-focus js-skip-to-content">Skip to content</a> <span data-view-component="true" class="progress-pjax-loader Progress position-fixed width-full"> <span style="width: 0%;" data-view-component="true" class="Progress-item progress-pjax-loader-bar left-0 top-0 color-bg-accent-emphasis"></span> </span> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/ui_packages_ui-commands_ui-commands_ts-2ea4e93613c0.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/keyboard-shortcuts-dialog-79d6a754ebf9.js"></script> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/primer-react.8157a56b30ae88a1b356.module.css" /> <react-partial partial-name="keyboard-shortcuts-dialog" data-ssr="false" data-attempted-ssr="false" > <script type="application/json" data-target="react-partial.embeddedData">{"props":{"docsUrl":"https://docs.github.com/get-started/accessibility/keyboard-shortcuts"}}</script> <div data-target="react-partial.reactRoot"></div> </react-partial> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_remote-form_dist_index_js-node_modules_delegated-events_dist_inde-94fd67-4898d1bf4b51.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/sessions-730dca81d0a2.js"></script> <header class="HeaderMktg header-logged-out js-details-container js-header Details f4 py-3" role="banner" data-is-top="true" data-color-mode=light data-light-theme=light data-dark-theme=dark> <h2 class="sr-only">Navigation Menu</h2> <button type="button" class="HeaderMktg-backdrop d-lg-none border-0 position-fixed top-0 left-0 width-full height-full js-details-target" aria-label="Toggle navigation"> <span class="d-none">Toggle navigation</span> </button> <div class="d-flex flex-column flex-lg-row flex-items-center px-3 px-md-4 px-lg-5 height-full position-relative z-1"> <div class="d-flex flex-justify-between flex-items-center width-full width-lg-auto"> <div class="flex-1"> <button aria-label="Toggle navigation" aria-expanded="false" type="button" data-view-component="true" class="js-details-target js-nav-padding-recalculate js-header-menu-toggle Button--link Button--medium Button d-lg-none color-fg-inherit p-1"> <span class="Button-content"> <span class="Button-label"><div class="HeaderMenu-toggle-bar rounded my-1"></div> <div class="HeaderMenu-toggle-bar rounded my-1"></div> <div class="HeaderMenu-toggle-bar rounded my-1"></div></span> </span> </button> </div> <a class="mr-lg-3 color-fg-inherit flex-order-2 js-prevent-focus-on-mobile-nav" href="/" aria-label="Homepage" data-analytics-event="{&quot;category&quot;:&quot;Marketing nav&quot;,&quot;action&quot;:&quot;click to go to homepage&quot;,&quot;label&quot;:&quot;ref_page:Marketing;ref_cta:Logomark;ref_loc:Header&quot;}"> <svg height="32" aria-hidden="true" viewBox="0 0 24 24" version="1.1" width="32" data-view-component="true" class="octicon octicon-mark-github"> <path d="M12 1C5.9225 1 1 5.9225 1 12C1 16.8675 4.14875 20.9787 8.52125 22.4362C9.07125 22.5325 9.2775 22.2025 9.2775 21.9137C9.2775 21.6525 9.26375 20.7862 9.26375 19.865C6.5 20.3737 5.785 19.1912 5.565 18.5725C5.44125 18.2562 4.905 17.28 4.4375 17.0187C4.0525 16.8125 3.5025 16.3037 4.42375 16.29C5.29 16.2762 5.90875 17.0875 6.115 17.4175C7.105 19.0812 8.68625 18.6137 9.31875 18.325C9.415 17.61 9.70375 17.1287 10.02 16.8537C7.5725 16.5787 5.015 15.63 5.015 11.4225C5.015 10.2262 5.44125 9.23625 6.1425 8.46625C6.0325 8.19125 5.6475 7.06375 6.2525 5.55125C6.2525 5.55125 7.17375 5.2625 9.2775 6.67875C10.1575 6.43125 11.0925 6.3075 12.0275 6.3075C12.9625 6.3075 13.8975 6.43125 14.7775 6.67875C16.8813 5.24875 17.8025 5.55125 17.8025 5.55125C18.4075 7.06375 18.0225 8.19125 17.9125 8.46625C18.6138 9.23625 19.04 10.2125 19.04 11.4225C19.04 15.6437 16.4688 16.5787 14.0213 16.8537C14.42 17.1975 14.7638 17.8575 14.7638 18.8887C14.7638 20.36 14.75 21.5425 14.75 21.9137C14.75 22.2025 14.9563 22.5462 15.5063 22.4362C19.8513 20.9787 23 16.8537 23 12C23 5.9225 18.0775 1 12 1Z"></path> </svg> </a> <div class="flex-1 flex-order-2 text-right"> <a href="/login?return_to=https%3A%2F%2Fgithub.com%2Fapple%2Fml-stable-diffusion" class="HeaderMenu-link HeaderMenu-button d-inline-flex d-lg-none flex-order-1 f5 no-underline border color-border-default rounded-2 px-2 py-1 color-fg-inherit js-prevent-focus-on-mobile-nav" data-hydro-click="{&quot;event_type&quot;:&quot;authentication.click&quot;,&quot;payload&quot;:{&quot;location_in_page&quot;:&quot;site header menu&quot;,&quot;repository_id&quot;:null,&quot;auth_type&quot;:&quot;SIGN_UP&quot;,&quot;originating_url&quot;:&quot;https://github.com/apple/ml-stable-diffusion&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="b73a63936f47c960275293fd24b94dbde64b9e1f5db4479240addb6322fcc2a7" data-analytics-event="{&quot;category&quot;:&quot;Marketing nav&quot;,&quot;action&quot;:&quot;click to Sign in&quot;,&quot;label&quot;:&quot;ref_page:Marketing;ref_cta:Sign in;ref_loc:Header&quot;}" > Sign in </a> </div> </div> <div class="HeaderMenu js-header-menu height-fit position-lg-relative d-lg-flex flex-column flex-auto top-0"> <div class="HeaderMenu-wrapper d-flex flex-column flex-self-start flex-lg-row flex-auto rounded rounded-lg-0"> <nav class="HeaderMenu-nav" aria-label="Global"> <ul class="d-lg-flex list-style-none"> <li class="HeaderMenu-item position-relative flex-wrap flex-justify-between flex-items-center d-block d-lg-flex flex-lg-nowrap flex-lg-items-center js-details-container js-header-menu-item"> <button type="button" class="HeaderMenu-link border-0 width-full width-lg-auto px-0 px-lg-2 py-lg-2 no-wrap d-flex flex-items-center flex-justify-between js-details-target" aria-expanded="false"> Product <svg opacity="0.5" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-chevron-down HeaderMenu-icon ml-1"> <path d="M12.78 5.22a.749.749 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.06 0L3.22 6.28a.749.749 0 1 1 1.06-1.06L8 8.939l3.72-3.719a.749.749 0 0 1 1.06 0Z"></path> </svg> </button> <div class="HeaderMenu-dropdown dropdown-menu rounded m-0 p-0 pt-2 pt-lg-4 position-relative position-lg-absolute left-0 left-lg-n3 pb-2 pb-lg-4 d-lg-flex flex-wrap dropdown-menu-wide"> <div class="HeaderMenu-column px-lg-4 border-lg-right mb-4 mb-lg-0 pr-lg-7"> <div class="border-bottom pb-3 pb-lg-0 border-lg-bottom-0"> <ul class="list-style-none f5" > <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary d-flex flex-items-center Link--has-description pb-lg-3" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;github_copilot&quot;,&quot;context&quot;:&quot;product&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;github_copilot_link_product_navbar&quot;}" href="https://github.com/features/copilot"> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-copilot color-fg-subtle mr-3"> <path d="M23.922 16.992c-.861 1.495-5.859 5.023-11.922 5.023-6.063 0-11.061-3.528-11.922-5.023A.641.641 0 0 1 0 16.736v-2.869a.841.841 0 0 1 .053-.22c.372-.935 1.347-2.292 2.605-2.656.167-.429.414-1.055.644-1.517a10.195 10.195 0 0 1-.052-1.086c0-1.331.282-2.499 1.132-3.368.397-.406.89-.717 1.474-.952 1.399-1.136 3.392-2.093 6.122-2.093 2.731 0 4.767.957 6.166 2.093.584.235 1.077.546 1.474.952.85.869 1.132 2.037 1.132 3.368 0 .368-.014.733-.052 1.086.23.462.477 1.088.644 1.517 1.258.364 2.233 1.721 2.605 2.656a.832.832 0 0 1 .053.22v2.869a.641.641 0 0 1-.078.256ZM12.172 11h-.344a4.323 4.323 0 0 1-.355.508C10.703 12.455 9.555 13 7.965 13c-1.725 0-2.989-.359-3.782-1.259a2.005 2.005 0 0 1-.085-.104L4 11.741v6.585c1.435.779 4.514 2.179 8 2.179 3.486 0 6.565-1.4 8-2.179v-6.585l-.098-.104s-.033.045-.085.104c-.793.9-2.057 1.259-3.782 1.259-1.59 0-2.738-.545-3.508-1.492a4.323 4.323 0 0 1-.355-.508h-.016.016Zm.641-2.935c.136 1.057.403 1.913.878 2.497.442.544 1.134.938 2.344.938 1.573 0 2.292-.337 2.657-.751.384-.435.558-1.15.558-2.361 0-1.14-.243-1.847-.705-2.319-.477-.488-1.319-.862-2.824-1.025-1.487-.161-2.192.138-2.533.529-.269.307-.437.808-.438 1.578v.021c0 .265.021.562.063.893Zm-1.626 0c.042-.331.063-.628.063-.894v-.02c-.001-.77-.169-1.271-.438-1.578-.341-.391-1.046-.69-2.533-.529-1.505.163-2.347.537-2.824 1.025-.462.472-.705 1.179-.705 2.319 0 1.211.175 1.926.558 2.361.365.414 1.084.751 2.657.751 1.21 0 1.902-.394 2.344-.938.475-.584.742-1.44.878-2.497Z"></path><path d="M14.5 14.25a1 1 0 0 1 1 1v2a1 1 0 0 1-2 0v-2a1 1 0 0 1 1-1Zm-5 0a1 1 0 0 1 1 1v2a1 1 0 0 1-2 0v-2a1 1 0 0 1 1-1Z"></path> </svg> <div> <div class="color-fg-default h4">GitHub Copilot</div> Write better code with AI </div> </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary d-flex flex-items-center Link--has-description pb-lg-3" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;security&quot;,&quot;context&quot;:&quot;product&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;security_link_product_navbar&quot;}" href="https://github.com/features/security"> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-shield-check color-fg-subtle mr-3"> <path d="M16.53 9.78a.75.75 0 0 0-1.06-1.06L11 13.19l-1.97-1.97a.75.75 0 0 0-1.06 1.06l2.5 2.5a.75.75 0 0 0 1.06 0l5-5Z"></path><path d="m12.54.637 8.25 2.675A1.75 1.75 0 0 1 22 4.976V10c0 6.19-3.771 10.704-9.401 12.83a1.704 1.704 0 0 1-1.198 0C5.77 20.705 2 16.19 2 10V4.976c0-.758.489-1.43 1.21-1.664L11.46.637a1.748 1.748 0 0 1 1.08 0Zm-.617 1.426-8.25 2.676a.249.249 0 0 0-.173.237V10c0 5.46 3.28 9.483 8.43 11.426a.199.199 0 0 0 .14 0C17.22 19.483 20.5 15.461 20.5 10V4.976a.25.25 0 0 0-.173-.237l-8.25-2.676a.253.253 0 0 0-.154 0Z"></path> </svg> <div> <div class="color-fg-default h4">Security</div> Find and fix vulnerabilities </div> </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary d-flex flex-items-center Link--has-description pb-lg-3" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;actions&quot;,&quot;context&quot;:&quot;product&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;actions_link_product_navbar&quot;}" href="https://github.com/features/actions"> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-workflow color-fg-subtle mr-3"> <path d="M1 3a2 2 0 0 1 2-2h6.5a2 2 0 0 1 2 2v6.5a2 2 0 0 1-2 2H7v4.063C7 16.355 7.644 17 8.438 17H12.5v-2.5a2 2 0 0 1 2-2H21a2 2 0 0 1 2 2V21a2 2 0 0 1-2 2h-6.5a2 2 0 0 1-2-2v-2.5H8.437A2.939 2.939 0 0 1 5.5 15.562V11.5H3a2 2 0 0 1-2-2Zm2-.5a.5.5 0 0 0-.5.5v6.5a.5.5 0 0 0 .5.5h6.5a.5.5 0 0 0 .5-.5V3a.5.5 0 0 0-.5-.5ZM14.5 14a.5.5 0 0 0-.5.5V21a.5.5 0 0 0 .5.5H21a.5.5 0 0 0 .5-.5v-6.5a.5.5 0 0 0-.5-.5Z"></path> </svg> <div> <div class="color-fg-default h4">Actions</div> Automate any workflow </div> </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary d-flex flex-items-center Link--has-description pb-lg-3" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;codespaces&quot;,&quot;context&quot;:&quot;product&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;codespaces_link_product_navbar&quot;}" href="https://github.com/features/codespaces"> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-codespaces color-fg-subtle mr-3"> <path d="M3.5 3.75C3.5 2.784 4.284 2 5.25 2h13.5c.966 0 1.75.784 1.75 1.75v7.5A1.75 1.75 0 0 1 18.75 13H5.25a1.75 1.75 0 0 1-1.75-1.75Zm-2 12c0-.966.784-1.75 1.75-1.75h17.5c.966 0 1.75.784 1.75 1.75v4a1.75 1.75 0 0 1-1.75 1.75H3.25a1.75 1.75 0 0 1-1.75-1.75ZM5.25 3.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h13.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Zm-2 12a.25.25 0 0 0-.25.25v4c0 .138.112.25.25.25h17.5a.25.25 0 0 0 .25-.25v-4a.25.25 0 0 0-.25-.25Z"></path><path d="M10 17.75a.75.75 0 0 1 .75-.75h6.5a.75.75 0 0 1 0 1.5h-6.5a.75.75 0 0 1-.75-.75Zm-4 0a.75.75 0 0 1 .75-.75h.5a.75.75 0 0 1 0 1.5h-.5a.75.75 0 0 1-.75-.75Z"></path> </svg> <div> <div class="color-fg-default h4">Codespaces</div> Instant dev environments </div> </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary d-flex flex-items-center Link--has-description pb-lg-3" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;issues&quot;,&quot;context&quot;:&quot;product&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;issues_link_product_navbar&quot;}" href="https://github.com/features/issues"> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-issue-opened color-fg-subtle mr-3"> <path d="M12 1c6.075 0 11 4.925 11 11s-4.925 11-11 11S1 18.075 1 12 5.925 1 12 1ZM2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5 9.5 9.5 0 0 0 2.5 12Zm9.5 2a2 2 0 1 1-.001-3.999A2 2 0 0 1 12 14Z"></path> </svg> <div> <div class="color-fg-default h4">Issues</div> Plan and track work </div> </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary d-flex flex-items-center Link--has-description pb-lg-3" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;code_review&quot;,&quot;context&quot;:&quot;product&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;code_review_link_product_navbar&quot;}" href="https://github.com/features/code-review"> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-code-review color-fg-subtle mr-3"> <path d="M10.3 6.74a.75.75 0 0 1-.04 1.06l-2.908 2.7 2.908 2.7a.75.75 0 1 1-1.02 1.1l-3.5-3.25a.75.75 0 0 1 0-1.1l3.5-3.25a.75.75 0 0 1 1.06.04Zm3.44 1.06a.75.75 0 1 1 1.02-1.1l3.5 3.25a.75.75 0 0 1 0 1.1l-3.5 3.25a.75.75 0 1 1-1.02-1.1l2.908-2.7-2.908-2.7Z"></path><path d="M1.5 4.25c0-.966.784-1.75 1.75-1.75h17.5c.966 0 1.75.784 1.75 1.75v12.5a1.75 1.75 0 0 1-1.75 1.75h-9.69l-3.573 3.573A1.458 1.458 0 0 1 5 21.043V18.5H3.25a1.75 1.75 0 0 1-1.75-1.75ZM3.25 4a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h2.5a.75.75 0 0 1 .75.75v3.19l3.72-3.72a.749.749 0 0 1 .53-.22h10a.25.25 0 0 0 .25-.25V4.25a.25.25 0 0 0-.25-.25Z"></path> </svg> <div> <div class="color-fg-default h4">Code Review</div> Manage code changes </div> </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary d-flex flex-items-center Link--has-description pb-lg-3" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;discussions&quot;,&quot;context&quot;:&quot;product&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;discussions_link_product_navbar&quot;}" href="https://github.com/features/discussions"> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-comment-discussion color-fg-subtle mr-3"> <path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"></path><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"></path> </svg> <div> <div class="color-fg-default h4">Discussions</div> Collaborate outside of code </div> </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary d-flex flex-items-center Link--has-description" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;code_search&quot;,&quot;context&quot;:&quot;product&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;code_search_link_product_navbar&quot;}" href="https://github.com/features/code-search"> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-code-square color-fg-subtle mr-3"> <path d="M10.3 8.24a.75.75 0 0 1-.04 1.06L7.352 12l2.908 2.7a.75.75 0 1 1-1.02 1.1l-3.5-3.25a.75.75 0 0 1 0-1.1l3.5-3.25a.75.75 0 0 1 1.06.04Zm3.44 1.06a.75.75 0 1 1 1.02-1.1l3.5 3.25a.75.75 0 0 1 0 1.1l-3.5 3.25a.75.75 0 1 1-1.02-1.1l2.908-2.7-2.908-2.7Z"></path><path d="M2 3.75C2 2.784 2.784 2 3.75 2h16.5c.966 0 1.75.784 1.75 1.75v16.5A1.75 1.75 0 0 1 20.25 22H3.75A1.75 1.75 0 0 1 2 20.25Zm1.75-.25a.25.25 0 0 0-.25.25v16.5c0 .138.112.25.25.25h16.5a.25.25 0 0 0 .25-.25V3.75a.25.25 0 0 0-.25-.25Z"></path> </svg> <div> <div class="color-fg-default h4">Code Search</div> Find more, search less </div> </a></li> </ul> </div> </div> <div class="HeaderMenu-column px-lg-4"> <div class="border-bottom pb-3 pb-lg-0 border-lg-bottom-0 border-bottom-0"> <span class="d-block h4 color-fg-default my-1" id="product-explore-heading">Explore</span> <ul class="list-style-none f5" aria-labelledby="product-explore-heading"> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;all_features&quot;,&quot;context&quot;:&quot;product&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;all_features_link_product_navbar&quot;}" href="https://github.com/features"> All features </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary Link--external" target="_blank" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;documentation&quot;,&quot;context&quot;:&quot;product&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;documentation_link_product_navbar&quot;}" href="https://docs.github.com"> Documentation <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-link-external HeaderMenu-external-icon color-fg-subtle"> <path d="M3.75 2h3.5a.75.75 0 0 1 0 1.5h-3.5a.25.25 0 0 0-.25.25v8.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25v-3.5a.75.75 0 0 1 1.5 0v3.5A1.75 1.75 0 0 1 12.25 14h-8.5A1.75 1.75 0 0 1 2 12.25v-8.5C2 2.784 2.784 2 3.75 2Zm6.854-1h4.146a.25.25 0 0 1 .25.25v4.146a.25.25 0 0 1-.427.177L13.03 4.03 9.28 7.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.75-3.75-1.543-1.543A.25.25 0 0 1 10.604 1Z"></path> </svg> </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary Link--external" target="_blank" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;github_skills&quot;,&quot;context&quot;:&quot;product&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;github_skills_link_product_navbar&quot;}" href="https://skills.github.com"> GitHub Skills <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-link-external HeaderMenu-external-icon color-fg-subtle"> <path d="M3.75 2h3.5a.75.75 0 0 1 0 1.5h-3.5a.25.25 0 0 0-.25.25v8.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25v-3.5a.75.75 0 0 1 1.5 0v3.5A1.75 1.75 0 0 1 12.25 14h-8.5A1.75 1.75 0 0 1 2 12.25v-8.5C2 2.784 2.784 2 3.75 2Zm6.854-1h4.146a.25.25 0 0 1 .25.25v4.146a.25.25 0 0 1-.427.177L13.03 4.03 9.28 7.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.75-3.75-1.543-1.543A.25.25 0 0 1 10.604 1Z"></path> </svg> </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary Link--external" target="_blank" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;blog&quot;,&quot;context&quot;:&quot;product&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;blog_link_product_navbar&quot;}" href="https://github.blog"> Blog <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-link-external HeaderMenu-external-icon color-fg-subtle"> <path d="M3.75 2h3.5a.75.75 0 0 1 0 1.5h-3.5a.25.25 0 0 0-.25.25v8.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25v-3.5a.75.75 0 0 1 1.5 0v3.5A1.75 1.75 0 0 1 12.25 14h-8.5A1.75 1.75 0 0 1 2 12.25v-8.5C2 2.784 2.784 2 3.75 2Zm6.854-1h4.146a.25.25 0 0 1 .25.25v4.146a.25.25 0 0 1-.427.177L13.03 4.03 9.28 7.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.75-3.75-1.543-1.543A.25.25 0 0 1 10.604 1Z"></path> </svg> </a></li> </ul> </div> </div> </div> </li> <li class="HeaderMenu-item position-relative flex-wrap flex-justify-between flex-items-center d-block d-lg-flex flex-lg-nowrap flex-lg-items-center js-details-container js-header-menu-item"> <button type="button" class="HeaderMenu-link border-0 width-full width-lg-auto px-0 px-lg-2 py-lg-2 no-wrap d-flex flex-items-center flex-justify-between js-details-target" aria-expanded="false"> Solutions <svg opacity="0.5" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-chevron-down HeaderMenu-icon ml-1"> <path d="M12.78 5.22a.749.749 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.06 0L3.22 6.28a.749.749 0 1 1 1.06-1.06L8 8.939l3.72-3.719a.749.749 0 0 1 1.06 0Z"></path> </svg> </button> <div class="HeaderMenu-dropdown dropdown-menu rounded m-0 p-0 pt-2 pt-lg-4 position-relative position-lg-absolute left-0 left-lg-n3 d-lg-flex flex-wrap dropdown-menu-wide"> <div class="HeaderMenu-column px-lg-4 border-lg-right mb-4 mb-lg-0 pr-lg-7"> <div class="border-bottom pb-3 pb-lg-0 border-lg-bottom-0 pb-lg-3 mb-3 mb-lg-0"> <span class="d-block h4 color-fg-default my-1" id="solutions-by-company-size-heading">By company size</span> <ul class="list-style-none f5" aria-labelledby="solutions-by-company-size-heading"> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;enterprises&quot;,&quot;context&quot;:&quot;solutions&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;enterprises_link_solutions_navbar&quot;}" href="https://github.com/enterprise"> Enterprises </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;small_and_medium_teams&quot;,&quot;context&quot;:&quot;solutions&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;small_and_medium_teams_link_solutions_navbar&quot;}" href="https://github.com/team"> Small and medium teams </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;startups&quot;,&quot;context&quot;:&quot;solutions&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;startups_link_solutions_navbar&quot;}" href="https://github.com/enterprise/startups"> Startups </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;nonprofits&quot;,&quot;context&quot;:&quot;solutions&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;nonprofits_link_solutions_navbar&quot;}" href="/solutions/industry/nonprofits"> Nonprofits </a></li> </ul> </div> <div class="border-bottom pb-3 pb-lg-0 border-lg-bottom-0"> <span class="d-block h4 color-fg-default my-1" id="solutions-by-use-case-heading">By use case</span> <ul class="list-style-none f5" aria-labelledby="solutions-by-use-case-heading"> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;devsecops&quot;,&quot;context&quot;:&quot;solutions&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;devsecops_link_solutions_navbar&quot;}" href="/solutions/use-case/devsecops"> DevSecOps </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;devops&quot;,&quot;context&quot;:&quot;solutions&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;devops_link_solutions_navbar&quot;}" href="/solutions/use-case/devops"> DevOps </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;ci_cd&quot;,&quot;context&quot;:&quot;solutions&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;ci_cd_link_solutions_navbar&quot;}" href="/solutions/use-case/ci-cd"> CI/CD </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;view_all_use_cases&quot;,&quot;context&quot;:&quot;solutions&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;view_all_use_cases_link_solutions_navbar&quot;}" href="/solutions/use-case"> View all use cases </a></li> </ul> </div> </div> <div class="HeaderMenu-column px-lg-4"> <div class="border-bottom pb-3 pb-lg-0 border-lg-bottom-0"> <span class="d-block h4 color-fg-default my-1" id="solutions-by-industry-heading">By industry</span> <ul class="list-style-none f5" aria-labelledby="solutions-by-industry-heading"> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;healthcare&quot;,&quot;context&quot;:&quot;solutions&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;healthcare_link_solutions_navbar&quot;}" href="/solutions/industry/healthcare"> Healthcare </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;financial_services&quot;,&quot;context&quot;:&quot;solutions&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;financial_services_link_solutions_navbar&quot;}" href="/solutions/industry/financial-services"> Financial services </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;manufacturing&quot;,&quot;context&quot;:&quot;solutions&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;manufacturing_link_solutions_navbar&quot;}" href="/solutions/industry/manufacturing"> Manufacturing </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;government&quot;,&quot;context&quot;:&quot;solutions&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;government_link_solutions_navbar&quot;}" href="/solutions/industry/government"> Government </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;view_all_industries&quot;,&quot;context&quot;:&quot;solutions&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;view_all_industries_link_solutions_navbar&quot;}" href="/solutions/industry"> View all industries </a></li> </ul> </div> </div> <div class="HeaderMenu-trailing-link rounded-bottom-2 flex-shrink-0 mt-lg-4 px-lg-4 py-4 py-lg-3 f5 text-semibold"> <a href="/solutions"> View all solutions <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-chevron-right HeaderMenu-trailing-link-icon"> <path d="M6.22 3.22a.75.75 0 0 1 1.06 0l4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L9.94 8 6.22 4.28a.75.75 0 0 1 0-1.06Z"></path> </svg> </a> </div> </div> </li> <li class="HeaderMenu-item position-relative flex-wrap flex-justify-between flex-items-center d-block d-lg-flex flex-lg-nowrap flex-lg-items-center js-details-container js-header-menu-item"> <button type="button" class="HeaderMenu-link border-0 width-full width-lg-auto px-0 px-lg-2 py-lg-2 no-wrap d-flex flex-items-center flex-justify-between js-details-target" aria-expanded="false"> Resources <svg opacity="0.5" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-chevron-down HeaderMenu-icon ml-1"> <path d="M12.78 5.22a.749.749 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.06 0L3.22 6.28a.749.749 0 1 1 1.06-1.06L8 8.939l3.72-3.719a.749.749 0 0 1 1.06 0Z"></path> </svg> </button> <div class="HeaderMenu-dropdown dropdown-menu rounded m-0 p-0 pt-2 pt-lg-4 position-relative position-lg-absolute left-0 left-lg-n3 pb-2 pb-lg-4 d-lg-flex flex-wrap dropdown-menu-wide"> <div class="HeaderMenu-column px-lg-4 border-lg-right mb-4 mb-lg-0 pr-lg-7"> <div class="border-bottom pb-3 pb-lg-0 border-lg-bottom-0"> <span class="d-block h4 color-fg-default my-1" id="resources-topics-heading">Topics</span> <ul class="list-style-none f5" aria-labelledby="resources-topics-heading"> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;ai&quot;,&quot;context&quot;:&quot;resources&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;ai_link_resources_navbar&quot;}" href="/resources/articles/ai"> AI </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;devops&quot;,&quot;context&quot;:&quot;resources&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;devops_link_resources_navbar&quot;}" href="/resources/articles/devops"> DevOps </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;security&quot;,&quot;context&quot;:&quot;resources&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;security_link_resources_navbar&quot;}" href="/resources/articles/security"> Security </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;software_development&quot;,&quot;context&quot;:&quot;resources&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;software_development_link_resources_navbar&quot;}" href="/resources/articles/software-development"> Software Development </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;view_all&quot;,&quot;context&quot;:&quot;resources&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;view_all_link_resources_navbar&quot;}" href="/resources/articles"> View all </a></li> </ul> </div> </div> <div class="HeaderMenu-column px-lg-4"> <div class="border-bottom pb-3 pb-lg-0 border-lg-bottom-0 border-bottom-0"> <span class="d-block h4 color-fg-default my-1" id="resources-explore-heading">Explore</span> <ul class="list-style-none f5" aria-labelledby="resources-explore-heading"> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary Link--external" target="_blank" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;learning_pathways&quot;,&quot;context&quot;:&quot;resources&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;learning_pathways_link_resources_navbar&quot;}" href="https://resources.github.com/learn/pathways"> Learning Pathways <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-link-external HeaderMenu-external-icon color-fg-subtle"> <path d="M3.75 2h3.5a.75.75 0 0 1 0 1.5h-3.5a.25.25 0 0 0-.25.25v8.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25v-3.5a.75.75 0 0 1 1.5 0v3.5A1.75 1.75 0 0 1 12.25 14h-8.5A1.75 1.75 0 0 1 2 12.25v-8.5C2 2.784 2.784 2 3.75 2Zm6.854-1h4.146a.25.25 0 0 1 .25.25v4.146a.25.25 0 0 1-.427.177L13.03 4.03 9.28 7.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.75-3.75-1.543-1.543A.25.25 0 0 1 10.604 1Z"></path> </svg> </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary Link--external" target="_blank" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;events_amp_webinars&quot;,&quot;context&quot;:&quot;resources&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;events_amp_webinars_link_resources_navbar&quot;}" href="https://resources.github.com"> Events &amp; Webinars <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-link-external HeaderMenu-external-icon color-fg-subtle"> <path d="M3.75 2h3.5a.75.75 0 0 1 0 1.5h-3.5a.25.25 0 0 0-.25.25v8.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25v-3.5a.75.75 0 0 1 1.5 0v3.5A1.75 1.75 0 0 1 12.25 14h-8.5A1.75 1.75 0 0 1 2 12.25v-8.5C2 2.784 2.784 2 3.75 2Zm6.854-1h4.146a.25.25 0 0 1 .25.25v4.146a.25.25 0 0 1-.427.177L13.03 4.03 9.28 7.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.75-3.75-1.543-1.543A.25.25 0 0 1 10.604 1Z"></path> </svg> </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;ebooks_amp_whitepapers&quot;,&quot;context&quot;:&quot;resources&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;ebooks_amp_whitepapers_link_resources_navbar&quot;}" href="https://github.com/resources/whitepapers"> Ebooks &amp; Whitepapers </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;customer_stories&quot;,&quot;context&quot;:&quot;resources&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;customer_stories_link_resources_navbar&quot;}" href="https://github.com/customer-stories"> Customer Stories </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary Link--external" target="_blank" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;partners&quot;,&quot;context&quot;:&quot;resources&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;partners_link_resources_navbar&quot;}" href="https://partner.github.com"> Partners <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-link-external HeaderMenu-external-icon color-fg-subtle"> <path d="M3.75 2h3.5a.75.75 0 0 1 0 1.5h-3.5a.25.25 0 0 0-.25.25v8.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25v-3.5a.75.75 0 0 1 1.5 0v3.5A1.75 1.75 0 0 1 12.25 14h-8.5A1.75 1.75 0 0 1 2 12.25v-8.5C2 2.784 2.784 2 3.75 2Zm6.854-1h4.146a.25.25 0 0 1 .25.25v4.146a.25.25 0 0 1-.427.177L13.03 4.03 9.28 7.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.75-3.75-1.543-1.543A.25.25 0 0 1 10.604 1Z"></path> </svg> </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;executive_insights&quot;,&quot;context&quot;:&quot;resources&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;executive_insights_link_resources_navbar&quot;}" href="https://github.com/solutions/executive-insights"> Executive Insights </a></li> </ul> </div> </div> </div> </li> <li class="HeaderMenu-item position-relative flex-wrap flex-justify-between flex-items-center d-block d-lg-flex flex-lg-nowrap flex-lg-items-center js-details-container js-header-menu-item"> <button type="button" class="HeaderMenu-link border-0 width-full width-lg-auto px-0 px-lg-2 py-lg-2 no-wrap d-flex flex-items-center flex-justify-between js-details-target" aria-expanded="false"> Open Source <svg opacity="0.5" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-chevron-down HeaderMenu-icon ml-1"> <path d="M12.78 5.22a.749.749 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.06 0L3.22 6.28a.749.749 0 1 1 1.06-1.06L8 8.939l3.72-3.719a.749.749 0 0 1 1.06 0Z"></path> </svg> </button> <div class="HeaderMenu-dropdown dropdown-menu rounded m-0 p-0 pt-2 pt-lg-4 position-relative position-lg-absolute left-0 left-lg-n3 pb-2 pb-lg-4 px-lg-4"> <div class="HeaderMenu-column"> <div class="border-bottom pb-3 pb-lg-0 pb-lg-3 mb-3 mb-lg-0 mb-lg-3"> <ul class="list-style-none f5" > <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary d-flex flex-items-center Link--has-description" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;github_sponsors&quot;,&quot;context&quot;:&quot;open_source&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;github_sponsors_link_open_source_navbar&quot;}" href="/sponsors"> <div> <div class="color-fg-default h4">GitHub Sponsors</div> Fund open source developers </div> </a></li> </ul> </div> <div class="border-bottom pb-3 pb-lg-0 pb-lg-3 mb-3 mb-lg-0 mb-lg-3"> <ul class="list-style-none f5" > <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary d-flex flex-items-center Link--has-description" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;the_readme_project&quot;,&quot;context&quot;:&quot;open_source&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;the_readme_project_link_open_source_navbar&quot;}" href="https://github.com/readme"> <div> <div class="color-fg-default h4">The ReadME Project</div> GitHub community articles </div> </a></li> </ul> </div> <div class="border-bottom pb-3 pb-lg-0 border-bottom-0"> <span class="d-block h4 color-fg-default my-1" id="open-source-repositories-heading">Repositories</span> <ul class="list-style-none f5" aria-labelledby="open-source-repositories-heading"> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;topics&quot;,&quot;context&quot;:&quot;open_source&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;topics_link_open_source_navbar&quot;}" href="https://github.com/topics"> Topics </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;trending&quot;,&quot;context&quot;:&quot;open_source&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;trending_link_open_source_navbar&quot;}" href="https://github.com/trending"> Trending </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;collections&quot;,&quot;context&quot;:&quot;open_source&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;collections_link_open_source_navbar&quot;}" href="https://github.com/collections"> Collections </a></li> </ul> </div> </div> </div> </li> <li class="HeaderMenu-item position-relative flex-wrap flex-justify-between flex-items-center d-block d-lg-flex flex-lg-nowrap flex-lg-items-center js-details-container js-header-menu-item"> <button type="button" class="HeaderMenu-link border-0 width-full width-lg-auto px-0 px-lg-2 py-lg-2 no-wrap d-flex flex-items-center flex-justify-between js-details-target" aria-expanded="false"> Enterprise <svg opacity="0.5" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-chevron-down HeaderMenu-icon ml-1"> <path d="M12.78 5.22a.749.749 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.06 0L3.22 6.28a.749.749 0 1 1 1.06-1.06L8 8.939l3.72-3.719a.749.749 0 0 1 1.06 0Z"></path> </svg> </button> <div class="HeaderMenu-dropdown dropdown-menu rounded m-0 p-0 pt-2 pt-lg-4 position-relative position-lg-absolute left-0 left-lg-n3 pb-2 pb-lg-4 px-lg-4"> <div class="HeaderMenu-column"> <div class="border-bottom pb-3 pb-lg-0 pb-lg-3 mb-3 mb-lg-0 mb-lg-3"> <ul class="list-style-none f5" > <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary d-flex flex-items-center Link--has-description" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;enterprise_platform&quot;,&quot;context&quot;:&quot;enterprise&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;enterprise_platform_link_enterprise_navbar&quot;}" href="/enterprise"> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-stack color-fg-subtle mr-3"> <path d="M11.063 1.456a1.749 1.749 0 0 1 1.874 0l8.383 5.316a1.751 1.751 0 0 1 0 2.956l-8.383 5.316a1.749 1.749 0 0 1-1.874 0L2.68 9.728a1.751 1.751 0 0 1 0-2.956Zm1.071 1.267a.25.25 0 0 0-.268 0L3.483 8.039a.25.25 0 0 0 0 .422l8.383 5.316a.25.25 0 0 0 .268 0l8.383-5.316a.25.25 0 0 0 0-.422Z"></path><path d="M1.867 12.324a.75.75 0 0 1 1.035-.232l8.964 5.685a.25.25 0 0 0 .268 0l8.964-5.685a.75.75 0 0 1 .804 1.267l-8.965 5.685a1.749 1.749 0 0 1-1.874 0l-8.965-5.685a.75.75 0 0 1-.231-1.035Z"></path><path d="M1.867 16.324a.75.75 0 0 1 1.035-.232l8.964 5.685a.25.25 0 0 0 .268 0l8.964-5.685a.75.75 0 0 1 .804 1.267l-8.965 5.685a1.749 1.749 0 0 1-1.874 0l-8.965-5.685a.75.75 0 0 1-.231-1.035Z"></path> </svg> <div> <div class="color-fg-default h4">Enterprise platform</div> AI-powered developer platform </div> </a></li> </ul> </div> <div class="border-bottom pb-3 pb-lg-0 border-bottom-0"> <span class="d-block h4 color-fg-default my-1" id="enterprise-available-add-ons-heading">Available add-ons</span> <ul class="list-style-none f5" aria-labelledby="enterprise-available-add-ons-heading"> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary d-flex flex-items-center Link--has-description pb-lg-3" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;advanced_security&quot;,&quot;context&quot;:&quot;enterprise&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;advanced_security_link_enterprise_navbar&quot;}" href="https://github.com/enterprise/advanced-security"> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-shield-check color-fg-subtle mr-3"> <path d="M16.53 9.78a.75.75 0 0 0-1.06-1.06L11 13.19l-1.97-1.97a.75.75 0 0 0-1.06 1.06l2.5 2.5a.75.75 0 0 0 1.06 0l5-5Z"></path><path d="m12.54.637 8.25 2.675A1.75 1.75 0 0 1 22 4.976V10c0 6.19-3.771 10.704-9.401 12.83a1.704 1.704 0 0 1-1.198 0C5.77 20.705 2 16.19 2 10V4.976c0-.758.489-1.43 1.21-1.664L11.46.637a1.748 1.748 0 0 1 1.08 0Zm-.617 1.426-8.25 2.676a.249.249 0 0 0-.173.237V10c0 5.46 3.28 9.483 8.43 11.426a.199.199 0 0 0 .14 0C17.22 19.483 20.5 15.461 20.5 10V4.976a.25.25 0 0 0-.173-.237l-8.25-2.676a.253.253 0 0 0-.154 0Z"></path> </svg> <div> <div class="color-fg-default h4">Advanced Security</div> Enterprise-grade security features </div> </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary d-flex flex-items-center Link--has-description pb-lg-3" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;copilot_for_business&quot;,&quot;context&quot;:&quot;enterprise&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;copilot_for_business_link_enterprise_navbar&quot;}" href="/features/copilot/copilot-business"> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-copilot color-fg-subtle mr-3"> <path d="M23.922 16.992c-.861 1.495-5.859 5.023-11.922 5.023-6.063 0-11.061-3.528-11.922-5.023A.641.641 0 0 1 0 16.736v-2.869a.841.841 0 0 1 .053-.22c.372-.935 1.347-2.292 2.605-2.656.167-.429.414-1.055.644-1.517a10.195 10.195 0 0 1-.052-1.086c0-1.331.282-2.499 1.132-3.368.397-.406.89-.717 1.474-.952 1.399-1.136 3.392-2.093 6.122-2.093 2.731 0 4.767.957 6.166 2.093.584.235 1.077.546 1.474.952.85.869 1.132 2.037 1.132 3.368 0 .368-.014.733-.052 1.086.23.462.477 1.088.644 1.517 1.258.364 2.233 1.721 2.605 2.656a.832.832 0 0 1 .053.22v2.869a.641.641 0 0 1-.078.256ZM12.172 11h-.344a4.323 4.323 0 0 1-.355.508C10.703 12.455 9.555 13 7.965 13c-1.725 0-2.989-.359-3.782-1.259a2.005 2.005 0 0 1-.085-.104L4 11.741v6.585c1.435.779 4.514 2.179 8 2.179 3.486 0 6.565-1.4 8-2.179v-6.585l-.098-.104s-.033.045-.085.104c-.793.9-2.057 1.259-3.782 1.259-1.59 0-2.738-.545-3.508-1.492a4.323 4.323 0 0 1-.355-.508h-.016.016Zm.641-2.935c.136 1.057.403 1.913.878 2.497.442.544 1.134.938 2.344.938 1.573 0 2.292-.337 2.657-.751.384-.435.558-1.15.558-2.361 0-1.14-.243-1.847-.705-2.319-.477-.488-1.319-.862-2.824-1.025-1.487-.161-2.192.138-2.533.529-.269.307-.437.808-.438 1.578v.021c0 .265.021.562.063.893Zm-1.626 0c.042-.331.063-.628.063-.894v-.02c-.001-.77-.169-1.271-.438-1.578-.341-.391-1.046-.69-2.533-.529-1.505.163-2.347.537-2.824 1.025-.462.472-.705 1.179-.705 2.319 0 1.211.175 1.926.558 2.361.365.414 1.084.751 2.657.751 1.21 0 1.902-.394 2.344-.938.475-.584.742-1.44.878-2.497Z"></path><path d="M14.5 14.25a1 1 0 0 1 1 1v2a1 1 0 0 1-2 0v-2a1 1 0 0 1 1-1Zm-5 0a1 1 0 0 1 1 1v2a1 1 0 0 1-2 0v-2a1 1 0 0 1 1-1Z"></path> </svg> <div> <div class="color-fg-default h4">Copilot for business</div> Enterprise-grade AI features </div> </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary d-flex flex-items-center Link--has-description" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;premium_support&quot;,&quot;context&quot;:&quot;enterprise&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;premium_support_link_enterprise_navbar&quot;}" href="/premium-support"> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-comment-discussion color-fg-subtle mr-3"> <path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"></path><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"></path> </svg> <div> <div class="color-fg-default h4">Premium Support</div> Enterprise-grade 24/7 support </div> </a></li> </ul> </div> </div> </div> </li> <li class="HeaderMenu-item position-relative flex-wrap flex-justify-between flex-items-center d-block d-lg-flex flex-lg-nowrap flex-lg-items-center js-details-container js-header-menu-item"> <a class="HeaderMenu-link no-underline px-0 px-lg-2 py-3 py-lg-2 d-block d-lg-inline-block" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;pricing&quot;,&quot;context&quot;:&quot;global&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;pricing_link_global_navbar&quot;}" href="https://github.com/pricing">Pricing</a> </li> </ul> </nav> <div class="d-flex flex-column flex-lg-row width-full flex-justify-end flex-lg-items-center text-center mt-3 mt-lg-0 text-lg-left ml-lg-3"> <qbsearch-input class="search-input" data-scope="repo:apple/ml-stable-diffusion" data-custom-scopes-path="/search/custom_scopes" data-delete-custom-scopes-csrf="kM8xdoe-TY9TttnGEkMYBx2gaDIXTO7d1okVsELgxdUuIifOrl6bHU8YwtslkgeCz4_q2SWy7ACYshEHUThwAw" data-max-custom-scopes="10" data-header-redesign-enabled="false" data-initial-value="" data-blackbird-suggestions-path="/search/suggestions" data-jump-to-suggestions-path="/_graphql/GetSuggestedNavigationDestinations" data-current-repository="apple/ml-stable-diffusion" data-current-org="apple" data-current-owner="" data-logged-in="false" data-copilot-chat-enabled="false" data-nl-search-enabled="false" data-retain-scroll-position="true"> <div class="search-input-container search-with-dialog position-relative d-flex flex-row flex-items-center mr-4 rounded" data-action="click:qbsearch-input#searchInputContainerClicked" > <button type="button" class="header-search-button placeholder input-button form-control d-flex flex-1 flex-self-stretch flex-items-center no-wrap width-full py-0 pl-2 pr-0 text-left border-0 box-shadow-none" data-target="qbsearch-input.inputButton" aria-label="Search or jump to…" aria-haspopup="dialog" placeholder="Search or jump to..." data-hotkey=s,/ autocapitalize="off" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;searchbar&quot;,&quot;context&quot;:&quot;global&quot;,&quot;tag&quot;:&quot;input&quot;,&quot;label&quot;:&quot;searchbar_input_global_navbar&quot;}" data-action="click:qbsearch-input#handleExpand" > <div class="mr-2 color-fg-muted"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path> </svg> </div> <span class="flex-1" data-target="qbsearch-input.inputButtonText">Search or jump to...</span> <div class="d-flex" data-target="qbsearch-input.hotkeyIndicator"> <svg xmlns="http://www.w3.org/2000/svg" width="22" height="20" aria-hidden="true" class="mr-1"><path fill="none" stroke="#979A9C" opacity=".4" d="M3.5.5h12c1.7 0 3 1.3 3 3v13c0 1.7-1.3 3-3 3h-12c-1.7 0-3-1.3-3-3v-13c0-1.7 1.3-3 3-3z"></path><path fill="#979A9C" d="M11.8 6L8 15.1h-.9L10.8 6h1z"></path></svg> </div> </button> <input type="hidden" name="type" class="js-site-search-type-field"> <div class="Overlay--hidden " data-modal-dialog-overlay> <modal-dialog data-action="close:qbsearch-input#handleClose cancel:qbsearch-input#handleClose" data-target="qbsearch-input.searchSuggestionsDialog" role="dialog" id="search-suggestions-dialog" aria-modal="true" aria-labelledby="search-suggestions-dialog-header" data-view-component="true" class="Overlay Overlay--width-large Overlay--height-auto"> <h1 id="search-suggestions-dialog-header" class="sr-only">Search code, repositories, users, issues, pull requests...</h1> <div class="Overlay-body Overlay-body--paddingNone"> <div data-view-component="true"> <div class="search-suggestions position-fixed width-full color-shadow-large border color-fg-default color-bg-default overflow-hidden d-flex flex-column query-builder-container" style="border-radius: 12px;" data-target="qbsearch-input.queryBuilderContainer" hidden > <!-- '"` --><!-- </textarea></xmp> --></option></form><form id="query-builder-test-form" action="" accept-charset="UTF-8" method="get"> <query-builder data-target="qbsearch-input.queryBuilder" id="query-builder-query-builder-test" data-filter-key=":" data-view-component="true" class="QueryBuilder search-query-builder"> <div class="FormControl FormControl--fullWidth"> <label id="query-builder-test-label" for="query-builder-test" class="FormControl-label sr-only"> Search </label> <div class="QueryBuilder-StyledInput width-fit " data-target="query-builder.styledInput" > <span id="query-builder-test-leadingvisual-wrap" class="FormControl-input-leadingVisualWrap QueryBuilder-leadingVisualWrap"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search FormControl-input-leadingVisual"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path> </svg> </span> <div data-target="query-builder.styledInputContainer" class="QueryBuilder-StyledInputContainer"> <div aria-hidden="true" class="QueryBuilder-StyledInputContent" data-target="query-builder.styledInputContent" ></div> <div class="QueryBuilder-InputWrapper"> <div aria-hidden="true" class="QueryBuilder-Sizer" data-target="query-builder.sizer"></div> <input id="query-builder-test" name="query-builder-test" value="" autocomplete="off" type="text" role="combobox" spellcheck="false" aria-expanded="false" aria-describedby="validation-44692740-13ca-4843-ba56-9c412e9f6e44" data-target="query-builder.input" data-action=" input:query-builder#inputChange blur:query-builder#inputBlur keydown:query-builder#inputKeydown focus:query-builder#inputFocus " data-view-component="true" class="FormControl-input QueryBuilder-Input FormControl-medium" /> </div> </div> <span class="sr-only" id="query-builder-test-clear">Clear</span> <button role="button" id="query-builder-test-clear-button" aria-labelledby="query-builder-test-clear query-builder-test-label" data-target="query-builder.clearButton" data-action=" click:query-builder#clear focus:query-builder#clearButtonFocus blur:query-builder#clearButtonBlur " variant="small" hidden="hidden" type="button" data-view-component="true" class="Button Button--iconOnly Button--invisible Button--medium mr-1 px-2 py-0 d-flex flex-items-center rounded-1 color-fg-muted"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x-circle-fill Button-visual"> <path d="M2.343 13.657A8 8 0 1 1 13.658 2.343 8 8 0 0 1 2.343 13.657ZM6.03 4.97a.751.751 0 0 0-1.042.018.751.751 0 0 0-.018 1.042L6.94 8 4.97 9.97a.749.749 0 0 0 .326 1.275.749.749 0 0 0 .734-.215L8 9.06l1.97 1.97a.749.749 0 0 0 1.275-.326.749.749 0 0 0-.215-.734L9.06 8l1.97-1.97a.749.749 0 0 0-.326-1.275.749.749 0 0 0-.734.215L8 6.94Z"></path> </svg> </button> </div> <template id="search-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path> </svg> </template> <template id="code-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-code"> <path d="m11.28 3.22 4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L13.94 8l-3.72-3.72a.749.749 0 0 1 .326-1.275.749.749 0 0 1 .734.215Zm-6.56 0a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042L2.06 8l3.72 3.72a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L.47 8.53a.75.75 0 0 1 0-1.06Z"></path> </svg> </template> <template id="file-code-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file-code"> <path d="M4 1.75C4 .784 4.784 0 5.75 0h5.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v8.586A1.75 1.75 0 0 1 14.25 15h-9a.75.75 0 0 1 0-1.5h9a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 10 4.25V1.5H5.75a.25.25 0 0 0-.25.25v2.5a.75.75 0 0 1-1.5 0Zm1.72 4.97a.75.75 0 0 1 1.06 0l2 2a.75.75 0 0 1 0 1.06l-2 2a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734l1.47-1.47-1.47-1.47a.75.75 0 0 1 0-1.06ZM3.28 7.78 1.81 9.25l1.47 1.47a.751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018l-2-2a.75.75 0 0 1 0-1.06l2-2a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042Zm8.22-6.218V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path> </svg> </template> <template id="history-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-history"> <path d="m.427 1.927 1.215 1.215a8.002 8.002 0 1 1-1.6 5.685.75.75 0 1 1 1.493-.154 6.5 6.5 0 1 0 1.18-4.458l1.358 1.358A.25.25 0 0 1 3.896 6H.25A.25.25 0 0 1 0 5.75V2.104a.25.25 0 0 1 .427-.177ZM7.75 4a.75.75 0 0 1 .75.75v2.992l2.028.812a.75.75 0 0 1-.557 1.392l-2.5-1A.751.751 0 0 1 7 8.25v-3.5A.75.75 0 0 1 7.75 4Z"></path> </svg> </template> <template id="repo-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path> </svg> </template> <template id="bookmark-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-bookmark"> <path d="M3 2.75C3 1.784 3.784 1 4.75 1h6.5c.966 0 1.75.784 1.75 1.75v11.5a.75.75 0 0 1-1.227.579L8 11.722l-3.773 3.107A.751.751 0 0 1 3 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v9.91l3.023-2.489a.75.75 0 0 1 .954 0l3.023 2.49V2.75a.25.25 0 0 0-.25-.25Z"></path> </svg> </template> <template id="plus-circle-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-plus-circle"> <path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm7.25-3.25v2.5h2.5a.75.75 0 0 1 0 1.5h-2.5v2.5a.75.75 0 0 1-1.5 0v-2.5h-2.5a.75.75 0 0 1 0-1.5h2.5v-2.5a.75.75 0 0 1 1.5 0Z"></path> </svg> </template> <template id="circle-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-dot-fill"> <path d="M8 4a4 4 0 1 1 0 8 4 4 0 0 1 0-8Z"></path> </svg> </template> <template id="trash-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-trash"> <path d="M11 1.75V3h2.25a.75.75 0 0 1 0 1.5H2.75a.75.75 0 0 1 0-1.5H5V1.75C5 .784 5.784 0 6.75 0h2.5C10.216 0 11 .784 11 1.75ZM4.496 6.675l.66 6.6a.25.25 0 0 0 .249.225h5.19a.25.25 0 0 0 .249-.225l.66-6.6a.75.75 0 0 1 1.492.149l-.66 6.6A1.748 1.748 0 0 1 10.595 15h-5.19a1.75 1.75 0 0 1-1.741-1.575l-.66-6.6a.75.75 0 1 1 1.492-.15ZM6.5 1.75V3h3V1.75a.25.25 0 0 0-.25-.25h-2.5a.25.25 0 0 0-.25.25Z"></path> </svg> </template> <template id="team-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-people"> <path d="M2 5.5a3.5 3.5 0 1 1 5.898 2.549 5.508 5.508 0 0 1 3.034 4.084.75.75 0 1 1-1.482.235 4 4 0 0 0-7.9 0 .75.75 0 0 1-1.482-.236A5.507 5.507 0 0 1 3.102 8.05 3.493 3.493 0 0 1 2 5.5ZM11 4a3.001 3.001 0 0 1 2.22 5.018 5.01 5.01 0 0 1 2.56 3.012.749.749 0 0 1-.885.954.752.752 0 0 1-.549-.514 3.507 3.507 0 0 0-2.522-2.372.75.75 0 0 1-.574-.73v-.352a.75.75 0 0 1 .416-.672A1.5 1.5 0 0 0 11 5.5.75.75 0 0 1 11 4Zm-5.5-.5a2 2 0 1 0-.001 3.999A2 2 0 0 0 5.5 3.5Z"></path> </svg> </template> <template id="project-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path> </svg> </template> <template id="pencil-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-pencil"> <path d="M11.013 1.427a1.75 1.75 0 0 1 2.474 0l1.086 1.086a1.75 1.75 0 0 1 0 2.474l-8.61 8.61c-.21.21-.47.364-.756.445l-3.251.93a.75.75 0 0 1-.927-.928l.929-3.25c.081-.286.235-.547.445-.758l8.61-8.61Zm.176 4.823L9.75 4.81l-6.286 6.287a.253.253 0 0 0-.064.108l-.558 1.953 1.953-.558a.253.253 0 0 0 .108-.064Zm1.238-3.763a.25.25 0 0 0-.354 0L10.811 3.75l1.439 1.44 1.263-1.263a.25.25 0 0 0 0-.354Z"></path> </svg> </template> <template id="copilot-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-copilot"> <path d="M7.998 15.035c-4.562 0-7.873-2.914-7.998-3.749V9.338c.085-.628.677-1.686 1.588-2.065.013-.07.024-.143.036-.218.029-.183.06-.384.126-.612-.201-.508-.254-1.084-.254-1.656 0-.87.128-1.769.693-2.484.579-.733 1.494-1.124 2.724-1.261 1.206-.134 2.262.034 2.944.765.05.053.096.108.139.165.044-.057.094-.112.143-.165.682-.731 1.738-.899 2.944-.765 1.23.137 2.145.528 2.724 1.261.566.715.693 1.614.693 2.484 0 .572-.053 1.148-.254 1.656.066.228.098.429.126.612.012.076.024.148.037.218.924.385 1.522 1.471 1.591 2.095v1.872c0 .766-3.351 3.795-8.002 3.795Zm0-1.485c2.28 0 4.584-1.11 5.002-1.433V7.862l-.023-.116c-.49.21-1.075.291-1.727.291-1.146 0-2.059-.327-2.71-.991A3.222 3.222 0 0 1 8 6.303a3.24 3.24 0 0 1-.544.743c-.65.664-1.563.991-2.71.991-.652 0-1.236-.081-1.727-.291l-.023.116v4.255c.419.323 2.722 1.433 5.002 1.433ZM6.762 2.83c-.193-.206-.637-.413-1.682-.297-1.019.113-1.479.404-1.713.7-.247.312-.369.789-.369 1.554 0 .793.129 1.171.308 1.371.162.181.519.379 1.442.379.853 0 1.339-.235 1.638-.54.315-.322.527-.827.617-1.553.117-.935-.037-1.395-.241-1.614Zm4.155-.297c-1.044-.116-1.488.091-1.681.297-.204.219-.359.679-.242 1.614.091.726.303 1.231.618 1.553.299.305.784.54 1.638.54.922 0 1.28-.198 1.442-.379.179-.2.308-.578.308-1.371 0-.765-.123-1.242-.37-1.554-.233-.296-.693-.587-1.713-.7Z"></path><path d="M6.25 9.037a.75.75 0 0 1 .75.75v1.501a.75.75 0 0 1-1.5 0V9.787a.75.75 0 0 1 .75-.75Zm4.25.75v1.501a.75.75 0 0 1-1.5 0V9.787a.75.75 0 0 1 1.5 0Z"></path> </svg> </template> <template id="copilot-error-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-copilot-error"> <path d="M16 11.24c0 .112-.072.274-.21.467L13 9.688V7.862l-.023-.116c-.49.21-1.075.291-1.727.291-.198 0-.388-.009-.571-.029L6.833 5.226a4.01 4.01 0 0 0 .17-.782c.117-.935-.037-1.395-.241-1.614-.193-.206-.637-.413-1.682-.297-.683.076-1.115.231-1.395.415l-1.257-.91c.579-.564 1.413-.877 2.485-.996 1.206-.134 2.262.034 2.944.765.05.053.096.108.139.165.044-.057.094-.112.143-.165.682-.731 1.738-.899 2.944-.765 1.23.137 2.145.528 2.724 1.261.566.715.693 1.614.693 2.484 0 .572-.053 1.148-.254 1.656.066.228.098.429.126.612.012.076.024.148.037.218.924.385 1.522 1.471 1.591 2.095Zm-5.083-8.707c-1.044-.116-1.488.091-1.681.297-.204.219-.359.679-.242 1.614.091.726.303 1.231.618 1.553.299.305.784.54 1.638.54.922 0 1.28-.198 1.442-.379.179-.2.308-.578.308-1.371 0-.765-.123-1.242-.37-1.554-.233-.296-.693-.587-1.713-.7Zm2.511 11.074c-1.393.776-3.272 1.428-5.43 1.428-4.562 0-7.873-2.914-7.998-3.749V9.338c.085-.628.677-1.686 1.588-2.065.013-.07.024-.143.036-.218.029-.183.06-.384.126-.612-.18-.455-.241-.963-.252-1.475L.31 4.107A.747.747 0 0 1 0 3.509V3.49a.748.748 0 0 1 .625-.73c.156-.026.306.047.435.139l14.667 10.578a.592.592 0 0 1 .227.264.752.752 0 0 1 .046.249v.022a.75.75 0 0 1-1.19.596Zm-1.367-.991L5.635 7.964a5.128 5.128 0 0 1-.889.073c-.652 0-1.236-.081-1.727-.291l-.023.116v4.255c.419.323 2.722 1.433 5.002 1.433 1.539 0 3.089-.505 4.063-.934Z"></path> </svg> </template> <template id="workflow-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-workflow"> <path d="M0 1.75C0 .784.784 0 1.75 0h3.5C6.216 0 7 .784 7 1.75v3.5A1.75 1.75 0 0 1 5.25 7H4v4a1 1 0 0 0 1 1h4v-1.25C9 9.784 9.784 9 10.75 9h3.5c.966 0 1.75.784 1.75 1.75v3.5A1.75 1.75 0 0 1 14.25 16h-3.5A1.75 1.75 0 0 1 9 14.25v-.75H5A2.5 2.5 0 0 1 2.5 11V7h-.75A1.75 1.75 0 0 1 0 5.25Zm1.75-.25a.25.25 0 0 0-.25.25v3.5c0 .138.112.25.25.25h3.5a.25.25 0 0 0 .25-.25v-3.5a.25.25 0 0 0-.25-.25Zm9 9a.25.25 0 0 0-.25.25v3.5c0 .138.112.25.25.25h3.5a.25.25 0 0 0 .25-.25v-3.5a.25.25 0 0 0-.25-.25Z"></path> </svg> </template> <template id="book-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-book"> <path d="M0 1.75A.75.75 0 0 1 .75 1h4.253c1.227 0 2.317.59 3 1.501A3.743 3.743 0 0 1 11.006 1h4.245a.75.75 0 0 1 .75.75v10.5a.75.75 0 0 1-.75.75h-4.507a2.25 2.25 0 0 0-1.591.659l-.622.621a.75.75 0 0 1-1.06 0l-.622-.621A2.25 2.25 0 0 0 5.258 13H.75a.75.75 0 0 1-.75-.75Zm7.251 10.324.004-5.073-.002-2.253A2.25 2.25 0 0 0 5.003 2.5H1.5v9h3.757a3.75 3.75 0 0 1 1.994.574ZM8.755 4.75l-.004 7.322a3.752 3.752 0 0 1 1.992-.572H14.5v-9h-3.495a2.25 2.25 0 0 0-2.25 2.25Z"></path> </svg> </template> <template id="code-review-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-code-review"> <path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v8.5A1.75 1.75 0 0 1 14.25 13H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 14.543V13H1.75A1.75 1.75 0 0 1 0 11.25v-8.5C0 1.784.784 1 1.75 1ZM1.5 2.75v8.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-8.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Zm5.28 1.72a.75.75 0 0 1 0 1.06L5.31 7l1.47 1.47a.751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018l-2-2a.75.75 0 0 1 0-1.06l2-2a.75.75 0 0 1 1.06 0Zm2.44 0a.75.75 0 0 1 1.06 0l2 2a.75.75 0 0 1 0 1.06l-2 2a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L10.69 7 9.22 5.53a.75.75 0 0 1 0-1.06Z"></path> </svg> </template> <template id="codespaces-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-codespaces"> <path d="M0 11.25c0-.966.784-1.75 1.75-1.75h12.5c.966 0 1.75.784 1.75 1.75v3A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25Zm2-9.5C2 .784 2.784 0 3.75 0h8.5C13.216 0 14 .784 14 1.75v5a1.75 1.75 0 0 1-1.75 1.75h-8.5A1.75 1.75 0 0 1 2 6.75Zm1.75-.25a.25.25 0 0 0-.25.25v5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25v-5a.25.25 0 0 0-.25-.25Zm-2 9.5a.25.25 0 0 0-.25.25v3c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25v-3a.25.25 0 0 0-.25-.25Z"></path><path d="M7 12.75a.75.75 0 0 1 .75-.75h4.5a.75.75 0 0 1 0 1.5h-4.5a.75.75 0 0 1-.75-.75Zm-4 0a.75.75 0 0 1 .75-.75h.5a.75.75 0 0 1 0 1.5h-.5a.75.75 0 0 1-.75-.75Z"></path> </svg> </template> <template id="comment-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-comment"> <path d="M1 2.75C1 1.784 1.784 1 2.75 1h10.5c.966 0 1.75.784 1.75 1.75v7.5A1.75 1.75 0 0 1 13.25 12H9.06l-2.573 2.573A1.458 1.458 0 0 1 4 13.543V12H2.75A1.75 1.75 0 0 1 1 10.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h4.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z"></path> </svg> </template> <template id="comment-discussion-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-comment-discussion"> <path d="M1.75 1h8.5c.966 0 1.75.784 1.75 1.75v5.5A1.75 1.75 0 0 1 10.25 10H7.061l-2.574 2.573A1.458 1.458 0 0 1 2 11.543V10h-.25A1.75 1.75 0 0 1 0 8.25v-5.5C0 1.784.784 1 1.75 1ZM1.5 2.75v5.5c0 .138.112.25.25.25h1a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h3.5a.25.25 0 0 0 .25-.25v-5.5a.25.25 0 0 0-.25-.25h-8.5a.25.25 0 0 0-.25.25Zm13 2a.25.25 0 0 0-.25-.25h-.5a.75.75 0 0 1 0-1.5h.5c.966 0 1.75.784 1.75 1.75v5.5A1.75 1.75 0 0 1 14.25 12H14v1.543a1.458 1.458 0 0 1-2.487 1.03L9.22 12.28a.749.749 0 0 1 .326-1.275.749.749 0 0 1 .734.215l2.22 2.22v-2.19a.75.75 0 0 1 .75-.75h1a.25.25 0 0 0 .25-.25Z"></path> </svg> </template> <template id="organization-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-organization"> <path d="M1.75 16A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0h8.5C11.216 0 12 .784 12 1.75v12.5c0 .085-.006.168-.018.25h2.268a.25.25 0 0 0 .25-.25V8.285a.25.25 0 0 0-.111-.208l-1.055-.703a.749.749 0 1 1 .832-1.248l1.055.703c.487.325.779.871.779 1.456v5.965A1.75 1.75 0 0 1 14.25 16h-3.5a.766.766 0 0 1-.197-.026c-.099.017-.2.026-.303.026h-3a.75.75 0 0 1-.75-.75V14h-1v1.25a.75.75 0 0 1-.75.75Zm-.25-1.75c0 .138.112.25.25.25H4v-1.25a.75.75 0 0 1 .75-.75h2.5a.75.75 0 0 1 .75.75v1.25h2.25a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25h-8.5a.25.25 0 0 0-.25.25ZM3.75 6h.5a.75.75 0 0 1 0 1.5h-.5a.75.75 0 0 1 0-1.5ZM3 3.75A.75.75 0 0 1 3.75 3h.5a.75.75 0 0 1 0 1.5h-.5A.75.75 0 0 1 3 3.75Zm4 3A.75.75 0 0 1 7.75 6h.5a.75.75 0 0 1 0 1.5h-.5A.75.75 0 0 1 7 6.75ZM7.75 3h.5a.75.75 0 0 1 0 1.5h-.5a.75.75 0 0 1 0-1.5ZM3 9.75A.75.75 0 0 1 3.75 9h.5a.75.75 0 0 1 0 1.5h-.5A.75.75 0 0 1 3 9.75ZM7.75 9h.5a.75.75 0 0 1 0 1.5h-.5a.75.75 0 0 1 0-1.5Z"></path> </svg> </template> <template id="rocket-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-rocket"> <path d="M14.064 0h.186C15.216 0 16 .784 16 1.75v.186a8.752 8.752 0 0 1-2.564 6.186l-.458.459c-.314.314-.641.616-.979.904v3.207c0 .608-.315 1.172-.833 1.49l-2.774 1.707a.749.749 0 0 1-1.11-.418l-.954-3.102a1.214 1.214 0 0 1-.145-.125L3.754 9.816a1.218 1.218 0 0 1-.124-.145L.528 8.717a.749.749 0 0 1-.418-1.11l1.71-2.774A1.748 1.748 0 0 1 3.31 4h3.204c.288-.338.59-.665.904-.979l.459-.458A8.749 8.749 0 0 1 14.064 0ZM8.938 3.623h-.002l-.458.458c-.76.76-1.437 1.598-2.02 2.5l-1.5 2.317 2.143 2.143 2.317-1.5c.902-.583 1.74-1.26 2.499-2.02l.459-.458a7.25 7.25 0 0 0 2.123-5.127V1.75a.25.25 0 0 0-.25-.25h-.186a7.249 7.249 0 0 0-5.125 2.123ZM3.56 14.56c-.732.732-2.334 1.045-3.005 1.148a.234.234 0 0 1-.201-.064.234.234 0 0 1-.064-.201c.103-.671.416-2.273 1.15-3.003a1.502 1.502 0 1 1 2.12 2.12Zm6.94-3.935c-.088.06-.177.118-.266.175l-2.35 1.521.548 1.783 1.949-1.2a.25.25 0 0 0 .119-.213ZM3.678 8.116 5.2 5.766c.058-.09.117-.178.176-.266H3.309a.25.25 0 0 0-.213.119l-1.2 1.95ZM12 5a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path> </svg> </template> <template id="shield-check-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-shield-check"> <path d="m8.533.133 5.25 1.68A1.75 1.75 0 0 1 15 3.48V7c0 1.566-.32 3.182-1.303 4.682-.983 1.498-2.585 2.813-5.032 3.855a1.697 1.697 0 0 1-1.33 0c-2.447-1.042-4.049-2.357-5.032-3.855C1.32 10.182 1 8.566 1 7V3.48a1.75 1.75 0 0 1 1.217-1.667l5.25-1.68a1.748 1.748 0 0 1 1.066 0Zm-.61 1.429.001.001-5.25 1.68a.251.251 0 0 0-.174.237V7c0 1.36.275 2.666 1.057 3.859.784 1.194 2.121 2.342 4.366 3.298a.196.196 0 0 0 .154 0c2.245-.957 3.582-2.103 4.366-3.297C13.225 9.666 13.5 8.358 13.5 7V3.48a.25.25 0 0 0-.174-.238l-5.25-1.68a.25.25 0 0 0-.153 0ZM11.28 6.28l-3.5 3.5a.75.75 0 0 1-1.06 0l-1.5-1.5a.749.749 0 0 1 .326-1.275.749.749 0 0 1 .734.215l.97.97 2.97-2.97a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042Z"></path> </svg> </template> <template id="heart-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-heart"> <path d="m8 14.25.345.666a.75.75 0 0 1-.69 0l-.008-.004-.018-.01a7.152 7.152 0 0 1-.31-.17 22.055 22.055 0 0 1-3.434-2.414C2.045 10.731 0 8.35 0 5.5 0 2.836 2.086 1 4.25 1 5.797 1 7.153 1.802 8 3.02 8.847 1.802 10.203 1 11.75 1 13.914 1 16 2.836 16 5.5c0 2.85-2.045 5.231-3.885 6.818a22.066 22.066 0 0 1-3.744 2.584l-.018.01-.006.003h-.002ZM4.25 2.5c-1.336 0-2.75 1.164-2.75 3 0 2.15 1.58 4.144 3.365 5.682A20.58 20.58 0 0 0 8 13.393a20.58 20.58 0 0 0 3.135-2.211C12.92 9.644 14.5 7.65 14.5 5.5c0-1.836-1.414-3-2.75-3-1.373 0-2.609.986-3.029 2.456a.749.749 0 0 1-1.442 0C6.859 3.486 5.623 2.5 4.25 2.5Z"></path> </svg> </template> <template id="server-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-server"> <path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v4c0 .372-.116.717-.314 1 .198.283.314.628.314 1v4a1.75 1.75 0 0 1-1.75 1.75H1.75A1.75 1.75 0 0 1 0 12.75v-4c0-.358.109-.707.314-1a1.739 1.739 0 0 1-.314-1v-4C0 1.784.784 1 1.75 1ZM1.5 2.75v4c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25v-4a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Zm.25 5.75a.25.25 0 0 0-.25.25v4c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25v-4a.25.25 0 0 0-.25-.25ZM7 4.75A.75.75 0 0 1 7.75 4h4.5a.75.75 0 0 1 0 1.5h-4.5A.75.75 0 0 1 7 4.75ZM7.75 10h4.5a.75.75 0 0 1 0 1.5h-4.5a.75.75 0 0 1 0-1.5ZM3 4.75A.75.75 0 0 1 3.75 4h.5a.75.75 0 0 1 0 1.5h-.5A.75.75 0 0 1 3 4.75ZM3.75 10h.5a.75.75 0 0 1 0 1.5h-.5a.75.75 0 0 1 0-1.5Z"></path> </svg> </template> <template id="globe-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-globe"> <path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM5.78 8.75a9.64 9.64 0 0 0 1.363 4.177c.255.426.542.832.857 1.215.245-.296.551-.705.857-1.215A9.64 9.64 0 0 0 10.22 8.75Zm4.44-1.5a9.64 9.64 0 0 0-1.363-4.177c-.307-.51-.612-.919-.857-1.215a9.927 9.927 0 0 0-.857 1.215A9.64 9.64 0 0 0 5.78 7.25Zm-5.944 1.5H1.543a6.507 6.507 0 0 0 4.666 5.5c-.123-.181-.24-.365-.352-.552-.715-1.192-1.437-2.874-1.581-4.948Zm-2.733-1.5h2.733c.144-2.074.866-3.756 1.58-4.948.12-.197.237-.381.353-.552a6.507 6.507 0 0 0-4.666 5.5Zm10.181 1.5c-.144 2.074-.866 3.756-1.58 4.948-.12.197-.237.381-.353.552a6.507 6.507 0 0 0 4.666-5.5Zm2.733-1.5a6.507 6.507 0 0 0-4.666-5.5c.123.181.24.365.353.552.714 1.192 1.436 2.874 1.58 4.948Z"></path> </svg> </template> <template id="issue-opened-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-issue-opened"> <path d="M8 9.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z"></path><path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Z"></path> </svg> </template> <template id="device-mobile-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-device-mobile"> <path d="M3.75 0h8.5C13.216 0 14 .784 14 1.75v12.5A1.75 1.75 0 0 1 12.25 16h-8.5A1.75 1.75 0 0 1 2 14.25V1.75C2 .784 2.784 0 3.75 0ZM3.5 1.75v12.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25h-8.5a.25.25 0 0 0-.25.25ZM8 13a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"></path> </svg> </template> <template id="package-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-package"> <path d="m8.878.392 5.25 3.045c.54.314.872.89.872 1.514v6.098a1.75 1.75 0 0 1-.872 1.514l-5.25 3.045a1.75 1.75 0 0 1-1.756 0l-5.25-3.045A1.75 1.75 0 0 1 1 11.049V4.951c0-.624.332-1.201.872-1.514L7.122.392a1.75 1.75 0 0 1 1.756 0ZM7.875 1.69l-4.63 2.685L8 7.133l4.755-2.758-4.63-2.685a.248.248 0 0 0-.25 0ZM2.5 5.677v5.372c0 .09.047.171.125.216l4.625 2.683V8.432Zm6.25 8.271 4.625-2.683a.25.25 0 0 0 .125-.216V5.677L8.75 8.432Z"></path> </svg> </template> <template id="credit-card-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-credit-card"> <path d="M10.75 9a.75.75 0 0 0 0 1.5h1.5a.75.75 0 0 0 0-1.5h-1.5Z"></path><path d="M0 3.75C0 2.784.784 2 1.75 2h12.5c.966 0 1.75.784 1.75 1.75v8.5A1.75 1.75 0 0 1 14.25 14H1.75A1.75 1.75 0 0 1 0 12.25ZM14.5 6.5h-13v5.75c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25Zm0-2.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25V5h13Z"></path> </svg> </template> <template id="play-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-play"> <path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm4.879-2.773 4.264 2.559a.25.25 0 0 1 0 .428l-4.264 2.559A.25.25 0 0 1 6 10.559V5.442a.25.25 0 0 1 .379-.215Z"></path> </svg> </template> <template id="gift-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-gift"> <path d="M2 2.75A2.75 2.75 0 0 1 4.75 0c.983 0 1.873.42 2.57 1.232.268.318.497.668.68 1.042.183-.375.411-.725.68-1.044C9.376.42 10.266 0 11.25 0a2.75 2.75 0 0 1 2.45 4h.55c.966 0 1.75.784 1.75 1.75v2c0 .698-.409 1.301-1 1.582v4.918A1.75 1.75 0 0 1 13.25 16H2.75A1.75 1.75 0 0 1 1 14.25V9.332C.409 9.05 0 8.448 0 7.75v-2C0 4.784.784 4 1.75 4h.55c-.192-.375-.3-.8-.3-1.25ZM7.25 9.5H2.5v4.75c0 .138.112.25.25.25h4.5Zm1.5 0v5h4.5a.25.25 0 0 0 .25-.25V9.5Zm0-4V8h5.5a.25.25 0 0 0 .25-.25v-2a.25.25 0 0 0-.25-.25Zm-7 0a.25.25 0 0 0-.25.25v2c0 .138.112.25.25.25h5.5V5.5h-5.5Zm3-4a1.25 1.25 0 0 0 0 2.5h2.309c-.233-.818-.542-1.401-.878-1.793-.43-.502-.915-.707-1.431-.707ZM8.941 4h2.309a1.25 1.25 0 0 0 0-2.5c-.516 0-1 .205-1.43.707-.337.392-.646.975-.879 1.793Z"></path> </svg> </template> <template id="code-square-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-code-square"> <path d="M0 1.75C0 .784.784 0 1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25Zm7.47 3.97a.75.75 0 0 1 1.06 0l2 2a.75.75 0 0 1 0 1.06l-2 2a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L10.69 8 9.22 6.53a.75.75 0 0 1 0-1.06ZM6.78 6.53 5.31 8l1.47 1.47a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-2-2a.75.75 0 0 1 0-1.06l2-2a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042Z"></path> </svg> </template> <template id="device-desktop-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-device-desktop"> <path d="M14.25 1c.966 0 1.75.784 1.75 1.75v7.5A1.75 1.75 0 0 1 14.25 12h-3.727c.099 1.041.52 1.872 1.292 2.757A.752.752 0 0 1 11.25 16h-6.5a.75.75 0 0 1-.565-1.243c.772-.885 1.192-1.716 1.292-2.757H1.75A1.75 1.75 0 0 1 0 10.25v-7.5C0 1.784.784 1 1.75 1ZM1.75 2.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25ZM9.018 12H6.982a5.72 5.72 0 0 1-.765 2.5h3.566a5.72 5.72 0 0 1-.765-2.5Z"></path> </svg> </template> <div class="position-relative"> <ul role="listbox" class="ActionListWrap QueryBuilder-ListWrap" aria-label="Suggestions" data-action=" combobox-commit:query-builder#comboboxCommit mousedown:query-builder#resultsMousedown " data-target="query-builder.resultsList" data-persist-list=false id="query-builder-test-results" ></ul> </div> <div class="FormControl-inlineValidation" id="validation-44692740-13ca-4843-ba56-9c412e9f6e44" hidden="hidden"> <span class="FormControl-inlineValidation--visual"> <svg aria-hidden="true" height="12" viewBox="0 0 12 12" version="1.1" width="12" data-view-component="true" class="octicon octicon-alert-fill"> <path d="M4.855.708c.5-.896 1.79-.896 2.29 0l4.675 8.351a1.312 1.312 0 0 1-1.146 1.954H1.33A1.313 1.313 0 0 1 .183 9.058ZM7 7V3H5v4Zm-1 3a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"></path> </svg> </span> <span></span> </div> </div> <div data-target="query-builder.screenReaderFeedback" aria-live="polite" aria-atomic="true" class="sr-only"></div> </query-builder></form> <div class="d-flex flex-row color-fg-muted px-3 text-small color-bg-default search-feedback-prompt"> <a target="_blank" href="https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax" data-view-component="true" class="Link color-fg-accent text-normal ml-2">Search syntax tips</a> <div class="d-flex flex-1"></div> </div> </div> </div> </div> </modal-dialog></div> </div> <div data-action="click:qbsearch-input#retract" class="dark-backdrop position-fixed" hidden data-target="qbsearch-input.darkBackdrop"></div> <div class="color-fg-default"> <dialog-helper> <dialog data-target="qbsearch-input.feedbackDialog" data-action="close:qbsearch-input#handleDialogClose cancel:qbsearch-input#handleDialogClose" id="feedback-dialog" aria-modal="true" aria-labelledby="feedback-dialog-title" aria-describedby="feedback-dialog-description" data-view-component="true" class="Overlay Overlay-whenNarrow Overlay--size-medium Overlay--motion-scaleFade Overlay--disableScroll"> <div data-view-component="true" class="Overlay-header"> <div class="Overlay-headerContentWrap"> <div class="Overlay-titleWrap"> <h1 class="Overlay-title " id="feedback-dialog-title"> Provide feedback </h1> </div> <div class="Overlay-actionWrap"> <button data-close-dialog-id="feedback-dialog" aria-label="Close" type="button" data-view-component="true" class="close-button Overlay-closeButton"><svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path> </svg></button> </div> </div> </div> <scrollable-region data-labelled-by="feedback-dialog-title"> <div data-view-component="true" class="Overlay-body"> <!-- '"` --><!-- </textarea></xmp> --></option></form><form id="code-search-feedback-form" data-turbo="false" action="/search/feedback" accept-charset="UTF-8" method="post"><input type="hidden" data-csrf="true" name="authenticity_token" value="q1y5Te+EmLUE1L5C8g1N+XCjX5Uh3GAdC7oanqzsGuaaOnvg+KHvcYrLLljeIgBUXF8sY8OEb/pMq2qRLXlRrg==" /> <p>We read every piece of feedback, and take your input very seriously.</p> <textarea name="feedback" class="form-control width-full mb-2" style="height: 120px" id="feedback"></textarea> <input name="include_email" id="include_email" aria-label="Include my email address so I can be contacted" class="form-control mr-2" type="checkbox"> <label for="include_email" style="font-weight: normal">Include my email address so I can be contacted</label> </form></div> </scrollable-region> <div data-view-component="true" class="Overlay-footer Overlay-footer--alignEnd"> <button data-close-dialog-id="feedback-dialog" type="button" data-view-component="true" class="btn"> Cancel </button> <button form="code-search-feedback-form" data-action="click:qbsearch-input#submitFeedback" type="submit" data-view-component="true" class="btn-primary btn"> Submit feedback </button> </div> </dialog></dialog-helper> <custom-scopes data-target="qbsearch-input.customScopesManager"> <dialog-helper> <dialog data-target="custom-scopes.customScopesModalDialog" data-action="close:qbsearch-input#handleDialogClose cancel:qbsearch-input#handleDialogClose" id="custom-scopes-dialog" aria-modal="true" aria-labelledby="custom-scopes-dialog-title" aria-describedby="custom-scopes-dialog-description" data-view-component="true" class="Overlay Overlay-whenNarrow Overlay--size-medium Overlay--motion-scaleFade Overlay--disableScroll"> <div data-view-component="true" class="Overlay-header Overlay-header--divided"> <div class="Overlay-headerContentWrap"> <div class="Overlay-titleWrap"> <h1 class="Overlay-title " id="custom-scopes-dialog-title"> Saved searches </h1> <h2 id="custom-scopes-dialog-description" class="Overlay-description">Use saved searches to filter your results more quickly</h2> </div> <div class="Overlay-actionWrap"> <button data-close-dialog-id="custom-scopes-dialog" aria-label="Close" type="button" data-view-component="true" class="close-button Overlay-closeButton"><svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path> </svg></button> </div> </div> </div> <scrollable-region data-labelled-by="custom-scopes-dialog-title"> <div data-view-component="true" class="Overlay-body"> <div data-target="custom-scopes.customScopesModalDialogFlash"></div> <div hidden class="create-custom-scope-form" data-target="custom-scopes.createCustomScopeForm"> <!-- '"` --><!-- </textarea></xmp> --></option></form><form id="custom-scopes-dialog-form" data-turbo="false" action="/search/custom_scopes" accept-charset="UTF-8" method="post"><input type="hidden" data-csrf="true" name="authenticity_token" value="L44vf9yiGBzghCmqZigMI4ELCgpq5nIxL/L5i4Sbn577dBssT5p7GKfLnvvafq5/Jti2B6l4Iqc+IP1EDdVhGQ==" /> <div data-target="custom-scopes.customScopesModalDialogFlash"></div> <input type="hidden" id="custom_scope_id" name="custom_scope_id" data-target="custom-scopes.customScopesIdField"> <div class="form-group"> <label for="custom_scope_name">Name</label> <auto-check src="/search/custom_scopes/check_name" required only-validate-on-blur="false"> <input type="text" name="custom_scope_name" id="custom_scope_name" data-target="custom-scopes.customScopesNameField" class="form-control" autocomplete="off" placeholder="github-ruby" required maxlength="50"> <input type="hidden" data-csrf="true" value="ygzsuFhxjAFo+w4mAft5y8qjigO3EhAXqGJPf/qZZWcpL1js2JcWk7LKdGf1vW/JNoFsBNFKRMVgVZCWCKeFKA==" /> </auto-check> </div> <div class="form-group"> <label for="custom_scope_query">Query</label> <input type="text" name="custom_scope_query" id="custom_scope_query" data-target="custom-scopes.customScopesQueryField" class="form-control" autocomplete="off" placeholder="(repo:mona/a OR repo:mona/b) AND lang:python" required maxlength="500"> </div> <p class="text-small color-fg-muted"> To see all available qualifiers, see our <a class="Link--inTextBlock" href="https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax">documentation</a>. </p> </form> </div> <div data-target="custom-scopes.manageCustomScopesForm"> <div data-target="custom-scopes.list"></div> </div> </div> </scrollable-region> <div data-view-component="true" class="Overlay-footer Overlay-footer--alignEnd Overlay-footer--divided"> <button data-action="click:custom-scopes#customScopesCancel" type="button" data-view-component="true" class="btn"> Cancel </button> <button form="custom-scopes-dialog-form" data-action="click:custom-scopes#customScopesSubmit" data-target="custom-scopes.customScopesSubmitButton" type="submit" data-view-component="true" class="btn-primary btn"> Create saved search </button> </div> </dialog></dialog-helper> </custom-scopes> </div> </qbsearch-input> <div class="position-relative HeaderMenu-link-wrap d-lg-inline-block"> <a href="/login?return_to=https%3A%2F%2Fgithub.com%2Fapple%2Fml-stable-diffusion" class="HeaderMenu-link HeaderMenu-link--sign-in HeaderMenu-button flex-shrink-0 no-underline d-none d-lg-inline-flex border border-lg-0 rounded rounded-lg-0 px-2 py-1" style="margin-left: 12px;" data-hydro-click="{&quot;event_type&quot;:&quot;authentication.click&quot;,&quot;payload&quot;:{&quot;location_in_page&quot;:&quot;site header menu&quot;,&quot;repository_id&quot;:null,&quot;auth_type&quot;:&quot;SIGN_UP&quot;,&quot;originating_url&quot;:&quot;https://github.com/apple/ml-stable-diffusion&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="b73a63936f47c960275293fd24b94dbde64b9e1f5db4479240addb6322fcc2a7" data-analytics-event="{&quot;category&quot;:&quot;Marketing nav&quot;,&quot;action&quot;:&quot;click to go to homepage&quot;,&quot;label&quot;:&quot;ref_page:Marketing;ref_cta:Sign in;ref_loc:Header&quot;}" > Sign in </a> </div> <a href="/signup?ref_cta=Sign+up&amp;ref_loc=header+logged+out&amp;ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E&amp;source=header-repo&amp;source_repo=apple%2Fml-stable-diffusion" class="HeaderMenu-link HeaderMenu-link--sign-up HeaderMenu-button flex-shrink-0 d-flex d-lg-inline-flex no-underline border color-border-default rounded px-2 py-1" data-hydro-click="{&quot;event_type&quot;:&quot;authentication.click&quot;,&quot;payload&quot;:{&quot;location_in_page&quot;:&quot;site header menu&quot;,&quot;repository_id&quot;:null,&quot;auth_type&quot;:&quot;SIGN_UP&quot;,&quot;originating_url&quot;:&quot;https://github.com/apple/ml-stable-diffusion&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="b73a63936f47c960275293fd24b94dbde64b9e1f5db4479240addb6322fcc2a7" data-analytics-event="{&quot;category&quot;:&quot;Sign up&quot;,&quot;action&quot;:&quot;click to sign up for account&quot;,&quot;label&quot;:&quot;ref_page:/&lt;user-name&gt;/&lt;repo-name&gt;;ref_cta:Sign up;ref_loc:header logged out&quot;}" > Sign up </a> <button type="button" class="sr-only js-header-menu-focus-trap d-block d-lg-none">Reseting focus</button> </div> </div> </div> </div> </header> <div hidden="hidden" data-view-component="true" class="js-stale-session-flash stale-session-flash flash flash-warn flash-full"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert"> <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path> </svg> <span class="js-stale-session-flash-signed-in" hidden>You signed in with another tab or window. <a class="Link--inTextBlock" href="">Reload</a> to refresh your session.</span> <span class="js-stale-session-flash-signed-out" hidden>You signed out in another tab or window. <a class="Link--inTextBlock" href="">Reload</a> to refresh your session.</span> <span class="js-stale-session-flash-switched" hidden>You switched accounts on another tab or window. <a class="Link--inTextBlock" href="">Reload</a> to refresh your session.</span> <button id="icon-button-8e332be7-27bb-425a-8d38-af502c03077e" aria-labelledby="tooltip-f51c4f0e-a635-4c2c-9d70-07e45e15d60f" type="button" data-view-component="true" class="Button Button--iconOnly Button--invisible Button--medium flash-close js-flash-close"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x Button-visual"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path> </svg> </button><tool-tip id="tooltip-f51c4f0e-a635-4c2c-9d70-07e45e15d60f" for="icon-button-8e332be7-27bb-425a-8d38-af502c03077e" popover="manual" data-direction="s" data-type="label" data-view-component="true" class="sr-only position-absolute">Dismiss alert</tool-tip> </div> </div> <div id="start-of-content" class="show-on-focus"></div> <div id="js-flash-container" class="flash-container" data-turbo-replace> <template class="js-flash-template"> <div class="flash flash-full {{ className }}"> <div > <button autofocus class="flash-close js-flash-close" type="button" aria-label="Dismiss this message"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path> </svg> </button> <div aria-atomic="true" role="alert" class="js-flash-alert"> <div>{{ message }}</div> </div> </div> </div> </template> </div> <div class="application-main " data-commit-hovercards-enabled data-discussion-hovercards-enabled data-issue-and-pr-hovercards-enabled data-project-hovercards-enabled > <div itemscope itemtype="http://schema.org/SoftwareSourceCode" class=""> <main id="js-repo-pjax-container" > <div id="repository-container-header" class="pt-3 hide-full-screen" style="background-color: var(--page-header-bgColor, var(--color-page-header-bg));" data-turbo-replace> <div class="d-flex flex-nowrap flex-justify-end mb-3 px-3 px-lg-5" style="gap: 1rem;"> <div class="flex-auto min-width-0 width-fit"> <div class=" d-flex flex-wrap flex-items-center wb-break-word f3 text-normal"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo color-fg-muted mr-2"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path> </svg> <span class="author flex-self-stretch" itemprop="author"> <a class="url fn" rel="author" data-hovercard-type="organization" data-hovercard-url="/orgs/apple/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="/apple"> apple </a> </span> <span class="mx-1 flex-self-stretch color-fg-muted">/</span> <strong itemprop="name" class="mr-2 flex-self-stretch"> <a data-pjax="#repo-content-pjax-container" data-turbo-frame="repo-content-turbo-frame" href="/apple/ml-stable-diffusion">ml-stable-diffusion</a> </strong> <span></span><span class="Label Label--secondary v-align-middle mr-1">Public</span> </div> </div> <div id="repository-details-container" class="flex-shrink-0" data-turbo-replace style="max-width: 70%;"> <ul class="pagehead-actions flex-shrink-0 d-none d-md-inline" style="padding: 2px 0;"> <li> <a href="/login?return_to=%2Fapple%2Fml-stable-diffusion" rel="nofollow" id="repository-details-watch-button" data-hydro-click="{&quot;event_type&quot;:&quot;authentication.click&quot;,&quot;payload&quot;:{&quot;location_in_page&quot;:&quot;notification subscription menu watch&quot;,&quot;repository_id&quot;:null,&quot;auth_type&quot;:&quot;LOG_IN&quot;,&quot;originating_url&quot;:&quot;https://github.com/apple/ml-stable-diffusion&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="d89c08a307d1a1a21b21ea3ead4011e8ab00590628f28c3e03858689af1e3c02" aria-label="You must be signed in to change notification settings" data-view-component="true" class="btn-sm btn"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-bell mr-2"> <path d="M8 16a2 2 0 0 0 1.985-1.75c.017-.137-.097-.25-.235-.25h-3.5c-.138 0-.252.113-.235.25A2 2 0 0 0 8 16ZM3 5a5 5 0 0 1 10 0v2.947c0 .05.015.098.042.139l1.703 2.555A1.519 1.519 0 0 1 13.482 13H2.518a1.516 1.516 0 0 1-1.263-2.36l1.703-2.554A.255.255 0 0 0 3 7.947Zm5-3.5A3.5 3.5 0 0 0 4.5 5v2.947c0 .346-.102.683-.294.97l-1.703 2.556a.017.017 0 0 0-.003.01l.001.006c0 .002.002.004.004.006l.006.004.007.001h10.964l.007-.001.006-.004.004-.006.001-.007a.017.017 0 0 0-.003-.01l-1.703-2.554a1.745 1.745 0 0 1-.294-.97V5A3.5 3.5 0 0 0 8 1.5Z"></path> </svg>Notifications </a> <tool-tip id="tooltip-f35556e6-9ff5-4452-8a72-b50e8b04b0c3" for="repository-details-watch-button" popover="manual" data-direction="s" data-type="description" data-view-component="true" class="sr-only position-absolute">You must be signed in to change notification settings</tool-tip> </li> <li> <a icon="repo-forked" id="fork-button" href="/login?return_to=%2Fapple%2Fml-stable-diffusion" rel="nofollow" data-hydro-click="{&quot;event_type&quot;:&quot;authentication.click&quot;,&quot;payload&quot;:{&quot;location_in_page&quot;:&quot;repo details fork button&quot;,&quot;repository_id&quot;:566576114,&quot;auth_type&quot;:&quot;LOG_IN&quot;,&quot;originating_url&quot;:&quot;https://github.com/apple/ml-stable-diffusion&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="c3bf0af419db6f102c91cc9f42e61e3180db6a721913114b5564c05eee1e8f62" data-view-component="true" class="btn-sm btn"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo-forked mr-2"> <path d="M5 5.372v.878c0 .414.336.75.75.75h4.5a.75.75 0 0 0 .75-.75v-.878a2.25 2.25 0 1 1 1.5 0v.878a2.25 2.25 0 0 1-2.25 2.25h-1.5v2.128a2.251 2.251 0 1 1-1.5 0V8.5h-1.5A2.25 2.25 0 0 1 3.5 6.25v-.878a2.25 2.25 0 1 1 1.5 0ZM5 3.25a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Zm6.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm-3 8.75a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Z"></path> </svg>Fork <span id="repo-network-counter" data-pjax-replace="true" data-turbo-replace="true" title="974" data-view-component="true" class="Counter">974</span> </a> </li> <li> <div data-view-component="true" class="BtnGroup d-flex"> <a href="/login?return_to=%2Fapple%2Fml-stable-diffusion" rel="nofollow" data-hydro-click="{&quot;event_type&quot;:&quot;authentication.click&quot;,&quot;payload&quot;:{&quot;location_in_page&quot;:&quot;star button&quot;,&quot;repository_id&quot;:566576114,&quot;auth_type&quot;:&quot;LOG_IN&quot;,&quot;originating_url&quot;:&quot;https://github.com/apple/ml-stable-diffusion&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="6884bbef4afb364dcbdd933a8e52569cd26a54de851a360918a5a8739d9e2e48" aria-label="You must be signed in to star a repository" data-view-component="true" class="tooltipped tooltipped-sw btn-sm btn"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-star v-align-text-bottom d-inline-block mr-2"> <path d="M8 .25a.75.75 0 0 1 .673.418l1.882 3.815 4.21.612a.75.75 0 0 1 .416 1.279l-3.046 2.97.719 4.192a.751.751 0 0 1-1.088.791L8 12.347l-3.766 1.98a.75.75 0 0 1-1.088-.79l.72-4.194L.818 6.374a.75.75 0 0 1 .416-1.28l4.21-.611L7.327.668A.75.75 0 0 1 8 .25Zm0 2.445L6.615 5.5a.75.75 0 0 1-.564.41l-3.097.45 2.24 2.184a.75.75 0 0 1 .216.664l-.528 3.084 2.769-1.456a.75.75 0 0 1 .698 0l2.77 1.456-.53-3.084a.75.75 0 0 1 .216-.664l2.24-2.183-3.096-.45a.75.75 0 0 1-.564-.41L8 2.694Z"></path> </svg><span data-view-component="true" class="d-inline"> Star </span> <span id="repo-stars-counter-star" aria-label="17249 users starred this repository" data-singular-suffix="user starred this repository" data-plural-suffix="users starred this repository" data-turbo-replace="true" title="17,249" data-view-component="true" class="Counter js-social-count">17.2k</span> </a></div> </li> </ul> </div> </div> <div id="responsive-meta-container" data-turbo-replace> <div class="d-block d-md-none mb-2 px-3 px-md-4 px-lg-5"> <p class="f4 mb-3 "> Stable Diffusion with Core ML on Apple Silicon </p> <h3 class="sr-only">License</h3> <div class="mb-2"> <a href="/apple/ml-stable-diffusion/blob/main/LICENSE.md" class="Link--muted" data-analytics-event="{&quot;category&quot;:&quot;Repository Overview&quot;,&quot;action&quot;:&quot;click&quot;,&quot;label&quot;:&quot;location:sidebar;file:license&quot;}" > <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-law mr-2"> <path d="M8.75.75V2h.985c.304 0 .603.08.867.231l1.29.736c.038.022.08.033.124.033h2.234a.75.75 0 0 1 0 1.5h-.427l2.111 4.692a.75.75 0 0 1-.154.838l-.53-.53.529.531-.001.002-.002.002-.006.006-.006.005-.01.01-.045.04c-.21.176-.441.327-.686.45C14.556 10.78 13.88 11 13 11a4.498 4.498 0 0 1-2.023-.454 3.544 3.544 0 0 1-.686-.45l-.045-.04-.016-.015-.006-.006-.004-.004v-.001a.75.75 0 0 1-.154-.838L12.178 4.5h-.162c-.305 0-.604-.079-.868-.231l-1.29-.736a.245.245 0 0 0-.124-.033H8.75V13h2.5a.75.75 0 0 1 0 1.5h-6.5a.75.75 0 0 1 0-1.5h2.5V3.5h-.984a.245.245 0 0 0-.124.033l-1.289.737c-.265.15-.564.23-.869.23h-.162l2.112 4.692a.75.75 0 0 1-.154.838l-.53-.53.529.531-.001.002-.002.002-.006.006-.016.015-.045.04c-.21.176-.441.327-.686.45C4.556 10.78 3.88 11 3 11a4.498 4.498 0 0 1-2.023-.454 3.544 3.544 0 0 1-.686-.45l-.045-.04-.016-.015-.006-.006-.004-.004v-.001a.75.75 0 0 1-.154-.838L2.178 4.5H1.75a.75.75 0 0 1 0-1.5h2.234a.249.249 0 0 0 .125-.033l1.288-.737c.265-.15.564-.23.869-.23h.984V.75a.75.75 0 0 1 1.5 0Zm2.945 8.477c.285.135.718.273 1.305.273s1.02-.138 1.305-.273L13 6.327Zm-10 0c.285.135.718.273 1.305.273s1.02-.138 1.305-.273L3 6.327Z"></path> </svg> MIT license </a> </div> <div class="mb-3"> <a class="Link--secondary no-underline mr-3" href="/apple/ml-stable-diffusion/stargazers"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-star mr-1"> <path d="M8 .25a.75.75 0 0 1 .673.418l1.882 3.815 4.21.612a.75.75 0 0 1 .416 1.279l-3.046 2.97.719 4.192a.751.751 0 0 1-1.088.791L8 12.347l-3.766 1.98a.75.75 0 0 1-1.088-.79l.72-4.194L.818 6.374a.75.75 0 0 1 .416-1.28l4.21-.611L7.327.668A.75.75 0 0 1 8 .25Zm0 2.445L6.615 5.5a.75.75 0 0 1-.564.41l-3.097.45 2.24 2.184a.75.75 0 0 1 .216.664l-.528 3.084 2.769-1.456a.75.75 0 0 1 .698 0l2.77 1.456-.53-3.084a.75.75 0 0 1 .216-.664l2.24-2.183-3.096-.45a.75.75 0 0 1-.564-.41L8 2.694Z"></path> </svg> <span class="text-bold">17.2k</span> stars </a> <a class="Link--secondary no-underline mr-3" href="/apple/ml-stable-diffusion/forks"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo-forked mr-1"> <path d="M5 5.372v.878c0 .414.336.75.75.75h4.5a.75.75 0 0 0 .75-.75v-.878a2.25 2.25 0 1 1 1.5 0v.878a2.25 2.25 0 0 1-2.25 2.25h-1.5v2.128a2.251 2.251 0 1 1-1.5 0V8.5h-1.5A2.25 2.25 0 0 1 3.5 6.25v-.878a2.25 2.25 0 1 1 1.5 0ZM5 3.25a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Zm6.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm-3 8.75a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Z"></path> </svg> <span class="text-bold">974</span> forks </a> <a class="Link--secondary no-underline mr-3 d-inline-block" href="/apple/ml-stable-diffusion/branches"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-git-branch mr-1"> <path d="M9.5 3.25a2.25 2.25 0 1 1 3 2.122V6A2.5 2.5 0 0 1 10 8.5H6a1 1 0 0 0-1 1v1.128a2.251 2.251 0 1 1-1.5 0V5.372a2.25 2.25 0 1 1 1.5 0v1.836A2.493 2.493 0 0 1 6 7h4a1 1 0 0 0 1-1v-.628A2.25 2.25 0 0 1 9.5 3.25Zm-6 0a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Zm8.25-.75a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5ZM4.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Z"></path> </svg> <span>Branches</span> </a> <a class="Link--secondary no-underline d-inline-block" href="/apple/ml-stable-diffusion/tags"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-tag mr-1"> <path d="M1 7.775V2.75C1 1.784 1.784 1 2.75 1h5.025c.464 0 .91.184 1.238.513l6.25 6.25a1.75 1.75 0 0 1 0 2.474l-5.026 5.026a1.75 1.75 0 0 1-2.474 0l-6.25-6.25A1.752 1.752 0 0 1 1 7.775Zm1.5 0c0 .066.026.13.073.177l6.25 6.25a.25.25 0 0 0 .354 0l5.025-5.025a.25.25 0 0 0 0-.354l-6.25-6.25a.25.25 0 0 0-.177-.073H2.75a.25.25 0 0 0-.25.25ZM6 5a1 1 0 1 1 0 2 1 1 0 0 1 0-2Z"></path> </svg> <span>Tags</span> </a> <a class="Link--secondary no-underline d-inline-block" href="/apple/ml-stable-diffusion/activity"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-pulse mr-1"> <path d="M6 2c.306 0 .582.187.696.471L10 10.731l1.304-3.26A.751.751 0 0 1 12 7h3.25a.75.75 0 0 1 0 1.5h-2.742l-1.812 4.528a.751.751 0 0 1-1.392 0L6 4.77 4.696 8.03A.75.75 0 0 1 4 8.5H.75a.75.75 0 0 1 0-1.5h2.742l1.812-4.529A.751.751 0 0 1 6 2Z"></path> </svg> <span>Activity</span> </a> </div> <div class="d-flex flex-wrap gap-2"> <div class="flex-1"> <div data-view-component="true" class="BtnGroup d-flex"> <a href="/login?return_to=%2Fapple%2Fml-stable-diffusion" rel="nofollow" data-hydro-click="{&quot;event_type&quot;:&quot;authentication.click&quot;,&quot;payload&quot;:{&quot;location_in_page&quot;:&quot;star button&quot;,&quot;repository_id&quot;:566576114,&quot;auth_type&quot;:&quot;LOG_IN&quot;,&quot;originating_url&quot;:&quot;https://github.com/apple/ml-stable-diffusion&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="6884bbef4afb364dcbdd933a8e52569cd26a54de851a360918a5a8739d9e2e48" aria-label="You must be signed in to star a repository" data-view-component="true" class="tooltipped tooltipped-sw btn-sm btn btn-block"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-star v-align-text-bottom d-inline-block mr-2"> <path d="M8 .25a.75.75 0 0 1 .673.418l1.882 3.815 4.21.612a.75.75 0 0 1 .416 1.279l-3.046 2.97.719 4.192a.751.751 0 0 1-1.088.791L8 12.347l-3.766 1.98a.75.75 0 0 1-1.088-.79l.72-4.194L.818 6.374a.75.75 0 0 1 .416-1.28l4.21-.611L7.327.668A.75.75 0 0 1 8 .25Zm0 2.445L6.615 5.5a.75.75 0 0 1-.564.41l-3.097.45 2.24 2.184a.75.75 0 0 1 .216.664l-.528 3.084 2.769-1.456a.75.75 0 0 1 .698 0l2.77 1.456-.53-3.084a.75.75 0 0 1 .216-.664l2.24-2.183-3.096-.45a.75.75 0 0 1-.564-.41L8 2.694Z"></path> </svg><span data-view-component="true" class="d-inline"> Star </span> </a></div> </div> <div class="flex-1"> <a href="/login?return_to=%2Fapple%2Fml-stable-diffusion" rel="nofollow" id="files-overview-watch-button" data-hydro-click="{&quot;event_type&quot;:&quot;authentication.click&quot;,&quot;payload&quot;:{&quot;location_in_page&quot;:&quot;notification subscription menu watch&quot;,&quot;repository_id&quot;:null,&quot;auth_type&quot;:&quot;LOG_IN&quot;,&quot;originating_url&quot;:&quot;https://github.com/apple/ml-stable-diffusion&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="d89c08a307d1a1a21b21ea3ead4011e8ab00590628f28c3e03858689af1e3c02" aria-label="You must be signed in to change notification settings" data-view-component="true" class="btn-sm btn btn-block"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-bell mr-2"> <path d="M8 16a2 2 0 0 0 1.985-1.75c.017-.137-.097-.25-.235-.25h-3.5c-.138 0-.252.113-.235.25A2 2 0 0 0 8 16ZM3 5a5 5 0 0 1 10 0v2.947c0 .05.015.098.042.139l1.703 2.555A1.519 1.519 0 0 1 13.482 13H2.518a1.516 1.516 0 0 1-1.263-2.36l1.703-2.554A.255.255 0 0 0 3 7.947Zm5-3.5A3.5 3.5 0 0 0 4.5 5v2.947c0 .346-.102.683-.294.97l-1.703 2.556a.017.017 0 0 0-.003.01l.001.006c0 .002.002.004.004.006l.006.004.007.001h10.964l.007-.001.006-.004.004-.006.001-.007a.017.017 0 0 0-.003-.01l-1.703-2.554a1.745 1.745 0 0 1-.294-.97V5A3.5 3.5 0 0 0 8 1.5Z"></path> </svg>Notifications </a> <tool-tip id="tooltip-5ffe02af-e21a-496f-b445-fdc98bc366a7" for="files-overview-watch-button" popover="manual" data-direction="s" data-type="description" data-view-component="true" class="sr-only position-absolute">You must be signed in to change notification settings</tool-tip> </div> <span> </span> </div> </div> </div> <nav data-pjax="#js-repo-pjax-container" aria-label="Repository" data-view-component="true" class="js-repo-nav js-sidenav-container-pjax js-responsive-underlinenav overflow-hidden UnderlineNav px-3 px-md-4 px-lg-5"> <ul data-view-component="true" class="UnderlineNav-body list-style-none"> <li data-view-component="true" class="d-inline-flex"> <a id="code-tab" href="/apple/ml-stable-diffusion" data-tab-item="i0code-tab" data-selected-links="repo_source repo_downloads repo_commits repo_releases repo_tags repo_branches repo_packages repo_deployments repo_attestations /apple/ml-stable-diffusion" data-pjax="#repo-content-pjax-container" data-turbo-frame="repo-content-turbo-frame" data-hotkey="g c" data-analytics-event="{&quot;category&quot;:&quot;Underline navbar&quot;,&quot;action&quot;:&quot;Click tab&quot;,&quot;label&quot;:&quot;Code&quot;,&quot;target&quot;:&quot;UNDERLINE_NAV.TAB&quot;}" aria-current="page" data-view-component="true" class="UnderlineNav-item no-wrap js-responsive-underlinenav-item js-selected-navigation-item selected"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-code UnderlineNav-octicon d-none d-sm-inline"> <path d="m11.28 3.22 4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L13.94 8l-3.72-3.72a.749.749 0 0 1 .326-1.275.749.749 0 0 1 .734.215Zm-6.56 0a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042L2.06 8l3.72 3.72a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L.47 8.53a.75.75 0 0 1 0-1.06Z"></path> </svg> <span data-content="Code">Code</span> <span id="code-repo-tab-count" data-pjax-replace="" data-turbo-replace="" title="Not available" data-view-component="true" class="Counter"></span> </a></li> <li data-view-component="true" class="d-inline-flex"> <a id="issues-tab" href="/apple/ml-stable-diffusion/issues" data-tab-item="i1issues-tab" data-selected-links="repo_issues repo_labels repo_milestones /apple/ml-stable-diffusion/issues" data-pjax="#repo-content-pjax-container" data-turbo-frame="repo-content-turbo-frame" data-hotkey="g i" data-analytics-event="{&quot;category&quot;:&quot;Underline navbar&quot;,&quot;action&quot;:&quot;Click tab&quot;,&quot;label&quot;:&quot;Issues&quot;,&quot;target&quot;:&quot;UNDERLINE_NAV.TAB&quot;}" data-view-component="true" class="UnderlineNav-item no-wrap js-responsive-underlinenav-item js-selected-navigation-item"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-issue-opened UnderlineNav-octicon d-none d-sm-inline"> <path d="M8 9.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z"></path><path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Z"></path> </svg> <span data-content="Issues">Issues</span> <span id="issues-repo-tab-count" data-pjax-replace="" data-turbo-replace="" title="167" data-view-component="true" class="Counter">167</span> </a></li> <li data-view-component="true" class="d-inline-flex"> <a id="pull-requests-tab" href="/apple/ml-stable-diffusion/pulls" data-tab-item="i2pull-requests-tab" data-selected-links="repo_pulls checks /apple/ml-stable-diffusion/pulls" data-pjax="#repo-content-pjax-container" data-turbo-frame="repo-content-turbo-frame" data-hotkey="g p" data-analytics-event="{&quot;category&quot;:&quot;Underline navbar&quot;,&quot;action&quot;:&quot;Click tab&quot;,&quot;label&quot;:&quot;Pull requests&quot;,&quot;target&quot;:&quot;UNDERLINE_NAV.TAB&quot;}" data-view-component="true" class="UnderlineNav-item no-wrap js-responsive-underlinenav-item js-selected-navigation-item"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-git-pull-request UnderlineNav-octicon d-none d-sm-inline"> <path d="M1.5 3.25a2.25 2.25 0 1 1 3 2.122v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.25 2.25 0 0 1 1.5 3.25Zm5.677-.177L9.573.677A.25.25 0 0 1 10 .854V2.5h1A2.5 2.5 0 0 1 13.5 5v5.628a2.251 2.251 0 1 1-1.5 0V5a1 1 0 0 0-1-1h-1v1.646a.25.25 0 0 1-.427.177L7.177 3.427a.25.25 0 0 1 0-.354ZM3.75 2.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm0 9.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm8.25.75a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Z"></path> </svg> <span data-content="Pull requests">Pull requests</span> <span id="pull-requests-repo-tab-count" data-pjax-replace="" data-turbo-replace="" title="20" data-view-component="true" class="Counter">20</span> </a></li> <li data-view-component="true" class="d-inline-flex"> <a id="projects-tab" href="/apple/ml-stable-diffusion/projects" data-tab-item="i3projects-tab" data-selected-links="repo_projects new_repo_project repo_project /apple/ml-stable-diffusion/projects" data-pjax="#repo-content-pjax-container" data-turbo-frame="repo-content-turbo-frame" data-hotkey="g b" data-analytics-event="{&quot;category&quot;:&quot;Underline navbar&quot;,&quot;action&quot;:&quot;Click tab&quot;,&quot;label&quot;:&quot;Projects&quot;,&quot;target&quot;:&quot;UNDERLINE_NAV.TAB&quot;}" data-view-component="true" class="UnderlineNav-item no-wrap js-responsive-underlinenav-item js-selected-navigation-item"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-table UnderlineNav-octicon d-none d-sm-inline"> <path d="M0 1.75C0 .784.784 0 1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25ZM6.5 6.5v8h7.75a.25.25 0 0 0 .25-.25V6.5Zm8-1.5V1.75a.25.25 0 0 0-.25-.25H6.5V5Zm-13 1.5v7.75c0 .138.112.25.25.25H5v-8ZM5 5V1.5H1.75a.25.25 0 0 0-.25.25V5Z"></path> </svg> <span data-content="Projects">Projects</span> <span id="projects-repo-tab-count" data-pjax-replace="" data-turbo-replace="" title="0" hidden="hidden" data-view-component="true" class="Counter">0</span> </a></li> <li data-view-component="true" class="d-inline-flex"> <a id="security-tab" href="/apple/ml-stable-diffusion/security" data-tab-item="i4security-tab" data-selected-links="security overview alerts policy token_scanning code_scanning /apple/ml-stable-diffusion/security" data-pjax="#repo-content-pjax-container" data-turbo-frame="repo-content-turbo-frame" data-hotkey="g s" data-analytics-event="{&quot;category&quot;:&quot;Underline navbar&quot;,&quot;action&quot;:&quot;Click tab&quot;,&quot;label&quot;:&quot;Security&quot;,&quot;target&quot;:&quot;UNDERLINE_NAV.TAB&quot;}" data-view-component="true" class="UnderlineNav-item no-wrap js-responsive-underlinenav-item js-selected-navigation-item"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-shield UnderlineNav-octicon d-none d-sm-inline"> <path d="M7.467.133a1.748 1.748 0 0 1 1.066 0l5.25 1.68A1.75 1.75 0 0 1 15 3.48V7c0 1.566-.32 3.182-1.303 4.682-.983 1.498-2.585 2.813-5.032 3.855a1.697 1.697 0 0 1-1.33 0c-2.447-1.042-4.049-2.357-5.032-3.855C1.32 10.182 1 8.566 1 7V3.48a1.75 1.75 0 0 1 1.217-1.667Zm.61 1.429a.25.25 0 0 0-.153 0l-5.25 1.68a.25.25 0 0 0-.174.238V7c0 1.358.275 2.666 1.057 3.86.784 1.194 2.121 2.34 4.366 3.297a.196.196 0 0 0 .154 0c2.245-.956 3.582-2.104 4.366-3.298C13.225 9.666 13.5 8.36 13.5 7V3.48a.251.251 0 0 0-.174-.237l-5.25-1.68ZM8.75 4.75v3a.75.75 0 0 1-1.5 0v-3a.75.75 0 0 1 1.5 0ZM9 10.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path> </svg> <span data-content="Security">Security</span> <include-fragment src="/apple/ml-stable-diffusion/security/overall-count" accept="text/fragment+html"></include-fragment> </a></li> <li data-view-component="true" class="d-inline-flex"> <a id="insights-tab" href="/apple/ml-stable-diffusion/pulse" data-tab-item="i5insights-tab" data-selected-links="repo_graphs repo_contributors dependency_graph dependabot_updates pulse people community /apple/ml-stable-diffusion/pulse" data-pjax="#repo-content-pjax-container" data-turbo-frame="repo-content-turbo-frame" data-analytics-event="{&quot;category&quot;:&quot;Underline navbar&quot;,&quot;action&quot;:&quot;Click tab&quot;,&quot;label&quot;:&quot;Insights&quot;,&quot;target&quot;:&quot;UNDERLINE_NAV.TAB&quot;}" data-view-component="true" class="UnderlineNav-item no-wrap js-responsive-underlinenav-item js-selected-navigation-item"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-graph UnderlineNav-octicon d-none d-sm-inline"> <path d="M1.5 1.75V13.5h13.75a.75.75 0 0 1 0 1.5H.75a.75.75 0 0 1-.75-.75V1.75a.75.75 0 0 1 1.5 0Zm14.28 2.53-5.25 5.25a.75.75 0 0 1-1.06 0L7 7.06 4.28 9.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.25-3.25a.75.75 0 0 1 1.06 0L10 7.94l4.72-4.72a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042Z"></path> </svg> <span data-content="Insights">Insights</span> <span id="insights-repo-tab-count" data-pjax-replace="" data-turbo-replace="" title="Not available" data-view-component="true" class="Counter"></span> </a></li> </ul> <div style="visibility:hidden;" data-view-component="true" class="UnderlineNav-actions js-responsive-underlinenav-overflow position-absolute pr-3 pr-md-4 pr-lg-5 right-0"> <action-menu data-select-variant="none" data-view-component="true"> <focus-group direction="vertical" mnemonics retain> <button id="action-menu-380adc9b-4b29-44a2-8244-0813e324a70f-button" popovertarget="action-menu-380adc9b-4b29-44a2-8244-0813e324a70f-overlay" aria-controls="action-menu-380adc9b-4b29-44a2-8244-0813e324a70f-list" aria-haspopup="true" aria-labelledby="tooltip-410b98d4-3b5e-495b-aa2b-681e103e9d0a" type="button" data-view-component="true" class="Button Button--iconOnly Button--secondary Button--medium UnderlineNav-item"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-kebab-horizontal Button-visual"> <path d="M8 9a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3ZM1.5 9a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Zm13 0a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z"></path> </svg> </button><tool-tip id="tooltip-410b98d4-3b5e-495b-aa2b-681e103e9d0a" for="action-menu-380adc9b-4b29-44a2-8244-0813e324a70f-button" popover="manual" data-direction="s" data-type="label" data-view-component="true" class="sr-only position-absolute">Additional navigation options</tool-tip> <anchored-position data-target="action-menu.overlay" id="action-menu-380adc9b-4b29-44a2-8244-0813e324a70f-overlay" anchor="action-menu-380adc9b-4b29-44a2-8244-0813e324a70f-button" align="start" side="outside-bottom" anchor-offset="normal" popover="auto" data-view-component="true"> <div data-view-component="true" class="Overlay Overlay--size-auto"> <div data-view-component="true" class="Overlay-body Overlay-body--paddingNone"> <action-list> <div data-view-component="true"> <ul aria-labelledby="action-menu-380adc9b-4b29-44a2-8244-0813e324a70f-button" id="action-menu-380adc9b-4b29-44a2-8244-0813e324a70f-list" role="menu" data-view-component="true" class="ActionListWrap--inset ActionListWrap"> <li hidden="hidden" data-menu-item="i0code-tab" data-targets="action-list.items" role="none" data-view-component="true" class="ActionListItem"> <a tabindex="-1" id="item-5079e8f0-7f7c-4f39-8c7d-bd5b2e78da22" href="/apple/ml-stable-diffusion" role="menuitem" data-view-component="true" class="ActionListContent ActionListContent--visual16"> <span class="ActionListItem-visual ActionListItem-visual--leading"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-code"> <path d="m11.28 3.22 4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L13.94 8l-3.72-3.72a.749.749 0 0 1 .326-1.275.749.749 0 0 1 .734.215Zm-6.56 0a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042L2.06 8l3.72 3.72a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L.47 8.53a.75.75 0 0 1 0-1.06Z"></path> </svg> </span> <span data-view-component="true" class="ActionListItem-label"> Code </span> </a> </li> <li hidden="hidden" data-menu-item="i1issues-tab" data-targets="action-list.items" role="none" data-view-component="true" class="ActionListItem"> <a tabindex="-1" id="item-df30ba59-5307-4ee3-a7ff-48f6c27025b2" href="/apple/ml-stable-diffusion/issues" role="menuitem" data-view-component="true" class="ActionListContent ActionListContent--visual16"> <span class="ActionListItem-visual ActionListItem-visual--leading"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-issue-opened"> <path d="M8 9.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z"></path><path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Z"></path> </svg> </span> <span data-view-component="true" class="ActionListItem-label"> Issues </span> </a> </li> <li hidden="hidden" data-menu-item="i2pull-requests-tab" data-targets="action-list.items" role="none" data-view-component="true" class="ActionListItem"> <a tabindex="-1" id="item-258ea82b-8a12-4c20-9681-71a60457aeda" href="/apple/ml-stable-diffusion/pulls" role="menuitem" data-view-component="true" class="ActionListContent ActionListContent--visual16"> <span class="ActionListItem-visual ActionListItem-visual--leading"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-git-pull-request"> <path d="M1.5 3.25a2.25 2.25 0 1 1 3 2.122v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.25 2.25 0 0 1 1.5 3.25Zm5.677-.177L9.573.677A.25.25 0 0 1 10 .854V2.5h1A2.5 2.5 0 0 1 13.5 5v5.628a2.251 2.251 0 1 1-1.5 0V5a1 1 0 0 0-1-1h-1v1.646a.25.25 0 0 1-.427.177L7.177 3.427a.25.25 0 0 1 0-.354ZM3.75 2.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm0 9.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm8.25.75a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Z"></path> </svg> </span> <span data-view-component="true" class="ActionListItem-label"> Pull requests </span> </a> </li> <li hidden="hidden" data-menu-item="i3projects-tab" data-targets="action-list.items" role="none" data-view-component="true" class="ActionListItem"> <a tabindex="-1" id="item-3ee8b7ef-ea6d-45ea-ba75-15a3d060e984" href="/apple/ml-stable-diffusion/projects" role="menuitem" data-view-component="true" class="ActionListContent ActionListContent--visual16"> <span class="ActionListItem-visual ActionListItem-visual--leading"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-table"> <path d="M0 1.75C0 .784.784 0 1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25ZM6.5 6.5v8h7.75a.25.25 0 0 0 .25-.25V6.5Zm8-1.5V1.75a.25.25 0 0 0-.25-.25H6.5V5Zm-13 1.5v7.75c0 .138.112.25.25.25H5v-8ZM5 5V1.5H1.75a.25.25 0 0 0-.25.25V5Z"></path> </svg> </span> <span data-view-component="true" class="ActionListItem-label"> Projects </span> </a> </li> <li hidden="hidden" data-menu-item="i4security-tab" data-targets="action-list.items" role="none" data-view-component="true" class="ActionListItem"> <a tabindex="-1" id="item-3efeac92-ee68-442d-b927-bccdd24ae0ef" href="/apple/ml-stable-diffusion/security" role="menuitem" data-view-component="true" class="ActionListContent ActionListContent--visual16"> <span class="ActionListItem-visual ActionListItem-visual--leading"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-shield"> <path d="M7.467.133a1.748 1.748 0 0 1 1.066 0l5.25 1.68A1.75 1.75 0 0 1 15 3.48V7c0 1.566-.32 3.182-1.303 4.682-.983 1.498-2.585 2.813-5.032 3.855a1.697 1.697 0 0 1-1.33 0c-2.447-1.042-4.049-2.357-5.032-3.855C1.32 10.182 1 8.566 1 7V3.48a1.75 1.75 0 0 1 1.217-1.667Zm.61 1.429a.25.25 0 0 0-.153 0l-5.25 1.68a.25.25 0 0 0-.174.238V7c0 1.358.275 2.666 1.057 3.86.784 1.194 2.121 2.34 4.366 3.297a.196.196 0 0 0 .154 0c2.245-.956 3.582-2.104 4.366-3.298C13.225 9.666 13.5 8.36 13.5 7V3.48a.251.251 0 0 0-.174-.237l-5.25-1.68ZM8.75 4.75v3a.75.75 0 0 1-1.5 0v-3a.75.75 0 0 1 1.5 0ZM9 10.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path> </svg> </span> <span data-view-component="true" class="ActionListItem-label"> Security </span> </a> </li> <li hidden="hidden" data-menu-item="i5insights-tab" data-targets="action-list.items" role="none" data-view-component="true" class="ActionListItem"> <a tabindex="-1" id="item-863ef51c-fb6c-4b06-9762-d1b89ccdd252" href="/apple/ml-stable-diffusion/pulse" role="menuitem" data-view-component="true" class="ActionListContent ActionListContent--visual16"> <span class="ActionListItem-visual ActionListItem-visual--leading"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-graph"> <path d="M1.5 1.75V13.5h13.75a.75.75 0 0 1 0 1.5H.75a.75.75 0 0 1-.75-.75V1.75a.75.75 0 0 1 1.5 0Zm14.28 2.53-5.25 5.25a.75.75 0 0 1-1.06 0L7 7.06 4.28 9.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.25-3.25a.75.75 0 0 1 1.06 0L10 7.94l4.72-4.72a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042Z"></path> </svg> </span> <span data-view-component="true" class="ActionListItem-label"> Insights </span> </a> </li> </ul> </div></action-list> </div> </div></anchored-position> </focus-group> </action-menu></div> </nav> </div> <turbo-frame id="repo-content-turbo-frame" target="_top" data-turbo-action="advance" class=""> <div id="repo-content-pjax-container" class="repository-content " > <h1 class='sr-only'>apple/ml-stable-diffusion</h1> <div class="clearfix container-xl px-md-4 px-lg-5 px-3"> <div> <div style="max-width: 100%" data-view-component="true" class="Layout Layout--flowRow-until-md react-repos-overview-margin Layout--sidebarPosition-end Layout--sidebarPosition-flowRow-end"> <div data-view-component="true" class="Layout-main"> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_dompurify_dist_purify_es_mjs-dd1d3ea6a436.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_tanstack_query-core_build_modern_queryObserver_js-node_modules_tanstack_-defd52-843b41414e0e.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/ui_packages_aria-live_aria-live_ts-ui_packages_history_history_ts-ui_packages_promise-with-re-01dc80-134579ff449f.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/ui_packages_paths_index_ts-3adbcf6faa83.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/ui_packages_ref-selector_RefSelector_tsx-7496afc3784d.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/ui_packages_commit-attribution_index_ts-ui_packages_commit-checks-status_index_ts-ui_packages-7094d4-b869a469ca5e.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/ui_packages_hydro-analytics_hydro-analytics_ts-ui_packages_verified-fetch_verified-fetch_ts-u-4672d1-96a19eaeffb7.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/ui_packages_code-view-shared_hooks_use-canonical-object_ts-ui_packages_code-view-shared_hooks-d63960-3a5579c864b4.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/repos-overview-fa360a7b1b46.js"></script> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/primer-react.8157a56b30ae88a1b356.module.css" /> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/repos-overview.0ee7cac3ab511a65d9f9.module.css" /> <react-partial partial-name="repos-overview" data-ssr="true" data-attempted-ssr="true" > <script type="application/json" data-target="react-partial.embeddedData">{"props":{"initialPayload":{"allShortcutsEnabled":false,"path":"/","repo":{"id":566576114,"defaultBranch":"main","name":"ml-stable-diffusion","ownerLogin":"apple","currentUserCanPush":false,"isFork":false,"isEmpty":false,"createdAt":"2022-11-16T00:48:18.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/10639145?v=4","public":true,"private":false,"isOrgOwned":true},"currentUser":null,"refInfo":{"name":"main","listCacheKey":"v0:1728414402.0","canEdit":false,"refType":"branch","currentOid":"e5d960c41a6a4ab200b8db379194127607b1c590"},"tree":{"items":[{"name":".github","path":".github","contentType":"directory"},{"name":"assets","path":"assets","contentType":"directory"},{"name":"python_coreml_stable_diffusion","path":"python_coreml_stable_diffusion","contentType":"directory"},{"name":"swift","path":"swift","contentType":"directory"},{"name":"tests","path":"tests","contentType":"directory"},{"name":".gitignore","path":".gitignore","contentType":"file"},{"name":"ACKNOWLEDGEMENTS","path":"ACKNOWLEDGEMENTS","contentType":"file"},{"name":"CODE_OF_CONDUCT.md","path":"CODE_OF_CONDUCT.md","contentType":"file"},{"name":"CONTRIBUTING.md","path":"CONTRIBUTING.md","contentType":"file"},{"name":"LICENSE.md","path":"LICENSE.md","contentType":"file"},{"name":"Package.swift","path":"Package.swift","contentType":"file"},{"name":"README.md","path":"README.md","contentType":"file"},{"name":"requirements.txt","path":"requirements.txt","contentType":"file"},{"name":"setup.py","path":"setup.py","contentType":"file"}],"templateDirectorySuggestionUrl":null,"readme":null,"totalCount":14,"showBranchInfobar":false},"fileTree":null,"fileTreeProcessingTime":null,"foldersToFetch":[],"treeExpanded":false,"symbolsExpanded":false,"isOverview":true,"overview":{"banners":{"shouldRecommendReadme":false,"isPersonalRepo":false,"showUseActionBanner":false,"actionSlug":null,"actionId":null,"showProtectBranchBanner":false,"publishBannersInfo":{"dismissActionNoticePath":"/settings/dismiss-notice/publish_action_from_repo","releasePath":"/apple/ml-stable-diffusion/releases/new?marketplace=true","showPublishActionBanner":false},"interactionLimitBanner":null,"showInvitationBanner":false,"inviterName":null,"actionsMigrationBannerInfo":{"releaseTags":[],"showImmutableActionsMigrationBanner":false,"initialMigrationStatus":null}},"codeButton":{"contactPath":"/contact","isEnterprise":false,"local":{"protocolInfo":{"httpAvailable":true,"sshAvailable":null,"httpUrl":"https://github.com/apple/ml-stable-diffusion.git","showCloneWarning":null,"sshUrl":null,"sshCertificatesRequired":null,"sshCertificatesAvailable":null,"ghCliUrl":"gh repo clone apple/ml-stable-diffusion","defaultProtocol":"http","newSshKeyUrl":"/settings/ssh/new","setProtocolPath":"/users/set_protocol"},"platformInfo":{"cloneUrl":"https://desktop.github.com","showVisualStudioCloneButton":false,"visualStudioCloneUrl":"https://windows.github.com","showXcodeCloneButton":false,"xcodeCloneUrl":"xcode://clone?repo=https%3A%2F%2Fgithub.com%2Fapple%2Fml-stable-diffusion","zipballUrl":"/apple/ml-stable-diffusion/archive/refs/heads/main.zip"}},"newCodespacePath":"/codespaces/new?hide_repo_select=true\u0026repo=566576114"},"popovers":{"rename":null,"renamedParentRepo":null},"commitCount":"121","overviewFiles":[{"displayName":"README.md","repoName":"ml-stable-diffusion","refName":"main","path":"README.md","preferredFileType":"readme","tabName":"README","richText":"\u003carticle class=\"markdown-body entry-content container-lg\" itemprop=\"text\"\u003e\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch1 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eCore ML Stable Diffusion\u003c/h1\u003e\u003ca id=\"user-content-core-ml-stable-diffusion\" class=\"anchor\" aria-label=\"Permalink: Core ML Stable Diffusion\" href=\"#core-ml-stable-diffusion\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eRun Stable Diffusion on Apple Silicon with Core ML\u003c/p\u003e\n\u003cp dir=\"auto\"\u003e\u003ca href=\"https://machinelearning.apple.com/research/stable-diffusion-coreml-apple-silicon\" rel=\"nofollow\"\u003e[Blog Post]\u003c/a\u003e \u003ca href=\"#bibtex\"\u003e[BibTeX]\u003c/a\u003e\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThis repository comprises:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003e\u003ccode\u003epython_coreml_stable_diffusion\u003c/code\u003e, a Python package for converting PyTorch models to Core ML format and performing image generation with Hugging Face \u003ca href=\"https://github.com/huggingface/diffusers\"\u003ediffusers\u003c/a\u003e in Python\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003eStableDiffusion\u003c/code\u003e, a Swift package that developers can add to their Xcode projects as a dependency to deploy image generation capabilities in their apps. The Swift package relies on the Core ML model files generated by \u003ccode\u003epython_coreml_stable_diffusion\u003c/code\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp dir=\"auto\"\u003eIf you run into issues during installation or runtime, please refer to the \u003ca href=\"#faq\"\u003eFAQ\u003c/a\u003e section. Please refer to the \u003ca href=\"#system-requirements\"\u003eSystem Requirements\u003c/a\u003e section before getting started.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003e\u003ca target=\"_blank\" rel=\"noopener noreferrer\" href=\"/apple/ml-stable-diffusion/blob/main/assets/readme_reel.png\"\u003e\u003cimg src=\"/apple/ml-stable-diffusion/raw/main/assets/readme_reel.png\" style=\"max-width: 100%;\"\u003e\u003c/a\u003e\u003c/p\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003e\u003ca name=\"user-content-system-requirements\"\u003e\u003c/a\u003e System Requirements\u003c/h2\u003e\u003ca id=\"user-content--system-requirements\" class=\"anchor\" aria-label=\"Permalink: System Requirements\" href=\"#-system-requirements\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cdetails\u003e\n \u003csummary\u003e Details (Click to expand) \u003c/summary\u003e\n\u003cp dir=\"auto\"\u003eModel Conversion:\u003c/p\u003e\n\u003cmarkdown-accessiblity-table\u003e\u003ctable\u003e\n\u003cthead\u003e\n\u003ctr\u003e\n\u003cth align=\"center\"\u003emacOS\u003c/th\u003e\n\u003cth align=\"center\"\u003ePython\u003c/th\u003e\n\u003cth align=\"center\"\u003ecoremltools\u003c/th\u003e\n\u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\n\u003ctd align=\"center\"\u003e13.1\u003c/td\u003e\n\u003ctd align=\"center\"\u003e3.8\u003c/td\u003e\n\u003ctd align=\"center\"\u003e7.0\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\u003c/markdown-accessiblity-table\u003e\n\u003cp dir=\"auto\"\u003eProject Build:\u003c/p\u003e\n\u003cmarkdown-accessiblity-table\u003e\u003ctable\u003e\n\u003cthead\u003e\n\u003ctr\u003e\n\u003cth align=\"center\"\u003emacOS\u003c/th\u003e\n\u003cth align=\"center\"\u003eXcode\u003c/th\u003e\n\u003cth align=\"center\"\u003eSwift\u003c/th\u003e\n\u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\n\u003ctd align=\"center\"\u003e13.1\u003c/td\u003e\n\u003ctd align=\"center\"\u003e14.3\u003c/td\u003e\n\u003ctd align=\"center\"\u003e5.8\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\u003c/markdown-accessiblity-table\u003e\n\u003cp dir=\"auto\"\u003eTarget Device Runtime:\u003c/p\u003e\n\u003cmarkdown-accessiblity-table\u003e\u003ctable\u003e\n\u003cthead\u003e\n\u003ctr\u003e\n\u003cth align=\"center\"\u003emacOS\u003c/th\u003e\n\u003cth align=\"center\"\u003eiPadOS, iOS\u003c/th\u003e\n\u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\n\u003ctd align=\"center\"\u003e13.1\u003c/td\u003e\n\u003ctd align=\"center\"\u003e16.2\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\u003c/markdown-accessiblity-table\u003e\n\u003cp dir=\"auto\"\u003eTarget Device Runtime (\u003ca href=\"#compression-6-bits-and-higher\"\u003eWith Memory Improvements\u003c/a\u003e):\u003c/p\u003e\n\u003cmarkdown-accessiblity-table\u003e\u003ctable\u003e\n\u003cthead\u003e\n\u003ctr\u003e\n\u003cth align=\"center\"\u003emacOS\u003c/th\u003e\n\u003cth align=\"center\"\u003eiPadOS, iOS\u003c/th\u003e\n\u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\n\u003ctd align=\"center\"\u003e14.0\u003c/td\u003e\n\u003ctd align=\"center\"\u003e17.0\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\u003c/markdown-accessiblity-table\u003e\n\u003cp dir=\"auto\"\u003eTarget Device Hardware Generation:\u003c/p\u003e\n\u003cmarkdown-accessiblity-table\u003e\u003ctable\u003e\n\u003cthead\u003e\n\u003ctr\u003e\n\u003cth align=\"center\"\u003eMac\u003c/th\u003e\n\u003cth align=\"center\"\u003eiPad\u003c/th\u003e\n\u003cth align=\"center\"\u003eiPhone\u003c/th\u003e\n\u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\n\u003ctd align=\"center\"\u003eM1\u003c/td\u003e\n\u003ctd align=\"center\"\u003eM1\u003c/td\u003e\n\u003ctd align=\"center\"\u003eA14\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\u003c/markdown-accessiblity-table\u003e\n\u003c/details\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003e\u003ca name=\"user-content-performance-benchmark\"\u003e\u003c/a\u003e Performance Benchmarks\u003c/h2\u003e\u003ca id=\"user-content--performance-benchmarks\" class=\"anchor\" aria-label=\"Permalink: Performance Benchmarks\" href=\"#-performance-benchmarks\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cdetails\u003e\n \u003csummary\u003e Details (Click to expand) \u003c/summary\u003e\n\u003cp dir=\"auto\"\u003e\u003ca href=\"https://huggingface.co/apple/coreml-stable-diffusion-2-1-base\" rel=\"nofollow\"\u003e\u003ccode\u003estabilityai/stable-diffusion-2-1-base\u003c/code\u003e\u003c/a\u003e (512x512)\u003c/p\u003e\n\u003cmarkdown-accessiblity-table\u003e\u003ctable\u003e\n\u003cthead\u003e\n\u003ctr\u003e\n\u003cth\u003eDevice\u003c/th\u003e\n\u003cth\u003e\u003ccode\u003e--compute-unit\u003c/code\u003e\u003c/th\u003e\n\u003cth\u003e\u003ccode\u003e--attention-implementation\u003c/code\u003e\u003c/th\u003e\n\u003cth\u003eEnd-to-End Latency (s)\u003c/th\u003e\n\u003cth\u003eDiffusion Speed (iter/s)\u003c/th\u003e\n\u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\n\u003ctd\u003eiPhone 12 Mini\u003c/td\u003e\n\u003ctd\u003e\u003ccode\u003eCPU_AND_NE\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e\u003ccode\u003eSPLIT_EINSUM_V2\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e18.5*\u003c/td\u003e\n\u003ctd\u003e1.44\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003eiPhone 12 Pro Max\u003c/td\u003e\n\u003ctd\u003e\u003ccode\u003eCPU_AND_NE\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e\u003ccode\u003eSPLIT_EINSUM_V2\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e15.4\u003c/td\u003e\n\u003ctd\u003e1.45\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003eiPhone 13\u003c/td\u003e\n\u003ctd\u003e\u003ccode\u003eCPU_AND_NE\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e\u003ccode\u003eSPLIT_EINSUM_V2\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e10.8*\u003c/td\u003e\n\u003ctd\u003e2.53\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003eiPhone 13 Pro Max\u003c/td\u003e\n\u003ctd\u003e\u003ccode\u003eCPU_AND_NE\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e\u003ccode\u003eSPLIT_EINSUM_V2\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e10.4\u003c/td\u003e\n\u003ctd\u003e2.55\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003eiPhone 14\u003c/td\u003e\n\u003ctd\u003e\u003ccode\u003eCPU_AND_NE\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e\u003ccode\u003eSPLIT_EINSUM_V2\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e8.6\u003c/td\u003e\n\u003ctd\u003e2.57\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003eiPhone 14 Pro Max\u003c/td\u003e\n\u003ctd\u003e\u003ccode\u003eCPU_AND_NE\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e\u003ccode\u003eSPLIT_EINSUM_V2\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e7.9\u003c/td\u003e\n\u003ctd\u003e2.69\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003eiPad Pro (M1)\u003c/td\u003e\n\u003ctd\u003e\u003ccode\u003eCPU_AND_NE\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e\u003ccode\u003eSPLIT_EINSUM_V2\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e11.2\u003c/td\u003e\n\u003ctd\u003e2.19\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003eiPad Pro (M2)\u003c/td\u003e\n\u003ctd\u003e\u003ccode\u003eCPU_AND_NE\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e\u003ccode\u003eSPLIT_EINSUM_V2\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e7.0\u003c/td\u003e\n\u003ctd\u003e3.07\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\u003c/markdown-accessiblity-table\u003e\n\u003cdetails\u003e\n \u003csummary\u003e Details (Click to expand) \u003c/summary\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003eThis benchmark was conducted by Apple and Hugging Face using public beta versions of iOS 17.0, iPadOS 17.0 and macOS 14.0 Seed 8 in August 2023.\u003c/li\u003e\n\u003cli\u003eThe performance data was collected using the \u003ccode\u003ebenchmark\u003c/code\u003e branch of the \u003ca href=\"https://github.com/huggingface/swift-coreml-diffusers\"\u003eDiffusers app\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003eSwift code is not fully optimized, introducing up to ~10% overhead unrelated to Core ML model execution.\u003c/li\u003e\n\u003cli\u003eThe median latency value across 5 back-to-back end-to-end executions are reported\u003c/li\u003e\n\u003cli\u003eThe image generation procedure follows the standard configuration: 20 inference steps, 512x512 output image resolution, 77 text token sequence length, classifier-free guidance (batch size of 2 for unet).\u003c/li\u003e\n\u003cli\u003eThe actual prompt length does not impact performance because the Core ML model is converted with a static shape that computes the forward pass for all of the 77 elements (\u003ccode\u003etokenizer.model_max_length\u003c/code\u003e) in the text token sequence regardless of the actual length of the input text.\u003c/li\u003e\n\u003cli\u003eWeights are compressed to 6 bit precision. Please refer to \u003ca href=\"#compression-6-bits-and-higher\"\u003ethis section\u003c/a\u003e for details.\u003c/li\u003e\n\u003cli\u003eActivations are in float16 precision for both the GPU and the Neural Engine.\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e*\u003c/code\u003e indicates that the \u003ca href=\"https://github.com/apple/ml-stable-diffusion/blob/main/swift/StableDiffusion/pipeline/StableDiffusionPipeline.swift#L91\"\u003ereduceMemory\u003c/a\u003e option was enabled which loads and unloads models just-in-time to avoid memory shortage. This added up to 2 seconds to the end-to-end latency.\u003c/li\u003e\n\u003cli\u003eIn the benchmark table, we report the best performing \u003ccode\u003e--compute-unit\u003c/code\u003e and \u003ccode\u003e--attention-implementation\u003c/code\u003e values per device. The former does not modify the Core ML model and can be applied during runtime. The latter modifies the Core ML model. Note that the best performing compute unit is model version and hardware-specific.\u003c/li\u003e\n\u003cli\u003eNote that the performance optimizations in this repository (e.g. \u003ccode\u003e--attention-implementation\u003c/code\u003e) are generally applicable to Transformers and not customized to Stable Diffusion. Better performance may be observed upon custom kernel tuning. Therefore, these numbers do not represent \u003cstrong\u003epeak\u003c/strong\u003e HW capability.\u003c/li\u003e\n\u003cli\u003ePerformance may vary across different versions of Stable Diffusion due to architecture changes in the model itself. Each reported number is specific to the model version mentioned in that context.\u003c/li\u003e\n\u003cli\u003ePerformance may vary due to factors like increased system load from other applications or suboptimal device thermal state.\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/details\u003e\n\u003cp dir=\"auto\"\u003e\u003ca href=\"https://huggingface.co/apple/coreml-stable-diffusion-xl-base-ios\" rel=\"nofollow\"\u003e\u003ccode\u003estabilityai/stable-diffusion-xl-base-1.0-ios\u003c/code\u003e\u003c/a\u003e (768x768)\u003c/p\u003e\n\u003cmarkdown-accessiblity-table\u003e\u003ctable\u003e\n\u003cthead\u003e\n\u003ctr\u003e\n\u003cth\u003eDevice\u003c/th\u003e\n\u003cth\u003e\u003ccode\u003e--compute-unit\u003c/code\u003e\u003c/th\u003e\n\u003cth\u003e\u003ccode\u003e--attention-implementation\u003c/code\u003e\u003c/th\u003e\n\u003cth\u003eEnd-to-End Latency (s)\u003c/th\u003e\n\u003cth\u003eDiffusion Speed (iter/s)\u003c/th\u003e\n\u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\n\u003ctd\u003eiPhone 12 Pro\u003c/td\u003e\n\u003ctd\u003e\u003ccode\u003eCPU_AND_NE\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e\u003ccode\u003eSPLIT_EINSUM\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e116*\u003c/td\u003e\n\u003ctd\u003e0.50\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003eiPhone 13 Pro Max\u003c/td\u003e\n\u003ctd\u003e\u003ccode\u003eCPU_AND_NE\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e\u003ccode\u003eSPLIT_EINSUM\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e86*\u003c/td\u003e\n\u003ctd\u003e0.68\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003eiPhone 14 Pro Max\u003c/td\u003e\n\u003ctd\u003e\u003ccode\u003eCPU_AND_NE\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e\u003ccode\u003eSPLIT_EINSUM\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e77*\u003c/td\u003e\n\u003ctd\u003e0.83\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003eiPhone 15 Pro Max\u003c/td\u003e\n\u003ctd\u003e\u003ccode\u003eCPU_AND_NE\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e\u003ccode\u003eSPLIT_EINSUM\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e31\u003c/td\u003e\n\u003ctd\u003e0.85\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003eiPad Pro (M1)\u003c/td\u003e\n\u003ctd\u003e\u003ccode\u003eCPU_AND_NE\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e\u003ccode\u003eSPLIT_EINSUM\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e36\u003c/td\u003e\n\u003ctd\u003e0.69\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003eiPad Pro (M2)\u003c/td\u003e\n\u003ctd\u003e\u003ccode\u003eCPU_AND_NE\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e\u003ccode\u003eSPLIT_EINSUM\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e27\u003c/td\u003e\n\u003ctd\u003e0.98\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\u003c/markdown-accessiblity-table\u003e\n\u003cdetails\u003e\n \u003csummary\u003e Details (Click to expand) \u003c/summary\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003eThis benchmark was conducted by Apple and Hugging Face using iOS 17.0.2 and iPadOS 17.0.2 in September 2023.\u003c/li\u003e\n\u003cli\u003eThe performance data was collected using the \u003ccode\u003ebenchmark\u003c/code\u003e branch of the \u003ca href=\"https://github.com/huggingface/swift-coreml-diffusers\"\u003eDiffusers app\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003eThe median latency value across 5 back-to-back end-to-end executions are reported\u003c/li\u003e\n\u003cli\u003eThe image generation procedure follows this configuration: 20 inference steps, 768x768 output image resolution, 77 text token sequence length, classifier-free guidance (batch size of 2 for unet).\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003eUnet.mlmodelc\u003c/code\u003e is compressed to 4.04 bit precision following the \u003ca href=\"#compression-lower-than-6-bits\"\u003eMixed-Bit Palettization\u003c/a\u003e algorithm recipe published \u003ca href=\"https://huggingface.co/apple/coreml-stable-diffusion-mixed-bit-palettization/blob/main/recipes/stabilityai-stable-diffusion-xl-base-1.0_palettization_recipe.json\" rel=\"nofollow\"\u003ehere\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003eAll models except for \u003ccode\u003eUnet.mlmodelc\u003c/code\u003e are compressed to 16 bit precision\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://huggingface.co/madebyollin/sdxl-vae-fp16-fix\" rel=\"nofollow\"\u003emadebyollin/sdxl-vae-fp16-fix\u003c/a\u003e by \u003ca href=\"https://github.com/madebyollin\"\u003e@madebyollin\u003c/a\u003e was used as the source PyTorch model for \u003ccode\u003eVAEDecoder.mlmodelc\u003c/code\u003e in order to enable float16 weight and activation quantization for the VAE model.\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e--attention-implementation SPLIT_EINSUM\u003c/code\u003e is chosen in lieu of \u003ccode\u003eSPLIT_EINSUM_V2\u003c/code\u003e due to the prohibitively long compilation time of the latter\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e*\u003c/code\u003e indicates that the \u003ca href=\"https://github.com/apple/ml-stable-diffusion/blob/main/swift/StableDiffusion/pipeline/StableDiffusionPipeline.swift#L91\"\u003ereduceMemory\u003c/a\u003e option was enabled which loads and unloads models just-in-time to avoid memory shortage. This added significant overhead to the end-to-end latency. Note that end-to-end latency difference between \u003ccode\u003eiPad Pro (M1)\u003c/code\u003e and \u003ccode\u003eiPhone 13 Pro Max\u003c/code\u003e despite identical diffusion speed.\u003c/li\u003e\n\u003cli\u003eThe actual prompt length does not impact performance because the Core ML model is converted with a static shape that computes the forward pass for all of the 77 elements (\u003ccode\u003etokenizer.model_max_length\u003c/code\u003e) in the text token sequence regardless of the actual length of the input text.\u003c/li\u003e\n\u003cli\u003eIn the benchmark table, we report the best performing \u003ccode\u003e--compute-unit\u003c/code\u003e and \u003ccode\u003e--attention-implementation\u003c/code\u003e values per device. The former does not modify the Core ML model and can be applied during runtime. The latter modifies the Core ML model. Note that the best performing compute unit is model version and hardware-specific.\u003c/li\u003e\n\u003cli\u003eNote that the performance optimizations in this repository (e.g. \u003ccode\u003e--attention-implementation\u003c/code\u003e) are generally applicable to Transformers and not customized to Stable Diffusion. Better performance may be observed upon custom kernel tuning. Therefore, these numbers do not represent \u003cstrong\u003epeak\u003c/strong\u003e HW capability.\u003c/li\u003e\n\u003cli\u003ePerformance may vary across different versions of Stable Diffusion due to architecture changes in the model itself. Each reported number is specific to the model version mentioned in that context.\u003c/li\u003e\n\u003cli\u003ePerformance may vary due to factors like increased system load from other applications or suboptimal device thermal state.\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/details\u003e\n\u003cp dir=\"auto\"\u003e\u003ca href=\"https://huggingface.co/apple/coreml-stable-diffusion-xl-base\" rel=\"nofollow\"\u003e\u003ccode\u003estabilityai/stable-diffusion-xl-base-1.0\u003c/code\u003e\u003c/a\u003e (1024x1024)\u003c/p\u003e\n\u003cmarkdown-accessiblity-table\u003e\u003ctable\u003e\n\u003cthead\u003e\n\u003ctr\u003e\n\u003cth\u003eDevice\u003c/th\u003e\n\u003cth\u003e\u003ccode\u003e--compute-unit\u003c/code\u003e\u003c/th\u003e\n\u003cth\u003e\u003ccode\u003e--attention-implementation\u003c/code\u003e\u003c/th\u003e\n\u003cth\u003eEnd-to-End Latency (s)\u003c/th\u003e\n\u003cth\u003eDiffusion Speed (iter/s)\u003c/th\u003e\n\u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\n\u003ctd\u003eMacBook Pro (M1 Max)\u003c/td\u003e\n\u003ctd\u003e\u003ccode\u003eCPU_AND_GPU\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e\u003ccode\u003eORIGINAL\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e46\u003c/td\u003e\n\u003ctd\u003e0.46\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003eMacBook Pro (M2 Max)\u003c/td\u003e\n\u003ctd\u003e\u003ccode\u003eCPU_AND_GPU\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e\u003ccode\u003eORIGINAL\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e37\u003c/td\u003e\n\u003ctd\u003e0.57\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003eMac Studio (M1 Ultra)\u003c/td\u003e\n\u003ctd\u003e\u003ccode\u003eCPU_AND_GPU\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e\u003ccode\u003eORIGINAL\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e25\u003c/td\u003e\n\u003ctd\u003e0.89\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003eMac Studio (M2 Ultra)\u003c/td\u003e\n\u003ctd\u003e\u003ccode\u003eCPU_AND_GPU\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e\u003ccode\u003eORIGINAL\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e20\u003c/td\u003e\n\u003ctd\u003e1.11\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\u003c/markdown-accessiblity-table\u003e\n\u003cdetails\u003e\n \u003csummary\u003e Details (Click to expand) \u003c/summary\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003eThis benchmark was conducted by Apple and Hugging Face using public beta versions of iOS 17.0, iPadOS 17.0 and macOS 14.0 in July 2023.\u003c/li\u003e\n\u003cli\u003eThe performance data was collected by running the \u003ccode\u003eStableDiffusion\u003c/code\u003e Swift pipeline.\u003c/li\u003e\n\u003cli\u003eThe median latency value across 3 back-to-back end-to-end executions are reported\u003c/li\u003e\n\u003cli\u003eThe image generation procedure follows the standard configuration: 20 inference steps, 1024x1024 output image resolution, classifier-free guidance (batch size of 2 for unet).\u003c/li\u003e\n\u003cli\u003eWeights and activations are in float16 precision\u003c/li\u003e\n\u003cli\u003ePerformance may vary across different versions of Stable Diffusion due to architecture changes in the model itself. Each reported number is specific to the model version mentioned in that context.\u003c/li\u003e\n\u003cli\u003ePerformance may vary due to factors like increased system load from other applications or suboptimal device thermal state. Given these factors, we do not report sub-second variance in latency.\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/details\u003e\n\u003c/details\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003e\u003ca name=\"user-content-compression-6-bits-and-higher\"\u003e\u003c/a\u003e Weight Compression (6-bits and higher)\u003c/h2\u003e\u003ca id=\"user-content--weight-compression-6-bits-and-higher\" class=\"anchor\" aria-label=\"Permalink: Weight Compression (6-bits and higher)\" href=\"#-weight-compression-6-bits-and-higher\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cdetails\u003e\n \u003csummary\u003e Details (Click to expand) \u003c/summary\u003e\n\u003cp dir=\"auto\"\u003ecoremltools-7.0 supports advanced weight compression techniques for \u003ca href=\"https://coremltools.readme.io/v7.0/docs/pruning\" rel=\"nofollow\"\u003epruning\u003c/a\u003e, \u003ca href=\"https://coremltools.readme.io/v7.0/docs/palettization-overview\" rel=\"nofollow\"\u003epalettization\u003c/a\u003e and \u003ca href=\"https://coremltools.readme.io/v7.0/docs/quantization-aware-training\" rel=\"nofollow\"\u003elinear 8-bit quantization\u003c/a\u003e. For these techniques, \u003ccode\u003ecoremltools.optimize.torch.*\u003c/code\u003e includes APIs that require fine-tuning to maintain accuracy at higher compression rates whereas \u003ccode\u003ecoremltools.optimize.coreml.*\u003c/code\u003e includes APIs that are applied post-training and are data-free.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eWe demonstrate how data-free \u003ca href=\"https://coremltools.readme.io/v7.0/docs/post-training-palettization\" rel=\"nofollow\"\u003epost-training palettization\u003c/a\u003e implemented in \u003ccode\u003ecoremltools.optimize.coreml.palettize_weights\u003c/code\u003e enables us to achieve greatly improved performance for Stable Diffusion on mobile devices. This API implements the \u003ca href=\"https://arxiv.org/abs/1701.07204\" rel=\"nofollow\"\u003eFast Exact k-Means\u003c/a\u003e algorithm for optimal weight clustering which yields more accurate palettes. Using \u003ccode\u003e--quantize-nbits {2,4,6,8}\u003c/code\u003e during \u003ca href=\"#converting-models-to-coreml\"\u003econversion\u003c/a\u003e is going to apply this compression to the unet and text_encoder models.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eFor best results, we recommend \u003ca href=\"https://coremltools.readme.io/v7.0/docs/training-time-palettization\" rel=\"nofollow\"\u003etraining-time palettization\u003c/a\u003e: \u003ccode\u003ecoremltools.optimize.torch.palettization.DKMPalettizer\u003c/code\u003e if fine-tuning your model is feasible. This API implements the \u003ca href=\"https://machinelearning.apple.com/research/differentiable-k-means\" rel=\"nofollow\"\u003eDifferentiable k-Means (DKM)\u003c/a\u003e learned palettization algorithm. In this exercise, we stick to post-training palettization for the sake of simplicity and ease of reproducibility.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThe Neural Engine is capable of accelerating models with low-bit palettization: 1, 2, 4, 6 or 8 bits. With iOS 17 and macOS 14, compressed weights for Core ML models can be just-in-time decompressed during runtime (as opposed to ahead-of-time decompression upon load) to match the precision of activation tensors. This yields significant memory savings and enables models to run on devices with smaller RAM (e.g. iPhone 12 Mini). In addition, compressed weights are faster to fetch from memory which reduces the latency of memory bandwidth-bound layers. The just-in-time decompression behavior depends on the compute unit, layer type and hardware generation.\u003c/p\u003e\n\u003cmarkdown-accessiblity-table\u003e\u003ctable\u003e\n\u003cthead\u003e\n\u003ctr\u003e\n\u003cth align=\"center\"\u003eWeight Precision\u003c/th\u003e\n\u003cth align=\"center\"\u003e\u003ccode\u003e--compute-unit\u003c/code\u003e\u003c/th\u003e\n\u003cth\u003e\u003ca href=\"https://huggingface.co/apple/coreml-stable-diffusion-2-1-base\" rel=\"nofollow\"\u003e\u003ccode\u003estabilityai/stable-diffusion-2-1-base\u003c/code\u003e\u003c/a\u003e generating \u003cem\u003e\"a high quality photo of a surfing dog\"\u003c/em\u003e\u003c/th\u003e\n\u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\n\u003ctd align=\"center\"\u003e6-bit\u003c/td\u003e\n\u003ctd align=\"center\"\u003ecpuAndNeuralEngine\u003c/td\u003e\n\u003ctd\u003e\u003ca target=\"_blank\" rel=\"noopener noreferrer\" href=\"/apple/ml-stable-diffusion/blob/main/assets/palette6_cpuandne_readmereel.png\"\u003e\u003cimg src=\"/apple/ml-stable-diffusion/raw/main/assets/palette6_cpuandne_readmereel.png\" style=\"max-width: 100%;\"\u003e\u003c/a\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd align=\"center\"\u003e16-bit\u003c/td\u003e\n\u003ctd align=\"center\"\u003ecpuAndNeuralEngine\u003c/td\u003e\n\u003ctd\u003e\u003ca target=\"_blank\" rel=\"noopener noreferrer\" href=\"/apple/ml-stable-diffusion/blob/main/assets/float16_cpuandne_readmereel.png\"\u003e\u003cimg src=\"/apple/ml-stable-diffusion/raw/main/assets/float16_cpuandne_readmereel.png\" style=\"max-width: 100%;\"\u003e\u003c/a\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd align=\"center\"\u003e16-bit\u003c/td\u003e\n\u003ctd align=\"center\"\u003ecpuAndGPU\u003c/td\u003e\n\u003ctd\u003e\u003ca target=\"_blank\" rel=\"noopener noreferrer\" href=\"/apple/ml-stable-diffusion/blob/main/assets/float16_gpu_readmereel.png\"\u003e\u003cimg src=\"/apple/ml-stable-diffusion/raw/main/assets/float16_gpu_readmereel.png\" style=\"max-width: 100%;\"\u003e\u003c/a\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\u003c/markdown-accessiblity-table\u003e\n\u003cp dir=\"auto\"\u003eNote that there are minor differences across 16-bit (float16) and 6-bit results. These differences are comparable to the differences across float16 and float32 or differences across compute units as exemplified above. We recommend a minimum of 6 bits for palettizing Stable Diffusion. Smaller number of bits (1, 2 and 4) will require either fine-tuning or advanced palettization techniques such as \u003ca href=\"#compression-lower-than-6-bits\"\u003eMBP\u003c/a\u003e.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eResources:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003e\u003ca href=\"https://coremltools.readme.io/v7.0/docs/optimizing-models\" rel=\"nofollow\"\u003eCore ML Tools Docs: Optimizing Models\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://developer.apple.com/videos/play/wwdc2023/10047\" rel=\"nofollow\"\u003eWWDC23 Session Video: Use Core ML Tools for machine learning model compression\u003c/a\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/details\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003e\u003ca name=\"user-content-compression-lower-than-6-bits\"\u003e\u003c/a\u003e Advanced Weight Compression (Lower than 6-bits)\u003c/h2\u003e\u003ca id=\"user-content--advanced-weight-compression-lower-than-6-bits\" class=\"anchor\" aria-label=\"Permalink: Advanced Weight Compression (Lower than 6-bits)\" href=\"#-advanced-weight-compression-lower-than-6-bits\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cdetails\u003e\n \u003csummary\u003e Details (Click to expand) \u003c/summary\u003e\n\u003cp dir=\"auto\"\u003eThis section describes an advanced compression algorithm called \u003ca href=\"https://huggingface.co/blog/stable-diffusion-xl-coreml#what-is-mixed-bit-palettization\" rel=\"nofollow\"\u003eMixed-Bit Palettization (MBP)\u003c/a\u003e built on top of the \u003ca href=\"https://apple.github.io/coremltools/docs-guides/source/post-training-palettization.html\" rel=\"nofollow\"\u003ePost-Training Weight Palettization tools\u003c/a\u003e and using the \u003ca href=\"https://apple.github.io/coremltools/docs-guides/source/mlmodel-utilities.html#get-weights-metadata\" rel=\"nofollow\"\u003eWeights Metadata API\u003c/a\u003e from \u003ca href=\"https://github.com/apple/coremltools\"\u003ecoremltools\u003c/a\u003e.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eMBP builds a per-layer \"palettization recipe\" by picking a suitable number of bits among the Neural Engine supported bit-widths of 1, 2, 4, 6 and 8 in order to achieve the minimum average bit-width while maintaining a desired level of signal strength. The signal strength is measured by comparing the compressed model's output to that of the original float16 model. Given the same random seed and text prompts, PSNR between denoised latents is computed. The compression rate will depend on the model version as well as the tolerance for signal loss (drop in PSNR) since this algorithm is adaptive.\u003c/p\u003e\n\u003cmarkdown-accessiblity-table\u003e\u003ctable\u003e\n\u003cthead\u003e\n\u003ctr\u003e\n\u003cth align=\"center\"\u003e3.41-bit\u003c/th\u003e\n\u003cth align=\"center\"\u003e4.50-bit\u003c/th\u003e\n\u003cth align=\"center\"\u003e6.55-bit\u003c/th\u003e\n\u003cth align=\"center\"\u003e16-bit (original)\u003c/th\u003e\n\u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\n\u003ctd align=\"center\"\u003e\u003ca target=\"_blank\" rel=\"noopener noreferrer\" href=\"/apple/ml-stable-diffusion/blob/main/assets/mbp/a_high_quality_photo_of_a_surfing_dog.7667.final_3.41-bits.png\"\u003e\u003cimg src=\"/apple/ml-stable-diffusion/raw/main/assets/mbp/a_high_quality_photo_of_a_surfing_dog.7667.final_3.41-bits.png\" style=\"max-width: 100%;\"\u003e\u003c/a\u003e\u003c/td\u003e\n\u003ctd align=\"center\"\u003e\u003ca target=\"_blank\" rel=\"noopener noreferrer\" href=\"/apple/ml-stable-diffusion/blob/main/assets/mbp/a_high_quality_photo_of_a_surfing_dog.7667.final_4.50-bits.png\"\u003e\u003cimg src=\"/apple/ml-stable-diffusion/raw/main/assets/mbp/a_high_quality_photo_of_a_surfing_dog.7667.final_4.50-bits.png\" style=\"max-width: 100%;\"\u003e\u003c/a\u003e\u003c/td\u003e\n\u003ctd align=\"center\"\u003e\u003ca target=\"_blank\" rel=\"noopener noreferrer\" href=\"/apple/ml-stable-diffusion/blob/main/assets/mbp/a_high_quality_photo_of_a_surfing_dog.7667.final_6.55-bits.png\"\u003e\u003cimg src=\"/apple/ml-stable-diffusion/raw/main/assets/mbp/a_high_quality_photo_of_a_surfing_dog.7667.final_6.55-bits.png\" style=\"max-width: 100%;\"\u003e\u003c/a\u003e\u003c/td\u003e\n\u003ctd align=\"center\"\u003e\u003ca target=\"_blank\" rel=\"noopener noreferrer\" href=\"/apple/ml-stable-diffusion/blob/main/assets/mbp/a_high_quality_photo_of_a_surfing_dog.7667.final_float16_original.png\"\u003e\u003cimg src=\"/apple/ml-stable-diffusion/raw/main/assets/mbp/a_high_quality_photo_of_a_surfing_dog.7667.final_float16_original.png\" style=\"max-width: 100%;\"\u003e\u003c/a\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\u003c/markdown-accessiblity-table\u003e\n\u003cp dir=\"auto\"\u003eFor example, the original float16 \u003ca href=\"https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0\" rel=\"nofollow\"\u003estabilityai/stable-diffusion-xl-base-1.0\u003c/a\u003e model has an ~82 dB signal strength. Naively applying \u003ca href=\"https://coremltools.readme.io/docs/data-free-quantization\" rel=\"nofollow\"\u003elinear 8-bit quantization\u003c/a\u003e to the Unet model drops the signal to ~65 dB. Instead, applying MBP yields an average of 2.81-bits quantization while maintaining a signal strength of ~67 dB. This technique generally yields better results compared to using \u003ccode\u003e--quantize-nbits\u003c/code\u003e during model conversion but requires a \"pre-analysis\" run that takes up to a few hours on a single GPU (\u003ccode\u003emps\u003c/code\u003e or \u003ccode\u003ecuda\u003c/code\u003e).\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eHere is the signal strength (PSNR in dB) versus model size reduction (% of float16 size) for \u003ccode\u003estabilityai/stable-diffusion-xl-base-1.0\u003c/code\u003e. The \u003ccode\u003e{1,2,4,6,8}-bit\u003c/code\u003e curves are generated by progressively palettizing more layers using a palette with fixed number of bits. The layers were ordered in ascending order of their isolated impact to end-to-end signal strength so the cumulative compression's impact is delayed as much as possible. The mixed-bit curve is based on falling back to a higher number of bits as soon as a layer's isolated impact to end-to-end signal integrity drops below a threshold. Note that all curves based on palettization outperform linear 8-bit quantization at the same model size except for 1-bit.\u003c/p\u003e\n\u003ca target=\"_blank\" rel=\"noopener noreferrer\" href=\"/apple/ml-stable-diffusion/blob/main/assets/mbp/stabilityai_stable-diffusion-xl-base-1.0_psnr_vs_size.png\"\u003e\u003cimg src=\"/apple/ml-stable-diffusion/raw/main/assets/mbp/stabilityai_stable-diffusion-xl-base-1.0_psnr_vs_size.png\" width=\"640\" style=\"max-width: 100%;\"\u003e\u003c/a\u003e\n\u003cp dir=\"auto\"\u003eHere are the steps for applying this technique on another model version:\u003c/p\u003e\n\u003cp dir=\"auto\"\u003e\u003cstrong\u003eStep 1:\u003c/strong\u003e Run the pre-analysis script to generate \"recipes\" with varying signal strength:\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"python -m python_coreml_stable_diffusion.mixed_bit_compression_pre_analysis --model-version \u0026lt;model-version\u0026gt; -o \u0026lt;output-dir\u0026gt;\"\u003e\u003cpre\u003e\u003cspan class=\"pl-s1\"\u003epython\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003em\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003epython_coreml_stable_diffusion\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003emixed_bit_compression_pre_analysis\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003emodel\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003eversion\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e\u0026lt;\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003emodel\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003eversion\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e\u0026gt;\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003eo\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e\u0026lt;\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003eoutput\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003edir\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e\u0026gt;\u003c/span\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eFor popular base models, you may find the pre-computed pre-analysis results \u003ca href=\"https://huggingface.co/apple/coreml-stable-diffusion-mixed-bit-palettization/tree/main/recipes\" rel=\"nofollow\"\u003ehere\u003c/a\u003e. Fine-tuned models models are likely to honor the recipes of their corresponding base models but this is untested.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003e\u003cstrong\u003eStep 2:\u003c/strong\u003e The resulting JSON file from Step 1 will list \"baselines\", e.g.:\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-json notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"{\n \u0026quot;model_version\u0026quot;: \u0026quot;stabilityai/stable-diffusion-xl-base-1.0\u0026quot;,\n \u0026quot;baselines\u0026quot;: {\n \u0026quot;original\u0026quot;: 82.2,\n \u0026quot;linear_8bit\u0026quot;: 66.025,\n \u0026quot;recipe_6.55_bit_mixedpalette\u0026quot;: 79.9,\n \u0026quot;recipe_5.52_bit_mixedpalette\u0026quot;: 78.2,\n \u0026quot;recipe_4.89_bit_mixedpalette\u0026quot;: 76.8,\n \u0026quot;recipe_4.41_bit_mixedpalette\u0026quot;: 75.5,\n \u0026quot;recipe_4.04_bit_mixedpalette\u0026quot;: 73.2,\n \u0026quot;recipe_3.67_bit_mixedpalette\u0026quot;: 72.2,\n \u0026quot;recipe_3.32_bit_mixedpalette\u0026quot;: 71.4,\n \u0026quot;recipe_3.19_bit_mixedpalette\u0026quot;: 70.4,\n \u0026quot;recipe_3.08_bit_mixedpalette\u0026quot;: 69.6,\n \u0026quot;recipe_2.98_bit_mixedpalette\u0026quot;: 68.6,\n \u0026quot;recipe_2.90_bit_mixedpalette\u0026quot;: 67.8,\n \u0026quot;recipe_2.83_bit_mixedpalette\u0026quot;: 67.0,\n \u0026quot;recipe_2.71_bit_mixedpalette\u0026quot;: 66.3\n },\n}\"\u003e\u003cpre\u003e{\n \u003cspan class=\"pl-ent\"\u003e\"model_version\"\u003c/span\u003e: \u003cspan class=\"pl-s\"\u003e\u003cspan class=\"pl-pds\"\u003e\"\u003c/span\u003estabilityai/stable-diffusion-xl-base-1.0\u003cspan class=\"pl-pds\"\u003e\"\u003c/span\u003e\u003c/span\u003e,\n \u003cspan class=\"pl-ent\"\u003e\"baselines\"\u003c/span\u003e: {\n \u003cspan class=\"pl-ent\"\u003e\"original\"\u003c/span\u003e: \u003cspan class=\"pl-c1\"\u003e82.2\u003c/span\u003e,\n \u003cspan class=\"pl-ent\"\u003e\"linear_8bit\"\u003c/span\u003e: \u003cspan class=\"pl-c1\"\u003e66.025\u003c/span\u003e,\n \u003cspan class=\"pl-ent\"\u003e\"recipe_6.55_bit_mixedpalette\"\u003c/span\u003e: \u003cspan class=\"pl-c1\"\u003e79.9\u003c/span\u003e,\n \u003cspan class=\"pl-ent\"\u003e\"recipe_5.52_bit_mixedpalette\"\u003c/span\u003e: \u003cspan class=\"pl-c1\"\u003e78.2\u003c/span\u003e,\n \u003cspan class=\"pl-ent\"\u003e\"recipe_4.89_bit_mixedpalette\"\u003c/span\u003e: \u003cspan class=\"pl-c1\"\u003e76.8\u003c/span\u003e,\n \u003cspan class=\"pl-ent\"\u003e\"recipe_4.41_bit_mixedpalette\"\u003c/span\u003e: \u003cspan class=\"pl-c1\"\u003e75.5\u003c/span\u003e,\n \u003cspan class=\"pl-ent\"\u003e\"recipe_4.04_bit_mixedpalette\"\u003c/span\u003e: \u003cspan class=\"pl-c1\"\u003e73.2\u003c/span\u003e,\n \u003cspan class=\"pl-ent\"\u003e\"recipe_3.67_bit_mixedpalette\"\u003c/span\u003e: \u003cspan class=\"pl-c1\"\u003e72.2\u003c/span\u003e,\n \u003cspan class=\"pl-ent\"\u003e\"recipe_3.32_bit_mixedpalette\"\u003c/span\u003e: \u003cspan class=\"pl-c1\"\u003e71.4\u003c/span\u003e,\n \u003cspan class=\"pl-ent\"\u003e\"recipe_3.19_bit_mixedpalette\"\u003c/span\u003e: \u003cspan class=\"pl-c1\"\u003e70.4\u003c/span\u003e,\n \u003cspan class=\"pl-ent\"\u003e\"recipe_3.08_bit_mixedpalette\"\u003c/span\u003e: \u003cspan class=\"pl-c1\"\u003e69.6\u003c/span\u003e,\n \u003cspan class=\"pl-ent\"\u003e\"recipe_2.98_bit_mixedpalette\"\u003c/span\u003e: \u003cspan class=\"pl-c1\"\u003e68.6\u003c/span\u003e,\n \u003cspan class=\"pl-ent\"\u003e\"recipe_2.90_bit_mixedpalette\"\u003c/span\u003e: \u003cspan class=\"pl-c1\"\u003e67.8\u003c/span\u003e,\n \u003cspan class=\"pl-ent\"\u003e\"recipe_2.83_bit_mixedpalette\"\u003c/span\u003e: \u003cspan class=\"pl-c1\"\u003e67.0\u003c/span\u003e,\n \u003cspan class=\"pl-ent\"\u003e\"recipe_2.71_bit_mixedpalette\"\u003c/span\u003e: \u003cspan class=\"pl-c1\"\u003e66.3\u003c/span\u003e\n },\n}\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eAmong these baselines, select a recipe based on your desired signal strength. We recommend palettizing to ~4 bits depending on the use case even if the signal integrity for lower bit values are higher than the linear 8-bit quantization baseline.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eFinally, apply the selected recipe to the float16 Core ML model as follows:\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"python -m python_coreml_stable_diffusion.mixed_bit_compression_apply --mlpackage-path \u0026lt;path-to-float16-unet-mlpackage\u0026gt; -o \u0026lt;output-dir\u0026gt; --pre-analysis-json-path \u0026lt;path-to--pre-analysis-json\u0026gt; --selected-recipe \u0026lt;selected-recipe-string-key\u0026gt;\"\u003e\u003cpre\u003e\u003cspan class=\"pl-s1\"\u003epython\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003em\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003epython_coreml_stable_diffusion\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003emixed_bit_compression_apply\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003emlpackage\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003epath\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e\u0026lt;\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003epath\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003eto\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003efloat16\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003eunet\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003emlpackage\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e\u0026gt;\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003eo\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e\u0026lt;\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003eoutput\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003edir\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e\u0026gt;\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003epre\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003eanalysis\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003ejson\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003epath\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e\u0026lt;\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003epath\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003eto\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003epre\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003eanalysis\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003ejson\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e\u0026gt;\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003eselected\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003erecipe\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e\u0026lt;\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003eselected\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003erecipe\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003estring\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003ekey\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e\u0026gt;\u003c/span\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eAn example \u003ccode\u003e\u0026lt;selected-recipe-string-key\u0026gt;\u003c/code\u003e would be \u003ccode\u003e\"recipe_4.50_bit_mixedpalette\"\u003c/code\u003e which achieves an average of 4.50-bits compression (compressed from ~5.2GB to ~1.46GB for SDXL). Please note that signal strength does not directly map to image-text alignment. Always verify that your MBP-compressed model variant is accurately generating images for your test prompts.\u003c/p\u003e\n\u003c/details\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003e\u003ca name=\"user-content-activation-quant\"\u003e\u003c/a\u003e Activation Quantization\u003c/h2\u003e\u003ca id=\"user-content--activation-quantization\" class=\"anchor\" aria-label=\"Permalink: Activation Quantization\" href=\"#-activation-quantization\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cdetails\u003e\n \u003csummary\u003e Details (Click to expand) \u003c/summary\u003e\n\u003cp dir=\"auto\"\u003eOn newer hardware with A17 Pro or M4 chips, such as the iPhone 15 Pro, quantizing both activations and weight to int8 can leverage optimized compute on the Neural Engine which can be used to improve runtime latency in compute-bound models.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eIn this section, we demonstrate how to apply \u003ca href=\"https://apple.github.io/coremltools/docs-guides/source/opt-quantization-algos.html#post-training-data-calibration-activation-quantization\" rel=\"nofollow\"\u003ePost Training Activation Quantization\u003c/a\u003e, using calibration data, on Stable Diffusion UNet model.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eSimilar to Mixed-Bit Palettization (MBP) described \u003ca href=\"#a-namecompression-lower-than-6-bitsa-advanced-weight-compression-lower-than-6-bits\"\u003eabove\u003c/a\u003e, first, a per-layer analysis is run to determine which intermediate activations are more sensitive to 8-bit compression.\nLess sensitive layers are weight and activation quantized (W8A8), whereas more sensitive layers are only weight quantized (W8A16).\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eHere are the steps for applying this technique:\u003c/p\u003e\n\u003cp dir=\"auto\"\u003e\u003cstrong\u003eStep 1:\u003c/strong\u003e Generate calibration data\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"python -m python_coreml_stable_diffusion.activation_quantization --model-version \u0026lt;model-version\u0026gt; --generate-calibration-data -o \u0026lt;output-dir\u0026gt;\"\u003e\u003cpre\u003e\u003cspan class=\"pl-s1\"\u003epython\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003em\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003epython_coreml_stable_diffusion\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003eactivation_quantization\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003emodel\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003eversion\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e\u0026lt;\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003emodel\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003eversion\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e\u0026gt;\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003egenerate\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003ecalibration\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003edata\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003eo\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e\u0026lt;\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003eoutput\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003edir\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e\u0026gt;\u003c/span\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eA set of calibration text prompts are run through StableDiffusionPipeline and UNet model inputs are recorded and stored as pickle files in \u003ccode\u003ecalibration_data_\u0026lt;model-version\u0026gt;\u003c/code\u003e folder inside specified output directory.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003e\u003cstrong\u003eStep 2:\u003c/strong\u003e Run layer-wise sensitivity analysis\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"python -m python_coreml_stable_diffusion.activation_quantization --model-version \u0026lt;model-version\u0026gt; --layerwise-sensitivity --calibration-nsamples \u0026lt;num-samples\u0026gt; -o \u0026lt;output-dir\u0026gt;\"\u003e\u003cpre\u003e\u003cspan class=\"pl-s1\"\u003epython\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003em\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003epython_coreml_stable_diffusion\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003eactivation_quantization\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003emodel\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003eversion\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e\u0026lt;\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003emodel\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003eversion\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e\u0026gt;\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003elayerwise\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003esensitivity\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003ecalibration\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003ensamples\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e\u0026lt;\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003enum\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003esamples\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e\u0026gt;\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003eo\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e\u0026lt;\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003eoutput\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003edir\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e\u0026gt;\u003c/span\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eThis will run the analysis on all Convolutional and Attention (Einsum) modules in the model.\nFor each module, a compressed version is generated by quantizing only that layer’s weights and activations.\nThen the PSNR between the outputs of the compressed and original model is calculated, using the same random seed and text prompts.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThis analysis takes up to a few hours on a single GPU (cuda). The number of calibration samples used to quantize the model can be reduced to speed up the process.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThe resulting JSON file looks like this:\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-json notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"{\n \u0026quot;conv\u0026quot;: {\n \u0026quot;conv_in\u0026quot;: 30.74,\n \u0026quot;down_blocks.0.attentions.0.proj_in\u0026quot;: 38.93,\n \u0026quot;down_blocks.0.attentions.0.transformer_blocks.0.attn1.to_q\u0026quot;: 48.15,\n \u0026quot;down_blocks.0.attentions.0.transformer_blocks.0.attn1.to_k\u0026quot;: 50.13,\n \u0026quot;down_blocks.0.attentions.0.transformer_blocks.0.attn1.to_v\u0026quot;: 45.70,\n \u0026quot;down_blocks.0.attentions.0.transformer_blocks.0.attn1.to_out.0\u0026quot;: 39.56,\n ...\n },\n \u0026quot;einsum\u0026quot;: {\n \u0026quot;down_blocks.0.attentions.0.transformer_blocks.0.attn1.einsum\u0026quot;: 25.34,\n \u0026quot;down_blocks.0.attentions.0.transformer_blocks.0.attn2.einsum\u0026quot;: 31.76,\n \u0026quot;down_blocks.0.attentions.1.transformer_blocks.0.attn1.einsum\u0026quot;: 23.40,\n \u0026quot;down_blocks.0.attentions.1.transformer_blocks.0.attn2.einsum\u0026quot;: 31.56,\n ...\n },\n \u0026quot;model_version\u0026quot;: \u0026quot;stabilityai/stable-diffusion-2-1-base\u0026quot;\n}\"\u003e\u003cpre\u003e{\n \u003cspan class=\"pl-ent\"\u003e\"conv\"\u003c/span\u003e: {\n \u003cspan class=\"pl-ent\"\u003e\"conv_in\"\u003c/span\u003e: \u003cspan class=\"pl-c1\"\u003e30.74\u003c/span\u003e,\n \u003cspan class=\"pl-ent\"\u003e\"down_blocks.0.attentions.0.proj_in\"\u003c/span\u003e: \u003cspan class=\"pl-c1\"\u003e38.93\u003c/span\u003e,\n \u003cspan class=\"pl-ent\"\u003e\"down_blocks.0.attentions.0.transformer_blocks.0.attn1.to_q\"\u003c/span\u003e: \u003cspan class=\"pl-c1\"\u003e48.15\u003c/span\u003e,\n \u003cspan class=\"pl-ent\"\u003e\"down_blocks.0.attentions.0.transformer_blocks.0.attn1.to_k\"\u003c/span\u003e: \u003cspan class=\"pl-c1\"\u003e50.13\u003c/span\u003e,\n \u003cspan class=\"pl-ent\"\u003e\"down_blocks.0.attentions.0.transformer_blocks.0.attn1.to_v\"\u003c/span\u003e: \u003cspan class=\"pl-c1\"\u003e45.70\u003c/span\u003e,\n \u003cspan class=\"pl-ent\"\u003e\"down_blocks.0.attentions.0.transformer_blocks.0.attn1.to_out.0\"\u003c/span\u003e: \u003cspan class=\"pl-c1\"\u003e39.56\u003c/span\u003e,\n \u003cspan class=\"pl-ii\"\u003e...\u003c/span\u003e\n },\n \u003cspan class=\"pl-ent\"\u003e\"einsum\"\u003c/span\u003e: {\n \u003cspan class=\"pl-ent\"\u003e\"down_blocks.0.attentions.0.transformer_blocks.0.attn1.einsum\"\u003c/span\u003e: \u003cspan class=\"pl-c1\"\u003e25.34\u003c/span\u003e,\n \u003cspan class=\"pl-ent\"\u003e\"down_blocks.0.attentions.0.transformer_blocks.0.attn2.einsum\"\u003c/span\u003e: \u003cspan class=\"pl-c1\"\u003e31.76\u003c/span\u003e,\n \u003cspan class=\"pl-ent\"\u003e\"down_blocks.0.attentions.1.transformer_blocks.0.attn1.einsum\"\u003c/span\u003e: \u003cspan class=\"pl-c1\"\u003e23.40\u003c/span\u003e,\n \u003cspan class=\"pl-ent\"\u003e\"down_blocks.0.attentions.1.transformer_blocks.0.attn2.einsum\"\u003c/span\u003e: \u003cspan class=\"pl-c1\"\u003e31.56\u003c/span\u003e,\n \u003cspan class=\"pl-ii\"\u003e...\u003c/span\u003e\n },\n \u003cspan class=\"pl-ent\"\u003e\"model_version\"\u003c/span\u003e: \u003cspan class=\"pl-s\"\u003e\u003cspan class=\"pl-pds\"\u003e\"\u003c/span\u003estabilityai/stable-diffusion-2-1-base\u003cspan class=\"pl-pds\"\u003e\"\u003c/span\u003e\u003c/span\u003e\n}\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003e\u003cstrong\u003eStep 3:\u003c/strong\u003e Generate quantized model\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eUsing calibration data and layer-wise sensitivity the quantized CoreML model can be generated as follows:\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"python -m python_coreml_stable_diffusion.activation_quantization --model-version \u0026lt;model-version\u0026gt; --quantize-pytorch --conv-psnr 38 --attn-psnr 26 -o \u0026lt;output-dir\u0026gt;\"\u003e\u003cpre\u003e\u003cspan class=\"pl-s1\"\u003epython\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003em\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003epython_coreml_stable_diffusion\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003eactivation_quantization\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003emodel\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003eversion\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e\u0026lt;\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003emodel\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003eversion\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e\u0026gt;\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003equantize\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003epytorch\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003econv\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003epsnr\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e38\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003eattn\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003epsnr\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e26\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003eo\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e\u0026lt;\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003eoutput\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003edir\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e\u0026gt;\u003c/span\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eThe PSNR thresholds determine which layers will be activation quantized. This number can be tuned to trade-off between output quality and inference latency.\u003c/p\u003e\n\u003c/details\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003e\u003ca name=\"user-content-using-stable-diffusion-3\"\u003e\u003c/a\u003e Using Stable Diffusion 3\u003c/h2\u003e\u003ca id=\"user-content--using-stable-diffusion-3\" class=\"anchor\" aria-label=\"Permalink: Using Stable Diffusion 3\" href=\"#-using-stable-diffusion-3\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cdetails\u003e\n \u003csummary\u003e Details (Click to expand) \u003c/summary\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eModel Conversion\u003c/h3\u003e\u003ca id=\"user-content-model-conversion\" class=\"anchor\" aria-label=\"Permalink: Model Conversion\" href=\"#model-conversion\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eStable Diffusion 3 uses some new and some old models to run. For the text encoders, the conversion can be done using a similar command as before with the \u003ccode\u003e--sd3-version\u003c/code\u003e flag.\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-shell notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"python -m python_coreml_stable_diffusion.torch2coreml --model-version stabilityai/stable-diffusion-3-medium --bundle-resources-for-swift-cli --convert-text-encoder --sd3-version -o \u0026lt;output-dir\u0026gt;\"\u003e\u003cpre\u003epython -m python_coreml_stable_diffusion.torch2coreml --model-version stabilityai/stable-diffusion-3-medium --bundle-resources-for-swift-cli --convert-text-encoder --sd3-version -o \u003cspan class=\"pl-k\"\u003e\u0026lt;\u003c/span\u003eoutput-dir\u003cspan class=\"pl-k\"\u003e\u0026gt;\u003c/span\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eFor the new models (MMDiT, a new VAE with 16 channels, and the T5 text encoder), there are a number of new CLI flags that utilize the \u003ca href=\"https://www.github.com/argmaxinc/DiffusionKit\"\u003eDiffusionKit\u003c/a\u003e repo:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003e\u003ccode\u003e--sd3-version\u003c/code\u003e: Indicates to the converter to treat this as a Stable Diffusion 3 model\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e--convert-mmdit\u003c/code\u003e: Convert the MMDiT model\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e--convert-vae-decoder\u003c/code\u003e: Convert the new VAE model (this will use the 16 channel version if --sd3-version is set)\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e--include-t5\u003c/code\u003e: Downloads and includes a pre-converted T5 text encoder in the conversion\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp dir=\"auto\"\u003ee.g.:\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-shell notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"python -m python_coreml_stable_diffusion.torch2coreml --model-version stabilityai/stable-diffusion-3-medium --bundle-resources-for-swift-cli --convert-vae-decoder --convert-mmdit --include-t5 --sd3-version -o \u0026lt;output-dir\u0026gt;\"\u003e\u003cpre\u003epython -m python_coreml_stable_diffusion.torch2coreml --model-version stabilityai/stable-diffusion-3-medium --bundle-resources-for-swift-cli --convert-vae-decoder --convert-mmdit --include-t5 --sd3-version -o \u003cspan class=\"pl-k\"\u003e\u0026lt;\u003c/span\u003eoutput-dir\u003cspan class=\"pl-k\"\u003e\u0026gt;\u003c/span\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eTo convert the full pipeline with at 1024x1024 resolution, the following command may be used:\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-shell notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"python -m python_coreml_stable_diffusion.torch2coreml --model-version stabilityai/stable-diffusion-3-medium --bundle-resources-for-swift-cli --convert-text-encoder --convert-vae-decoder --convert-mmdit --include-t5 --sd3-version --latent-h 128 --latent-w 128 -o \u0026lt;output-dir\u0026gt;\"\u003e\u003cpre\u003epython -m python_coreml_stable_diffusion.torch2coreml --model-version stabilityai/stable-diffusion-3-medium --bundle-resources-for-swift-cli --convert-text-encoder --convert-vae-decoder --convert-mmdit --include-t5 --sd3-version --latent-h 128 --latent-w 128 -o \u003cspan class=\"pl-k\"\u003e\u0026lt;\u003c/span\u003eoutput-dir\u003cspan class=\"pl-k\"\u003e\u0026gt;\u003c/span\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eKeep in mind that the MMDiT model is quite large and will require increasingly more memory and time to convert as the latent resolution increases.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eAlso note that currently the MMDiT model requires fp32 and therefore only supports \u003ccode\u003eCPU_AND_GPU\u003c/code\u003e compute units and \u003ccode\u003eORIGINAL\u003c/code\u003e attention implementation (the default for this pipeline).\u003c/p\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eSwift Inference\u003c/h3\u003e\u003ca id=\"user-content-swift-inference\" class=\"anchor\" aria-label=\"Permalink: Swift Inference\" href=\"#swift-inference\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eSwift inference for Stable Diffusion 3 is similar to the previous versions. The only difference is that the \u003ccode\u003e--sd3\u003c/code\u003e flag should be used to indicate that the model is a Stable Diffusion 3 model.\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-shell notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"swift run StableDiffusionSample \u0026lt;prompt\u0026gt; --resource-path \u0026lt;output-mlpackages-directory/Resources\u0026gt; --output-path \u0026lt;output-dir\u0026gt; --compute-units cpuAndGPU --sd3\"\u003e\u003cpre\u003eswift run StableDiffusionSample \u003cspan class=\"pl-k\"\u003e\u0026lt;\u003c/span\u003eprompt\u003cspan class=\"pl-k\"\u003e\u0026gt;\u003c/span\u003e --resource-path \u003cspan class=\"pl-k\"\u003e\u0026lt;\u003c/span\u003eoutput-mlpackages-directory/Resources\u003cspan class=\"pl-k\"\u003e\u0026gt;\u003c/span\u003e --output-path \u003cspan class=\"pl-k\"\u003e\u0026lt;\u003c/span\u003eoutput-dir\u003cspan class=\"pl-k\"\u003e\u0026gt;\u003c/span\u003e --compute-units cpuAndGPU --sd3\u003c/pre\u003e\u003c/div\u003e\n\u003c/details\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003e\u003ca name=\"user-content-using-stable-diffusion-xl\"\u003e\u003c/a\u003e Using Stable Diffusion XL\u003c/h2\u003e\u003ca id=\"user-content--using-stable-diffusion-xl\" class=\"anchor\" aria-label=\"Permalink: Using Stable Diffusion XL\" href=\"#-using-stable-diffusion-xl\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cdetails\u003e\n \u003csummary\u003e Details (Click to expand) \u003c/summary\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eModel Conversion\u003c/h3\u003e\u003ca id=\"user-content-model-conversion-1\" class=\"anchor\" aria-label=\"Permalink: Model Conversion\" href=\"#model-conversion-1\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003ee.g.:\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-shell notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"python -m python_coreml_stable_diffusion.torch2coreml --convert-unet --convert-vae-decoder --convert-text-encoder --xl-version --model-version stabilityai/stable-diffusion-xl-base-1.0 --refiner-version stabilityai/stable-diffusion-xl-refiner-1.0 --bundle-resources-for-swift-cli --attention-implementation {ORIGINAL,SPLIT_EINSUM} -o \u0026lt;output-dir\u0026gt;\"\u003e\u003cpre\u003epython -m python_coreml_stable_diffusion.torch2coreml --convert-unet --convert-vae-decoder --convert-text-encoder --xl-version --model-version stabilityai/stable-diffusion-xl-base-1.0 --refiner-version stabilityai/stable-diffusion-xl-refiner-1.0 --bundle-resources-for-swift-cli --attention-implementation {ORIGINAL,SPLIT_EINSUM} -o \u003cspan class=\"pl-k\"\u003e\u0026lt;\u003c/span\u003eoutput-dir\u003cspan class=\"pl-k\"\u003e\u0026gt;\u003c/span\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003e\u003ccode\u003e--xl-version\u003c/code\u003e: Additional argument to pass to the conversion script when specifying an XL model\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e--refiner-version\u003c/code\u003e: Additional argument to pass to the conversion script when specifying an XL refiner model, required for \u003ca href=\"https://huggingface.co/docs/diffusers/main/en/api/pipelines/stable_diffusion/stable_diffusion_xl#1-ensemble-of-expert-denoisers\" rel=\"nofollow\"\u003e\"Ensemble of Expert Denoisers\"\u003c/a\u003e inference.\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e--attention-implementation\u003c/code\u003e: \u003ccode\u003eORIGINAL\u003c/code\u003e is recommended for \u003ccode\u003ecpuAndGPU\u003c/code\u003e for deployment on Mac\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e--attention-implementation\u003c/code\u003e: \u003ccode\u003eSPLIT_EINSUM\u003c/code\u003e is recommended for \u003ccode\u003ecpuAndNeuralEngine\u003c/code\u003e for deployment on iPhone \u0026amp; iPad\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e--attention-implementation\u003c/code\u003e: \u003ccode\u003eSPLIT_EINSUM_V2\u003c/code\u003e is not recommended for Stable Diffusion XL because of prohibitively long compilation time\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eTip:\u003c/strong\u003e Adding \u003ccode\u003e--latent-h 96 --latent-w 96\u003c/code\u003e is recommended for iOS and iPadOS deployment which leads to 768x768 generation as opposed to the default 1024x1024.\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eTip:\u003c/strong\u003e Due to known float16 overflow issues in the original Stable Diffusion XL VAE, \u003ca href=\"https://github.com/apple/ml-stable-diffusion/blob/main/python_coreml_stable_diffusion/torch2coreml.py#L486\"\u003ethe model conversion script enforces float32 precision\u003c/a\u003e. Using a custom VAE version such as \u003ca href=\"https://huggingface.co/madebyollin/sdxl-vae-fp16-fix\" rel=\"nofollow\"\u003emadebyollin/sdxl-vae-fp16-fix\u003c/a\u003e by \u003ca href=\"https://github.com/madebyollin\"\u003e@madebyollin\u003c/a\u003e via \u003ccode\u003e--custom-vae-version madebyollin/sdxl-vae-fp16-fix\u003c/code\u003e will restore the default float16 precision for VAE.\u003c/li\u003e\n\u003c/ul\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eSwift Inference\u003c/h3\u003e\u003ca id=\"user-content-swift-inference-1\" class=\"anchor\" aria-label=\"Permalink: Swift Inference\" href=\"#swift-inference-1\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cdiv class=\"highlight highlight-source-shell notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"swift run StableDiffusionSample \u0026lt;prompt\u0026gt; --resource-path \u0026lt;output-mlpackages-directory/Resources\u0026gt; --output-path \u0026lt;output-dir\u0026gt; --compute-units {cpuAndGPU,cpuAndNeuralEngine} --xl\"\u003e\u003cpre\u003eswift run StableDiffusionSample \u003cspan class=\"pl-k\"\u003e\u0026lt;\u003c/span\u003eprompt\u003cspan class=\"pl-k\"\u003e\u0026gt;\u003c/span\u003e --resource-path \u003cspan class=\"pl-k\"\u003e\u0026lt;\u003c/span\u003eoutput-mlpackages-directory/Resources\u003cspan class=\"pl-k\"\u003e\u0026gt;\u003c/span\u003e --output-path \u003cspan class=\"pl-k\"\u003e\u0026lt;\u003c/span\u003eoutput-dir\u003cspan class=\"pl-k\"\u003e\u0026gt;\u003c/span\u003e --compute-units {cpuAndGPU,cpuAndNeuralEngine} --xl\u003c/pre\u003e\u003c/div\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003eOnly the \u003ccode\u003ebase\u003c/code\u003e model is required, \u003ccode\u003erefiner\u003c/code\u003e model is optional and will be used by default if provided in the resource directory\u003c/li\u003e\n\u003cli\u003eControlNet for XL is not yet supported\u003c/li\u003e\n\u003c/ul\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003ePython Inference\u003c/h3\u003e\u003ca id=\"user-content-python-inference\" class=\"anchor\" aria-label=\"Permalink: Python Inference\" href=\"#python-inference\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cdiv class=\"highlight highlight-source-shell notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"python -m python_coreml_stable_diffusion.pipeline --prompt \u0026lt;prompt\u0026gt; --compute-unit {CPU_AND_GPU,CPU_AND_NE} -o \u0026lt;output-dir\u0026gt; -i \u0026lt;output-mlpackages-directory/Resources\u0026gt; --model-version stabilityai/stable-diffusion-xl-base-1.0\"\u003e\u003cpre\u003epython -m python_coreml_stable_diffusion.pipeline --prompt \u003cspan class=\"pl-k\"\u003e\u0026lt;\u003c/span\u003eprompt\u003cspan class=\"pl-k\"\u003e\u0026gt;\u003c/span\u003e --compute-unit {CPU_AND_GPU,CPU_AND_NE} -o \u003cspan class=\"pl-k\"\u003e\u0026lt;\u003c/span\u003eoutput-dir\u003cspan class=\"pl-k\"\u003e\u0026gt;\u003c/span\u003e -i \u003cspan class=\"pl-k\"\u003e\u0026lt;\u003c/span\u003eoutput-mlpackages-directory/Resources\u003cspan class=\"pl-k\"\u003e\u0026gt;\u003c/span\u003e --model-version stabilityai/stable-diffusion-xl-base-1.0\u003c/pre\u003e\u003c/div\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003e\u003ccode\u003erefiner\u003c/code\u003e model is not yet supported\u003c/li\u003e\n\u003cli\u003eControlNet for XL is not yet supported\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/details\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003e\u003ca name=\"user-content-using-controlnet\"\u003e\u003c/a\u003e Using ControlNet\u003c/h2\u003e\u003ca id=\"user-content--using-controlnet\" class=\"anchor\" aria-label=\"Permalink: Using ControlNet\" href=\"#-using-controlnet\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cdetails\u003e\n \u003csummary\u003e Details (Click to expand) \u003c/summary\u003e\n\u003cp dir=\"auto\"\u003eExample results using the prompt \u003cem\u003e\"a high quality photo of a surfing dog\"\u003c/em\u003e conditioned on the scribble (leftmost):\u003c/p\u003e\n\u003ca target=\"_blank\" rel=\"noopener noreferrer\" href=\"/apple/ml-stable-diffusion/blob/main/assets/controlnet_readme_reel.png\"\u003e\u003cimg src=\"/apple/ml-stable-diffusion/raw/main/assets/controlnet_readme_reel.png\" style=\"max-width: 100%;\"\u003e\u003c/a\u003e\n\u003cp dir=\"auto\"\u003e\u003ca href=\"https://huggingface.co/lllyasviel/ControlNet\" rel=\"nofollow\"\u003eControlNet\u003c/a\u003e allows users to condition image generation with Stable Diffusion on signals such as edge maps, depth maps, segmentation maps, scribbles and pose. Thanks to \u003ca href=\"https://github.com/apple/ml-stable-diffusion/pull/153\" data-hovercard-type=\"pull_request\" data-hovercard-url=\"/apple/ml-stable-diffusion/pull/153/hovercard\"\u003e@ryu38's contribution\u003c/a\u003e, both the Python CLI and the Swift package support ControlNet models. Please refer to \u003ca href=\"#converting-models-to-coreml\"\u003ethis section\u003c/a\u003e for details on setting up Stable Diffusion with ControlNet.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eNote that ControlNet is not yet supported for Stable Diffusion XL.\u003c/p\u003e\n\u003c/details\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003e\u003ca name=\"user-content-system-multilingual-text-encoder\"\u003e\u003c/a\u003e Using the System Multilingual Text Encoder\u003c/h2\u003e\u003ca id=\"user-content--using-the-system-multilingual-text-encoder\" class=\"anchor\" aria-label=\"Permalink: Using the System Multilingual Text Encoder\" href=\"#-using-the-system-multilingual-text-encoder\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cdetails\u003e\n \u003csummary\u003e Details (Click to expand) \u003c/summary\u003e\n\u003cp dir=\"auto\"\u003eWith iOS 17 and macOS 14, \u003ccode\u003eNaturalLanguage\u003c/code\u003e framework introduced the \u003ca href=\"https://developer.apple.com/documentation/naturallanguage/nlcontextualembedding\" rel=\"nofollow\"\u003eNLContextualEmbedding\u003c/a\u003e which provides Transformer-based textual embeddings for Latin (20 languages), Cyrillic (4 languages) and CJK (3 languages) scripts. The WWDC23 session titled \u003ca href=\"https://developer.apple.com/videos/play/wwdc2023/10042\" rel=\"nofollow\"\u003eExplore Natural Language multilingual models\u003c/a\u003e demonstrated how this powerful new model can be used by developers to train downstream tasks such as multilingual image generation with Stable Diffusion.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThe code to reproduce this demo workflow is made available in this repository. There are several ways in which this workflow can be implemented. Here is an example:\u003c/p\u003e\n\u003cp dir=\"auto\"\u003e\u003cstrong\u003eStep 1:\u003c/strong\u003e Curate an image-text dataset with the desired languages.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003e\u003cstrong\u003eStep 2:\u003c/strong\u003e Pre-compute the NLContextualEmbedding values and replace the text strings with these embedding vectors in your dataset.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003e\u003cstrong\u003eStep 3:\u003c/strong\u003e Fine-tune a base model from Hugging Face Hub that is compatible with the \u003ca href=\"https://huggingface.co/docs/diffusers/api/pipelines/stable_diffusion/overview\" rel=\"nofollow\"\u003eStableDiffusionPipeline\u003c/a\u003e by using your new dataset and replacing the default text_encoder with your pre-computed NLContextualEmbedding values.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003e\u003cstrong\u003eStep 4:\u003c/strong\u003e In order to be able to swap the text_encoder of a base model without training new layers, the base model's \u003ccode\u003etext_encoder.hidden_size\u003c/code\u003e must match that of NLContextualEmbedding. If it doesn't, you will need to train a linear projection layer to map between the two dimensionalities. After fine-tuning, this linear layer should be converted to CoreML as follows:\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-shell notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"python -m python_coreml_stable_diffusion.multilingual_projection --input-path \u0026lt;path-to-projection-torchscript\u0026gt; --output-dir \u0026lt;output-dir\u0026gt;\"\u003e\u003cpre\u003epython -m python_coreml_stable_diffusion.multilingual_projection --input-path \u003cspan class=\"pl-k\"\u003e\u0026lt;\u003c/span\u003epath-to-projection-torchscript\u003cspan class=\"pl-k\"\u003e\u0026gt;\u003c/span\u003e --output-dir \u003cspan class=\"pl-k\"\u003e\u0026lt;\u003c/span\u003eoutput-dir\u003cspan class=\"pl-k\"\u003e\u0026gt;\u003c/span\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eThe command above will yield a \u003ccode\u003eMultilingualTextEncoderProjection.mlmodelc\u003c/code\u003e file under \u003ccode\u003e--output-dir\u003c/code\u003e and this should be colocated with the rest of the Core ML model assets that were generated through \u003ccode\u003e--bundle-resources-for-swift-cli\u003c/code\u003e.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003e\u003cstrong\u003eStep 5:\u003c/strong\u003e The multilingual system text encoder can now be invoked by setting \u003ccode\u003euseMultilingualTextEncoder\u003c/code\u003e to true when initializing a pipeline or setting \u003ccode\u003e--use-multilingual-text-encoder\u003c/code\u003e in the CLI. Note that the model assets are distributed over-the-air so the first invocation will trigger asset downloads which is less than 100MB.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eResources:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003e\u003ca href=\"https://developer.apple.com/videos/play/wwdc2023/10042\" rel=\"nofollow\"\u003eWWDC23 Session Video: Explore Natural Language multilingual models\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://developer.apple.com/documentation/naturallanguage/nlcontextualembedding\" rel=\"nofollow\"\u003eNLContextualEmbedding API Documentation\u003c/a\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/details\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003e\u003ca name=\"user-content-using-converted-weights\"\u003e\u003c/a\u003e Using Ready-made Core ML Models from Hugging Face Hub\u003c/h2\u003e\u003ca id=\"user-content--using-ready-made-core-ml-models-from-hugging-face-hub\" class=\"anchor\" aria-label=\"Permalink: Using Ready-made Core ML Models from Hugging Face Hub\" href=\"#-using-ready-made-core-ml-models-from-hugging-face-hub\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cdetails\u003e\n \u003csummary\u003e Click to expand \u003c/summary\u003e\n\u003cp dir=\"auto\"\u003e🤗 Hugging Face ran the \u003ca href=\"#converting-models-to-coreml\"\u003econversion procedure\u003c/a\u003e on the following models and made the Core ML weights publicly available on the Hub. If you would like to convert a version of Stable Diffusion that is not already available on the Hub, please refer to the \u003ca href=\"#converting-models-to-coreml\"\u003eConverting Models to Core ML\u003c/a\u003e.\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003e\n\u003cp dir=\"auto\"\u003e6-bit quantized models (suitable for iOS 17 and macOS 14):\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003e\u003ca href=\"https://huggingface.co/apple/coreml-stable-diffusion-1-4-palettized\" rel=\"nofollow\"\u003e\u003ccode\u003eCompVis/stable-diffusion-v1-4\u003c/code\u003e\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://huggingface.co/apple/coreml-stable-diffusion-v1-5-palettized\" rel=\"nofollow\"\u003e\u003ccode\u003erunwayml/stable-diffusion-v1-5\u003c/code\u003e\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://huggingface.co/apple/coreml-stable-diffusion-2-base-palettized\" rel=\"nofollow\"\u003e\u003ccode\u003estabilityai/stable-diffusion-2-base\u003c/code\u003e\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://huggingface.co/apple/coreml-stable-diffusion-2-1-base-palettized\" rel=\"nofollow\"\u003e\u003ccode\u003estabilityai/stable-diffusion-2-1-base\u003c/code\u003e\u003c/a\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp dir=\"auto\"\u003eMixed-bit quantized models\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003e\u003ca href=\"https://huggingface.co/apple/coreml-stable-diffusion-mixed-bit-palettization\" rel=\"nofollow\"\u003e\u003ccode\u003estabilityai/stable-diffusion-xl-base-1.0\u003c/code\u003e\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://huggingface.co/apple/coreml-stable-diffusion-xl-base-ios\" rel=\"nofollow\"\u003e\u003ccode\u003estabilityai/stable-diffusion-xl-base-1.0-ios\u003c/code\u003e\u003c/a\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003eUncompressed models:\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003e\u003ca href=\"https://huggingface.co/apple/coreml-stable-diffusion-v1-4\" rel=\"nofollow\"\u003e\u003ccode\u003eCompVis/stable-diffusion-v1-4\u003c/code\u003e\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://huggingface.co/apple/coreml-stable-diffusion-v1-5\" rel=\"nofollow\"\u003e\u003ccode\u003erunwayml/stable-diffusion-v1-5\u003c/code\u003e\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://huggingface.co/apple/coreml-stable-diffusion-2-base\" rel=\"nofollow\"\u003e\u003ccode\u003estabilityai/stable-diffusion-2-base\u003c/code\u003e\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://huggingface.co/apple/coreml-stable-diffusion-2-1-base\" rel=\"nofollow\"\u003e\u003ccode\u003estabilityai/stable-diffusion-2-1-base\u003c/code\u003e\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://huggingface.co/apple/coreml-stable-diffusion-xl-base\" rel=\"nofollow\"\u003e\u003ccode\u003estabilityai/stable-diffusion-xl-base-1.0\u003c/code\u003e\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://huggingface.co/apple/coreml-stable-diffusion-xl-base-with-refiner\" rel=\"nofollow\"\u003e\u003ccode\u003estabilityai/stable-diffusion-xl-{base+refiner}-1.0\u003c/code\u003e\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://huggingface.co/stabilityai/stable-diffusion-3-medium\" rel=\"nofollow\"\u003e\u003ccode\u003estabilityai/stable-diffusion-3-medium\u003c/code\u003e\u003c/a\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp dir=\"auto\"\u003eIf you want to use any of those models you may download the weights and proceed to \u003ca href=\"#image-generation-with-python\"\u003egenerate images with Python\u003c/a\u003e or \u003ca href=\"#image-generation-with-swift\"\u003eSwift\u003c/a\u003e.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThere are several variants in each model repository. You may clone the whole repos using \u003ccode\u003egit\u003c/code\u003e and \u003ccode\u003egit lfs\u003c/code\u003e to download all variants, or selectively download the ones you need.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eTo clone the repos using \u003ccode\u003egit\u003c/code\u003e, please follow this process:\u003c/p\u003e\n\u003cp dir=\"auto\"\u003e\u003cstrong\u003eStep 1:\u003c/strong\u003e Install the \u003ccode\u003egit lfs\u003c/code\u003e extension for your system.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003e\u003ccode\u003egit lfs\u003c/code\u003e stores large files outside the main git repo, and it downloads them from the appropriate server after you clone or checkout. It is available in most package managers, check \u003ca href=\"https://git-lfs.com\" rel=\"nofollow\"\u003ethe installation page\u003c/a\u003e for details.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003e\u003cstrong\u003eStep 2:\u003c/strong\u003e Enable \u003ccode\u003egit lfs\u003c/code\u003e by running this command once:\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-shell notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"git lfs install\"\u003e\u003cpre\u003egit lfs install\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003e\u003cstrong\u003eStep 3:\u003c/strong\u003e Use \u003ccode\u003egit clone\u003c/code\u003e to download a copy of the repo that includes all model variants. For Stable Diffusion version 1.4, you'd issue the following command in your terminal:\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-shell notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"git clone https://huggingface.co/apple/coreml-stable-diffusion-v1-4\"\u003e\u003cpre\u003egit clone https://huggingface.co/apple/coreml-stable-diffusion-v1-4\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eIf you prefer to download specific variants instead of cloning the repos, you can use the \u003ccode\u003ehuggingface_hub\u003c/code\u003e Python library. For example, to do generation in Python using the \u003ccode\u003eORIGINAL\u003c/code\u003e attention implementation (read \u003ca href=\"#converting-models-to-coreml\"\u003ethis section\u003c/a\u003e for details), you could use the following helper code:\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"from huggingface_hub import snapshot_download\nfrom pathlib import Path\n\nrepo_id = \u0026quot;apple/coreml-stable-diffusion-v1-4\u0026quot;\nvariant = \u0026quot;original/packages\u0026quot;\n\nmodel_path = Path(\u0026quot;./models\u0026quot;) / (repo_id.split(\u0026quot;/\u0026quot;)[-1] + \u0026quot;_\u0026quot; + variant.replace(\u0026quot;/\u0026quot;, \u0026quot;_\u0026quot;))\nsnapshot_download(repo_id, allow_patterns=f\u0026quot;{variant}/*\u0026quot;, local_dir=model_path, local_dir_use_symlinks=False)\nprint(f\u0026quot;Model downloaded at {model_path}\u0026quot;)\"\u003e\u003cpre\u003e\u003cspan class=\"pl-k\"\u003efrom\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003ehuggingface_hub\u003c/span\u003e \u003cspan class=\"pl-k\"\u003eimport\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003esnapshot_download\u003c/span\u003e\n\u003cspan class=\"pl-k\"\u003efrom\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003epathlib\u003c/span\u003e \u003cspan class=\"pl-k\"\u003eimport\u003c/span\u003e \u003cspan class=\"pl-v\"\u003ePath\u003c/span\u003e\n\n\u003cspan class=\"pl-s1\"\u003erepo_id\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e \u003cspan class=\"pl-s\"\u003e\"apple/coreml-stable-diffusion-v1-4\"\u003c/span\u003e\n\u003cspan class=\"pl-s1\"\u003evariant\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e \u003cspan class=\"pl-s\"\u003e\"original/packages\"\u003c/span\u003e\n\n\u003cspan class=\"pl-s1\"\u003emodel_path\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e \u003cspan class=\"pl-en\"\u003ePath\u003c/span\u003e(\u003cspan class=\"pl-s\"\u003e\"./models\"\u003c/span\u003e) \u003cspan class=\"pl-c1\"\u003e/\u003c/span\u003e (\u003cspan class=\"pl-s1\"\u003erepo_id\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003esplit\u003c/span\u003e(\u003cspan class=\"pl-s\"\u003e\"/\"\u003c/span\u003e)[\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e1\u003c/span\u003e] \u003cspan class=\"pl-c1\"\u003e+\u003c/span\u003e \u003cspan class=\"pl-s\"\u003e\"_\"\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e+\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003evariant\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003ereplace\u003c/span\u003e(\u003cspan class=\"pl-s\"\u003e\"/\"\u003c/span\u003e, \u003cspan class=\"pl-s\"\u003e\"_\"\u003c/span\u003e))\n\u003cspan class=\"pl-en\"\u003esnapshot_download\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003erepo_id\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003eallow_patterns\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e\u003cspan class=\"pl-s\"\u003ef\"\u003cspan class=\"pl-s1\"\u003e\u003cspan class=\"pl-kos\"\u003e{\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003evariant\u003c/span\u003e\u003cspan class=\"pl-kos\"\u003e}\u003c/span\u003e\u003c/span\u003e/*\"\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003elocal_dir\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003emodel_path\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003elocal_dir_use_symlinks\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003eFalse\u003c/span\u003e)\n\u003cspan class=\"pl-en\"\u003eprint\u003c/span\u003e(\u003cspan class=\"pl-s\"\u003ef\"Model downloaded at \u003cspan class=\"pl-s1\"\u003e\u003cspan class=\"pl-kos\"\u003e{\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003emodel_path\u003c/span\u003e\u003cspan class=\"pl-kos\"\u003e}\u003c/span\u003e\u003c/span\u003e\"\u003c/span\u003e)\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003e\u003ccode\u003emodel_path\u003c/code\u003e would be the path in your local filesystem where the checkpoint was saved. Please, refer to \u003ca href=\"https://huggingface.co/blog/diffusers-coreml\" rel=\"nofollow\"\u003ethis post\u003c/a\u003e for additional details.\u003c/p\u003e\n\u003c/details\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003e\u003ca name=\"user-content-converting-models-to-coreml\"\u003e\u003c/a\u003e Converting Models to Core ML\u003c/h2\u003e\u003ca id=\"user-content--converting-models-to-core-ml\" class=\"anchor\" aria-label=\"Permalink: Converting Models to Core ML\" href=\"#-converting-models-to-core-ml\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cdetails\u003e\n \u003csummary\u003e Click to expand \u003c/summary\u003e\n\u003cp dir=\"auto\"\u003e\u003cstrong\u003eStep 1:\u003c/strong\u003e Create a Python environment and install dependencies:\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-shell notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"conda create -n coreml_stable_diffusion python=3.8 -y\nconda activate coreml_stable_diffusion\ncd /path/to/cloned/ml-stable-diffusion/repository\npip install -e .\"\u003e\u003cpre\u003econda create -n coreml_stable_diffusion python=3.8 -y\nconda activate coreml_stable_diffusion\n\u003cspan class=\"pl-c1\"\u003ecd\u003c/span\u003e /path/to/cloned/ml-stable-diffusion/repository\npip install -e \u003cspan class=\"pl-c1\"\u003e.\u003c/span\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003e\u003cstrong\u003eStep 2:\u003c/strong\u003e Log in to or register for your \u003ca href=\"https://huggingface.co\" rel=\"nofollow\"\u003eHugging Face account\u003c/a\u003e, generate a \u003ca href=\"https://huggingface.co/settings/tokens\" rel=\"nofollow\"\u003eUser Access Token\u003c/a\u003e and use this token to set up Hugging Face API access by running \u003ccode\u003ehuggingface-cli login\u003c/code\u003e in a Terminal window.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003e\u003cstrong\u003eStep 3:\u003c/strong\u003e Navigate to the version of Stable Diffusion that you would like to use on \u003ca href=\"https://huggingface.co/models?search=stable-diffusion\" rel=\"nofollow\"\u003eHugging Face Hub\u003c/a\u003e and accept its Terms of Use. The default model version is \u003ca href=\"https://huggingface.co/CompVis/stable-diffusion-v1-4\" rel=\"nofollow\"\u003eCompVis/stable-diffusion-v1-4\u003c/a\u003e. The model version may be changed by the user as described in the next step.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003e\u003cstrong\u003eStep 4:\u003c/strong\u003e Execute the following command from the Terminal to generate Core ML model files (\u003ccode\u003e.mlpackage\u003c/code\u003e)\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-shell notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"python -m python_coreml_stable_diffusion.torch2coreml --convert-unet --convert-text-encoder --convert-vae-decoder --convert-safety-checker --model-version \u0026lt;model-version-string-from-hub\u0026gt; -o \u0026lt;output-mlpackages-directory\u0026gt;\"\u003e\u003cpre\u003epython -m python_coreml_stable_diffusion.torch2coreml --convert-unet --convert-text-encoder --convert-vae-decoder --convert-safety-checker --model-version \u003cspan class=\"pl-k\"\u003e\u0026lt;\u003c/span\u003emodel-version-string-from-hub\u003cspan class=\"pl-k\"\u003e\u0026gt;\u003c/span\u003e -o \u003cspan class=\"pl-k\"\u003e\u0026lt;\u003c/span\u003eoutput-mlpackages-directory\u003cspan class=\"pl-k\"\u003e\u0026gt;\u003c/span\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003e\u003cstrong\u003eWARNING:\u003c/strong\u003e This command will download several GB worth of PyTorch checkpoints from Hugging Face. Please ensure that you are on Wi-Fi and have enough disk space.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThis generally takes 15-20 minutes on an M1 MacBook Pro. Upon successful execution, the 4 neural network models that comprise Stable Diffusion will have been converted from PyTorch to Core ML (\u003ccode\u003e.mlpackage\u003c/code\u003e) and saved into the specified \u003ccode\u003e\u0026lt;output-mlpackages-directory\u0026gt;\u003c/code\u003e. Some additional notable arguments:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003e\n\u003cp dir=\"auto\"\u003e\u003ccode\u003e--model-version\u003c/code\u003e: The model version name as published on the \u003ca href=\"https://huggingface.co/models?search=stable-diffusion\" rel=\"nofollow\"\u003eHugging Face Hub\u003c/a\u003e\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp dir=\"auto\"\u003e\u003ccode\u003e--refiner-version\u003c/code\u003e: The refiner version name as published on the \u003ca href=\"https://huggingface.co/models?search=stable-diffusion\" rel=\"nofollow\"\u003eHugging Face Hub\u003c/a\u003e. This is optional and if specified, this argument will convert and bundle the refiner unet alongside the model unet.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp dir=\"auto\"\u003e\u003ccode\u003e--bundle-resources-for-swift-cli\u003c/code\u003e: Compiles all 4 models and bundles them along with necessary resources for text tokenization into \u003ccode\u003e\u0026lt;output-mlpackages-directory\u0026gt;/Resources\u003c/code\u003e which should provided as input to the Swift package. This flag is not necessary for the diffusers-based Python pipeline. \u003ca href=\"https://apple.github.io/coremltools/docs-guides/source/model-prediction.html#why-use-a-compiled-model\" rel=\"nofollow\"\u003eHowever using these compiled models in Python will significantly speed up inference\u003c/a\u003e.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp dir=\"auto\"\u003e\u003ccode\u003e--quantize-nbits\u003c/code\u003e: Quantizes the weights of unet and text_encoder models down to 2, 4, 6 or 8 bits using a globally optimal k-means clustering algorithm. By default all models are weight-quantized to 16 bits even if this argument is not specified. Please refer to [this section](#compression-6-bits-and-higher for details and further guidance on weight compression.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp dir=\"auto\"\u003e\u003ccode\u003e--chunk-unet\u003c/code\u003e: Splits the Unet model in two approximately equal chunks (each with less than 1GB of weights) for mobile-friendly deployment. This is \u003cstrong\u003erequired\u003c/strong\u003e for Neural Engine deployment on iOS and iPadOS if weights are not quantized to 6-bits or less (\u003ccode\u003e--quantize-nbits {2,4,6}\u003c/code\u003e). This is not required for macOS. Swift CLI is able to consume both the chunked and regular versions of the Unet model but prioritizes the former. Note that chunked unet is not compatible with the Python pipeline because Python pipeline is intended for macOS only.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp dir=\"auto\"\u003e\u003ccode\u003e--attention-implementation\u003c/code\u003e: Defaults to \u003ccode\u003eSPLIT_EINSUM\u003c/code\u003e which is the implementation described in \u003ca href=\"https://machinelearning.apple.com/research/neural-engine-transformers\" rel=\"nofollow\"\u003eDeploying Transformers on the Apple Neural Engine\u003c/a\u003e. \u003ccode\u003e--attention-implementation SPLIT_EINSUM_V2\u003c/code\u003e yields 10-30% improvement for mobile devices, still targeting the Neural Engine. \u003ccode\u003e--attention-implementation ORIGINAL\u003c/code\u003e will switch to an alternative implementation that should be used for CPU or GPU deployment on some Mac devices. Please refer to the \u003ca href=\"#performance-benchmark\"\u003ePerformance Benchmark\u003c/a\u003e section for further guidance.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp dir=\"auto\"\u003e\u003ccode\u003e--check-output-correctness\u003c/code\u003e: Compares original PyTorch model's outputs to final Core ML model's outputs. This flag increases RAM consumption significantly so it is recommended only for debugging purposes.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp dir=\"auto\"\u003e\u003ccode\u003e--convert-controlnet\u003c/code\u003e: Converts ControlNet models specified after this option. This can also convert multiple models if you specify like \u003ccode\u003e--convert-controlnet lllyasviel/sd-controlnet-mlsd lllyasviel/sd-controlnet-depth\u003c/code\u003e.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp dir=\"auto\"\u003e\u003ccode\u003e--unet-support-controlnet\u003c/code\u003e: enables a converted UNet model to receive additional inputs from ControlNet. This is required for generating image with using ControlNet and saved with a different name, \u003ccode\u003e*_control-unet.mlpackage\u003c/code\u003e, distinct from normal UNet. On the other hand, this UNet model can not work without ControlNet. Please use normal UNet for just txt2img.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp dir=\"auto\"\u003e\u003ccode\u003e--unet-batch-one\u003c/code\u003e: use a batch size of one for the unet, this is needed if you do not want to do classifier free guidance, i.e. using a \u003ccode\u003eguidance-scale\u003c/code\u003e of less than one.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp dir=\"auto\"\u003e\u003ccode\u003e--convert-vae-encoder\u003c/code\u003e: not required for text-to-image applications. Required for image-to-image applications in order to map the input image to the latent space.\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/details\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003e\u003ca name=\"user-content-image-generation-with-python\"\u003e\u003c/a\u003e Image Generation with Python\u003c/h2\u003e\u003ca id=\"user-content--image-generation-with-python\" class=\"anchor\" aria-label=\"Permalink: Image Generation with Python\" href=\"#-image-generation-with-python\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cdetails\u003e\n \u003csummary\u003e Click to expand \u003c/summary\u003e\n\u003cp dir=\"auto\"\u003eRun text-to-image generation using the example Python pipeline based on \u003ca href=\"https://github.com/huggingface/diffusers\"\u003ediffusers\u003c/a\u003e:\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-shell notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"python -m python_coreml_stable_diffusion.pipeline --prompt \u0026quot;a photo of an astronaut riding a horse on mars\u0026quot; -i \u0026lt;core-ml-model-directory\u0026gt; -o \u0026lt;/path/to/output/image\u0026gt; --compute-unit ALL --seed 93\"\u003e\u003cpre\u003epython -m python_coreml_stable_diffusion.pipeline --prompt \u003cspan class=\"pl-s\"\u003e\u003cspan class=\"pl-pds\"\u003e\"\u003c/span\u003ea photo of an astronaut riding a horse on mars\u003cspan class=\"pl-pds\"\u003e\"\u003c/span\u003e\u003c/span\u003e -i \u003cspan class=\"pl-k\"\u003e\u0026lt;\u003c/span\u003ecore-ml-model-directory\u003cspan class=\"pl-k\"\u003e\u0026gt;\u003c/span\u003e -o \u003cspan class=\"pl-k\"\u003e\u0026lt;\u003c/span\u003e/path/to/output/image\u003cspan class=\"pl-k\"\u003e\u0026gt;\u003c/span\u003e --compute-unit ALL --seed 93\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003ePlease refer to the help menu for all available arguments: \u003ccode\u003epython -m python_coreml_stable_diffusion.pipeline -h\u003c/code\u003e. Some notable arguments:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003e\u003ccode\u003e-i\u003c/code\u003e: Should point to the \u003ccode\u003e-o\u003c/code\u003e directory from Step 4 of \u003ca href=\"#converting-models-to-coreml\"\u003eConverting Models to Core ML\u003c/a\u003e section from above. If you specified \u003ccode\u003e--bundle-resources-for-swift-cli\u003c/code\u003e during conversion, then use the resulting \u003ccode\u003eResources\u003c/code\u003e folder (which holds the compiled \u003ccode\u003e.mlmodelc\u003c/code\u003e files). \u003ca href=\"https://apple.github.io/coremltools/docs-guides/source/model-prediction.html#why-use-a-compiled-model\" rel=\"nofollow\"\u003eThe compiled models load much faster after first use\u003c/a\u003e.\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e--model-version\u003c/code\u003e: If you overrode the default model version while converting models to Core ML, you will need to specify the same model version here.\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e--compute-unit\u003c/code\u003e: Note that the most performant compute unit for this particular implementation may differ across different hardware. \u003ccode\u003eCPU_AND_GPU\u003c/code\u003e or \u003ccode\u003eCPU_AND_NE\u003c/code\u003e may be faster than \u003ccode\u003eALL\u003c/code\u003e. Please refer to the \u003ca href=\"#performance-benchmark\"\u003ePerformance Benchmark\u003c/a\u003e section for further guidance.\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e--scheduler\u003c/code\u003e: If you would like to experiment with different schedulers, you may specify it here. For available options, please see the help menu. You may also specify a custom number of inference steps by \u003ccode\u003e--num-inference-steps\u003c/code\u003e which defaults to 50.\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e--controlnet\u003c/code\u003e: ControlNet models specified with this option are used in image generation. Use this option in the format \u003ccode\u003e--controlnet lllyasviel/sd-controlnet-mlsd lllyasviel/sd-controlnet-depth\u003c/code\u003e and make sure to use \u003ccode\u003e--controlnet-inputs\u003c/code\u003e in conjunction.\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e--controlnet-inputs\u003c/code\u003e: Image inputs corresponding to each ControlNet model. Please provide image paths in same order as models in \u003ccode\u003e--controlnet\u003c/code\u003e, for example: \u003ccode\u003e--controlnet-inputs image_mlsd image_depth\u003c/code\u003e.\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e--unet-batch-one\u003c/code\u003e: Do not batch unet predictions for the prompt and negative prompt. This requires the unet has been converted with a batch size of one, see \u003ccode\u003e--unet-batch-one\u003c/code\u003e option in conversion script.\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/details\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003e\u003ca name=\"user-content-image-gen-swift\"\u003e\u003c/a\u003e Image Generation with Swift\u003c/h2\u003e\u003ca id=\"user-content--image-generation-with-swift\" class=\"anchor\" aria-label=\"Permalink: Image Generation with Swift\" href=\"#-image-generation-with-swift\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cdetails\u003e\n \u003csummary\u003e Click to expand \u003c/summary\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eExample CLI Usage\u003c/h3\u003e\u003ca id=\"user-content-example-cli-usage\" class=\"anchor\" aria-label=\"Permalink: Example CLI Usage\" href=\"#example-cli-usage\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cdiv class=\"highlight highlight-source-shell notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"swift run StableDiffusionSample \u0026quot;a photo of an astronaut riding a horse on mars\u0026quot; --resource-path \u0026lt;output-mlpackages-directory\u0026gt;/Resources/ --seed 93 --output-path \u0026lt;/path/to/output/image\u0026gt;\"\u003e\u003cpre\u003eswift run StableDiffusionSample \u003cspan class=\"pl-s\"\u003e\u003cspan class=\"pl-pds\"\u003e\"\u003c/span\u003ea photo of an astronaut riding a horse on mars\u003cspan class=\"pl-pds\"\u003e\"\u003c/span\u003e\u003c/span\u003e --resource-path \u003cspan class=\"pl-k\"\u003e\u0026lt;\u003c/span\u003eoutput-mlpackages-directory\u003cspan class=\"pl-k\"\u003e\u0026gt;\u003c/span\u003e/Resources/ --seed 93 --output-path \u003cspan class=\"pl-k\"\u003e\u0026lt;\u003c/span\u003e/path/to/output/image\u003cspan class=\"pl-k\"\u003e\u0026gt;\u003c/span\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eThe output will be named based on the prompt and random seed:\ne.g. \u003ccode\u003e\u0026lt;/path/to/output/image\u0026gt;/a_photo_of_an_astronaut_riding_a_horse_on_mars.93.final.png\u003c/code\u003e\u003c/p\u003e\n\u003cp dir=\"auto\"\u003ePlease use the \u003ccode\u003e--help\u003c/code\u003e flag to learn about batched generation and more.\u003c/p\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eExample Library Usage\u003c/h3\u003e\u003ca id=\"user-content-example-library-usage\" class=\"anchor\" aria-label=\"Permalink: Example Library Usage\" href=\"#example-library-usage\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cdiv class=\"highlight highlight-source-swift notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"import StableDiffusion\n...\nlet pipeline = try StableDiffusionPipeline(resourcesAt: resourceURL)\npipeline.loadResources()\nlet image = try pipeline.generateImages(prompt: prompt, seed: seed).first\"\u003e\u003cpre\u003e\u003cspan class=\"pl-k\"\u003eimport\u003c/span\u003e StableDiffusion\n\u003cspan class=\"pl-c1\"\u003e...\u003c/span\u003e\n\u003cspan class=\"pl-k\"\u003elet\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003epipeline\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e\u003cspan class=\"pl-k\"\u003etry\u003c/span\u003e\u003c/span\u003e \u003cspan class=\"pl-en\"\u003eStableDiffusionPipeline\u003c/span\u003e\u003cspan class=\"pl-kos\"\u003e(\u003c/span\u003eresourcesAt\u003cspan class=\"pl-kos\"\u003e:\u003c/span\u003e resourceURL\u003cspan class=\"pl-kos\"\u003e)\u003c/span\u003e\npipeline\u003cspan class=\"pl-kos\"\u003e.\u003c/span\u003e\u003cspan class=\"pl-en\"\u003eloadResources\u003c/span\u003e\u003cspan class=\"pl-kos\"\u003e(\u003c/span\u003e\u003cspan class=\"pl-kos\"\u003e)\u003c/span\u003e\n\u003cspan class=\"pl-k\"\u003elet\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003eimage\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e\u003cspan class=\"pl-k\"\u003etry\u003c/span\u003e\u003c/span\u003e pipeline\u003cspan class=\"pl-kos\"\u003e.\u003c/span\u003e\u003cspan class=\"pl-en\"\u003egenerateImages\u003c/span\u003e\u003cspan class=\"pl-kos\"\u003e(\u003c/span\u003eprompt\u003cspan class=\"pl-kos\"\u003e:\u003c/span\u003e prompt\u003cspan class=\"pl-kos\"\u003e,\u003c/span\u003e seed\u003cspan class=\"pl-kos\"\u003e:\u003c/span\u003e seed\u003cspan class=\"pl-kos\"\u003e)\u003c/span\u003e\u003cspan class=\"pl-kos\"\u003e.\u003c/span\u003efirst\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eOn iOS, the \u003ccode\u003ereduceMemory\u003c/code\u003e option should be set to \u003ccode\u003etrue\u003c/code\u003e when constructing \u003ccode\u003eStableDiffusionPipeline\u003c/code\u003e\u003c/p\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eSwift Package Details\u003c/h3\u003e\u003ca id=\"user-content-swift-package-details\" class=\"anchor\" aria-label=\"Permalink: Swift Package Details\" href=\"#swift-package-details\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eThis Swift package contains two products:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003e\u003ccode\u003eStableDiffusion\u003c/code\u003e library\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003eStableDiffusionSample\u003c/code\u003e command-line tool\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp dir=\"auto\"\u003eBoth of these products require the Core ML models and tokenization resources to be supplied. When specifying resources via a directory path that directory must contain the following:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003e\u003ccode\u003eTextEncoder.mlmodelc\u003c/code\u003e or `TextEncoder2.mlmodelc (text embedding model)\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003eUnet.mlmodelc\u003c/code\u003e or \u003ccode\u003eUnetChunk1.mlmodelc\u003c/code\u003e \u0026amp; \u003ccode\u003eUnetChunk2.mlmodelc\u003c/code\u003e (denoising autoencoder model)\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003eVAEDecoder.mlmodelc\u003c/code\u003e (image decoder model)\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003evocab.json\u003c/code\u003e (tokenizer vocabulary file)\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003emerges.text\u003c/code\u003e (merges for byte pair encoding file)\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp dir=\"auto\"\u003eOptionally, for image2image, in-painting, or similar:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003e\u003ccode\u003eVAEEncoder.mlmodelc\u003c/code\u003e (image encoder model)\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp dir=\"auto\"\u003eOptionally, it may also include the safety checker model that some versions of Stable Diffusion include:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003e\u003ccode\u003eSafetyChecker.mlmodelc\u003c/code\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp dir=\"auto\"\u003eOptionally, for the SDXL refiner:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003e\u003ccode\u003eUnetRefiner.mlmodelc\u003c/code\u003e (refiner unet model)\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp dir=\"auto\"\u003eOptionally, for ControlNet:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003e\u003ccode\u003eControlledUNet.mlmodelc\u003c/code\u003e or \u003ccode\u003eControlledUnetChunk1.mlmodelc\u003c/code\u003e \u0026amp; \u003ccode\u003eControlledUnetChunk2.mlmodelc\u003c/code\u003e (enabled to receive ControlNet values)\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003econtrolnet/\u003c/code\u003e (directory containing ControlNet models)\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003e\u003ccode\u003eLllyasvielSdControlnetMlsd.mlmodelc\u003c/code\u003e (for example, from lllyasviel/sd-controlnet-mlsd)\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003eLllyasvielSdControlnetDepth.mlmodelc\u003c/code\u003e (for example, from lllyasviel/sd-controlnet-depth)\u003c/li\u003e\n\u003cli\u003eOther models you converted\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp dir=\"auto\"\u003eNote that the chunked version of Unet is checked for first. Only if it is not present will the full \u003ccode\u003eUnet.mlmodelc\u003c/code\u003e be loaded. Chunking is required for iOS and iPadOS and not necessary for macOS.\u003c/p\u003e\n\u003c/details\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003e\u003ca name=\"user-content-swift-app\"\u003e\u003c/a\u003e Example Swift App\u003c/h2\u003e\u003ca id=\"user-content--example-swift-app\" class=\"anchor\" aria-label=\"Permalink: Example Swift App\" href=\"#-example-swift-app\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cdetails\u003e\n \u003csummary\u003e Click to expand \u003c/summary\u003e\n\u003cp dir=\"auto\"\u003e🤗 Hugging Face created an \u003ca href=\"https://github.com/huggingface/swift-coreml-diffusers\"\u003eopen-source demo app\u003c/a\u003e on top of this library. It's written in native Swift and Swift UI, and runs on macOS, iOS and iPadOS. You can use the code as a starting point for your app, or to see how to integrate this library in your own projects.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eHugging Face has made the app \u003ca href=\"https://apps.apple.com/app/diffusers/id1666309574?mt=12\" rel=\"nofollow\"\u003eavailable in the Mac App Store\u003c/a\u003e.\u003c/p\u003e\n\u003c/details\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003e\u003ca name=\"user-content-faq\"\u003e\u003c/a\u003e FAQ\u003c/h2\u003e\u003ca id=\"user-content--faq\" class=\"anchor\" aria-label=\"Permalink: FAQ\" href=\"#-faq\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cdetails\u003e\n \u003csummary\u003e Click to expand \u003c/summary\u003e\n\u003cdetails\u003e\n\u003csummary\u003e \u003cb\u003e Q1: \u003c/b\u003e \u003ccode\u003e ERROR: Failed building wheel for tokenizers or error: can't find Rust compiler \u003c/code\u003e \u003c/summary\u003e\n\u003cp dir=\"auto\"\u003e\u003cb\u003e A1: \u003c/b\u003e Please review this \u003ca href=\"https://github.com/huggingface/transformers/issues/2831#issuecomment-592724471\" data-hovercard-type=\"issue\" data-hovercard-url=\"/huggingface/transformers/issues/2831/hovercard\"\u003epotential solution\u003c/a\u003e.\u003c/p\u003e\n\u003c/details\u003e\n\u003cdetails\u003e\n\u003csummary\u003e \u003cb\u003e Q2: \u003c/b\u003e \u003ccode\u003e RuntimeError: {NSLocalizedDescription = \"Error computing NN outputs.\" \u003c/code\u003e \u003c/summary\u003e\n\u003cp dir=\"auto\"\u003e\u003cb\u003e A2: \u003c/b\u003e There are many potential causes for this error. In this context, it is highly likely to be encountered when your system is under increased memory pressure from other applications. Reducing memory utilization of other applications is likely to help alleviate the issue.\u003c/p\u003e\n\u003c/details\u003e\n\u003cdetails\u003e\n\u003csummary\u003e \u003cb\u003e \u003ca name=\"user-content-low-mem-conversion\"\u003e\u003c/a\u003e Q3: \u003c/b\u003e My Mac has 8GB RAM and I am converting models to Core ML using the example command. The process is getting killed because of memory issues. How do I fix this issue? \u003c/summary\u003e\n\u003cp dir=\"auto\"\u003e\u003cb\u003e A3: \u003c/b\u003e In order to minimize the memory impact of the model conversion process, please execute the following command instead:\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-shell notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"python -m python_coreml_stable_diffusion.torch2coreml --convert-vae-encoder --model-version \u0026lt;model-version-string-from-hub\u0026gt; -o \u0026lt;output-mlpackages-directory\u0026gt; \u0026amp;\u0026amp; \\\npython -m python_coreml_stable_diffusion.torch2coreml --convert-vae-decoder --model-version \u0026lt;model-version-string-from-hub\u0026gt; -o \u0026lt;output-mlpackages-directory\u0026gt; \u0026amp;\u0026amp; \\\npython -m python_coreml_stable_diffusion.torch2coreml --convert-unet --model-version \u0026lt;model-version-string-from-hub\u0026gt; -o \u0026lt;output-mlpackages-directory\u0026gt; \u0026amp;\u0026amp; \\\npython -m python_coreml_stable_diffusion.torch2coreml --convert-text-encoder --model-version \u0026lt;model-version-string-from-hub\u0026gt; -o \u0026lt;output-mlpackages-directory\u0026gt; \u0026amp;\u0026amp; \\\npython -m python_coreml_stable_diffusion.torch2coreml --convert-safety-checker --model-version \u0026lt;model-version-string-from-hub\u0026gt; -o \u0026lt;output-mlpackages-directory\u0026gt; \u0026amp;\u0026amp;\"\u003e\u003cpre\u003epython -m python_coreml_stable_diffusion.torch2coreml --convert-vae-encoder --model-version \u003cspan class=\"pl-k\"\u003e\u0026lt;\u003c/span\u003emodel-version-string-from-hub\u003cspan class=\"pl-k\"\u003e\u0026gt;\u003c/span\u003e -o \u003cspan class=\"pl-k\"\u003e\u0026lt;\u003c/span\u003eoutput-mlpackages-directory\u003cspan class=\"pl-k\"\u003e\u0026gt;\u003c/span\u003e \u003cspan class=\"pl-k\"\u003e\u0026amp;\u0026amp;\u003c/span\u003e \\\npython -m python_coreml_stable_diffusion.torch2coreml --convert-vae-decoder --model-version \u003cspan class=\"pl-k\"\u003e\u0026lt;\u003c/span\u003emodel-version-string-from-hub\u003cspan class=\"pl-k\"\u003e\u0026gt;\u003c/span\u003e -o \u003cspan class=\"pl-k\"\u003e\u0026lt;\u003c/span\u003eoutput-mlpackages-directory\u003cspan class=\"pl-k\"\u003e\u0026gt;\u003c/span\u003e \u003cspan class=\"pl-k\"\u003e\u0026amp;\u0026amp;\u003c/span\u003e \\\npython -m python_coreml_stable_diffusion.torch2coreml --convert-unet --model-version \u003cspan class=\"pl-k\"\u003e\u0026lt;\u003c/span\u003emodel-version-string-from-hub\u003cspan class=\"pl-k\"\u003e\u0026gt;\u003c/span\u003e -o \u003cspan class=\"pl-k\"\u003e\u0026lt;\u003c/span\u003eoutput-mlpackages-directory\u003cspan class=\"pl-k\"\u003e\u0026gt;\u003c/span\u003e \u003cspan class=\"pl-k\"\u003e\u0026amp;\u0026amp;\u003c/span\u003e \\\npython -m python_coreml_stable_diffusion.torch2coreml --convert-text-encoder --model-version \u003cspan class=\"pl-k\"\u003e\u0026lt;\u003c/span\u003emodel-version-string-from-hub\u003cspan class=\"pl-k\"\u003e\u0026gt;\u003c/span\u003e -o \u003cspan class=\"pl-k\"\u003e\u0026lt;\u003c/span\u003eoutput-mlpackages-directory\u003cspan class=\"pl-k\"\u003e\u0026gt;\u003c/span\u003e \u003cspan class=\"pl-k\"\u003e\u0026amp;\u0026amp;\u003c/span\u003e \\\npython -m python_coreml_stable_diffusion.torch2coreml --convert-safety-checker --model-version \u003cspan class=\"pl-k\"\u003e\u0026lt;\u003c/span\u003emodel-version-string-from-hub\u003cspan class=\"pl-k\"\u003e\u0026gt;\u003c/span\u003e -o \u003cspan class=\"pl-k\"\u003e\u0026lt;\u003c/span\u003eoutput-mlpackages-directory\u003cspan class=\"pl-k\"\u003e\u0026gt;\u003c/span\u003e \u003cspan class=\"pl-k\"\u003e\u0026amp;\u0026amp;\u003c/span\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eIf you need \u003ccode\u003e--chunk-unet\u003c/code\u003e, you may do so in yet another independent command which will reuse the previously exported Unet model and simply chunk it in place:\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-shell notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"python -m python_coreml_stable_diffusion.torch2coreml --convert-unet --chunk-unet -o \u0026lt;output-mlpackages-directory\u0026gt;\"\u003e\u003cpre\u003epython -m python_coreml_stable_diffusion.torch2coreml --convert-unet --chunk-unet -o \u003cspan class=\"pl-k\"\u003e\u0026lt;\u003c/span\u003eoutput-mlpackages-directory\u003cspan class=\"pl-k\"\u003e\u0026gt;\u003c/span\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003c/details\u003e\n\u003cdetails\u003e\n\u003csummary\u003e \u003cb\u003e Q4: \u003c/b\u003e My Mac has 8GB RAM, should image generation work on my machine? \u003c/summary\u003e\n\u003cp dir=\"auto\"\u003e\u003cb\u003e A4: \u003c/b\u003e Yes! Especially the \u003ccode\u003e--compute-unit CPU_AND_NE\u003c/code\u003e option should work under reasonable system load from other applications. Note that part of the \u003ca href=\"#example-results\"\u003eExample Results\u003c/a\u003e were generated using an M2 MacBook Air with 8GB RAM.\u003c/p\u003e\n\u003c/details\u003e\n\u003cdetails\u003e\n\u003csummary\u003e \u003cb\u003e Q5: \u003c/b\u003e Every time I generate an image using the Python pipeline, loading all the Core ML models takes 2-3 minutes. Is this expected? \u003c/summary\u003e\n\u003cp dir=\"auto\"\u003e\u003cb\u003e A5: \u003c/b\u003e Both \u003ccode\u003e.mlpackage\u003c/code\u003e and \u003ccode\u003e.mlmodelc\u003c/code\u003e models are compiled (also known as \"model preparation\" in Core ML terms) upon first load when a specific compute unit is specified. \u003ccode\u003e.mlpackage\u003c/code\u003e does not cache this compiled asset so each model load retriggers this compilation which may take up to a few minutes. On the other hand, \u003ccode\u003e.mlmodelc\u003c/code\u003e files do cache this compiled asset and non-first load times are reduced to just a few seconds.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eIn order to benefit from compilation caching, you may use the \u003ccode\u003e.mlmodelc\u003c/code\u003e assets instead of \u003ccode\u003e.mlpackage\u003c/code\u003e assets in both Swift (default) and Python (possible thanks to \u003ca href=\"https://github.com/lopez-hector\"\u003e@lopez-hector\u003c/a\u003e's \u003ca href=\"https://github.com/apple/ml-stable-diffusion/commit/f3a212491cf531dd88493c89ad3d98d016db407f\"\u003econtribution\u003c/a\u003e) image generation pipelines.\u003c/p\u003e\n\u003c/details\u003e\n\u003cdetails\u003e\n\u003csummary\u003e \u003cb\u003e \u003ca name=\"user-content-q-mobile-app\"\u003e\u003c/a\u003e Q6: \u003c/b\u003e I want to deploy \u003ccode\u003eStableDiffusion\u003c/code\u003e, the Swift package, in my mobile app. What should I be aware of? \u003c/summary\u003e\n\u003cp dir=\"auto\"\u003e\u003cb\u003e A6: \u003c/b\u003eThe \u003ca href=\"#image-gen-swift\"\u003eImage Generation with Swift\u003c/a\u003e section describes the minimum SDK and OS versions as well as the device models supported by this package. We recommend carefully testing the package on the device with the least amount of RAM available among your deployment targets.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThe image generation process in \u003ccode\u003eStableDiffusion\u003c/code\u003e can yield over 2 GB of peak memory during runtime depending on the compute units selected. On iPadOS, we recommend using \u003ccode\u003e.cpuAndNeuralEngine\u003c/code\u003e in your configuration and the \u003ccode\u003ereduceMemory\u003c/code\u003e option when constructing a \u003ccode\u003eStableDiffusionPipeline\u003c/code\u003e to minimize memory pressure.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eIf your app crashes during image generation, consider adding the \u003ca href=\"https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_kernel_increased-memory-limit\" rel=\"nofollow\"\u003eIncreased Memory Limit\u003c/a\u003e capability to inform the system that some of your app’s core features may perform better by exceeding the default app memory limit on supported devices.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eOn iOS, depending on the iPhone model, Stable Diffusion model versions, selected compute units, system load and design of your app, this may still not be sufficient to keep your apps peak memory under the limit. Please remember, because the device shares memory between apps and iOS processes, one app using too much memory can compromise the user experience across the whole device.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eWe \u003cstrong\u003estrongly recommend\u003c/strong\u003e compressing your models following the recipes in \u003ca href=\"#compression-lower-than-6-bits\"\u003eAdvanced Weight Compression (Lower than 6-bits)\u003c/a\u003e for iOS deployment. This reduces the peak RAM usage by up to 75% (from 16-bit to 4-bit) while preserving model output quality.\u003c/p\u003e\n\u003c/details\u003e\n\u003cdetails\u003e\n\u003csummary\u003e \u003cb\u003e Q7: \u003c/b\u003e How do I generate images with different resolutions using the same Core ML models? \u003c/summary\u003e\n\u003cp dir=\"auto\"\u003e\u003cb\u003e A7: \u003c/b\u003e The current version of \u003ccode\u003epython_coreml_stable_diffusion\u003c/code\u003e does not support single-model multi-resolution out of the box. However, developers may fork this project and leverage the \u003ca href=\"https://coremltools.readme.io/docs/flexible-inputs\" rel=\"nofollow\"\u003eflexible shapes\u003c/a\u003e support from coremltools to extend the \u003ccode\u003etorch2coreml\u003c/code\u003e script by using \u003ccode\u003ecoremltools.EnumeratedShapes\u003c/code\u003e. Note that, while the \u003ccode\u003etext_encoder\u003c/code\u003e is agnostic to the image resolution, the inputs and outputs of \u003ccode\u003evae_decoder\u003c/code\u003e and \u003ccode\u003eunet\u003c/code\u003e models are dependent on the desired image resolution.\u003c/p\u003e\n\u003c/details\u003e\n\u003cdetails\u003e\n\u003csummary\u003e \u003cb\u003e Q8: \u003c/b\u003e Are the Core ML and PyTorch generated images going to be identical? \u003c/summary\u003e\n\u003cp dir=\"auto\"\u003e\u003cb\u003e A8: \u003c/b\u003e If desired, the generated images across PyTorch and Core ML can be made approximately identical. However, it is not guaranteed by default. There are several factors that might lead to different images across PyTorch and Core ML:\u003c/p\u003e\n\u003cp dir=\"auto\"\u003e\u003cb\u003e 1. Random Number Generator Behavior \u003c/b\u003e\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThe main source of potentially different results across PyTorch and Core ML is the Random Number Generator (\u003ca href=\"https://en.wikipedia.org/wiki/Random_number_generation\" rel=\"nofollow\"\u003eRNG\u003c/a\u003e) behavior. PyTorch and Numpy have different sources of randomness. \u003ccode\u003epython_coreml_stable_diffusion\u003c/code\u003e generally relies on Numpy for RNG (e.g. latents initialization) and \u003ccode\u003eStableDiffusion\u003c/code\u003e Swift Library reproduces this RNG behavior by default. However, PyTorch-based pipelines such as Hugging Face \u003ccode\u003ediffusers\u003c/code\u003e relies on PyTorch's RNG behavior. Thanks to @liuliu's \u003ca href=\"https://github.com/apple/ml-stable-diffusion/pull/124\" data-hovercard-type=\"pull_request\" data-hovercard-url=\"/apple/ml-stable-diffusion/pull/124/hovercard\"\u003econtributions\u003c/a\u003e, one can match the PyTorch (CPU/GPU) RNG behavior in Swift by specifying \u003ccode\u003e--rng torch/cuda\u003c/code\u003e which selects the \u003ccode\u003etorchRNG/cudaRNG\u003c/code\u003e mode.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003e\u003cb\u003e 2. PyTorch \u003c/b\u003e\u003c/p\u003e\n\u003cp dir=\"auto\"\u003e\u003cem\u003e\"Completely reproducible results are not guaranteed across PyTorch releases, individual commits, or different platforms. Furthermore, results may not be reproducible between CPU and GPU executions, even when using identical seeds.\"\u003c/em\u003e (\u003ca href=\"https://pytorch.org/docs/stable/notes/randomness.html#reproducibility\" rel=\"nofollow\"\u003esource\u003c/a\u003e).\u003c/p\u003e\n\u003cp dir=\"auto\"\u003e\u003cb\u003e 3. Model Function Drift During Conversion \u003c/b\u003e\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThe difference in outputs across corresponding PyTorch and Core ML models is a potential cause. The signal integrity is tested during the conversion process (enabled via \u003ccode\u003e--check-output-correctness\u003c/code\u003e argument to \u003ccode\u003epython_coreml_stable_diffusion.torch2coreml\u003c/code\u003e) and it is verified to be above a minimum \u003ca href=\"https://en.wikipedia.org/wiki/Peak_signal-to-noise_ratio\" rel=\"nofollow\"\u003ePSNR\u003c/a\u003e value as tested on random inputs. Note that this is simply a sanity check and does not guarantee this minimum PSNR across all possible inputs. Furthermore, the results are not guaranteed to be identical when executing the same Core ML models across different compute units. This is not expected to be a major source of difference as the sample visual results indicate in \u003ca href=\"#compression-6-bits-and-higher\"\u003ethis section\u003c/a\u003e.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003e\u003cb\u003e 4. Weights and Activations Data Type \u003c/b\u003e\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eWhen quantizing models from float32 to lower-precision data types such as float16, the generated images are \u003ca href=\"https://lambdalabs.com/blog/inference-benchmark-stable-diffusion\" rel=\"nofollow\"\u003eknown to vary slightly\u003c/a\u003e in semantics even when using the same PyTorch model. Core ML models generated by coremltools have float16 weights and activations by default \u003ca href=\"https://github.com/apple/coremltools/blob/main/coremltools/converters/_converters_entry.py#L256\"\u003eunless explicitly overridden\u003c/a\u003e. This is not expected to be a major source of difference.\u003c/p\u003e\n\u003c/details\u003e\n\u003cdetails\u003e\n\u003csummary\u003e \u003cb\u003e Q9: \u003c/b\u003e The model files are very large, how do I avoid a large binary for my App? \u003c/summary\u003e\n\u003cp dir=\"auto\"\u003e\u003cb\u003e A9: \u003c/b\u003e The recommended option is to prompt the user to download these assets upon first launch of the app. This keeps the app binary size independent of the Core ML models being deployed. Disclosing the size of the download to the user is extremely important as there could be data charges or storage impact that the user might not be comfortable with.\u003c/p\u003e\n\u003c/details\u003e\n\u003cdetails\u003e\n\u003csummary\u003e \u003cb\u003e Q10: \u003c/b\u003e \u003ccode\u003e `Could not initialize NNPACK! Reason: Unsupported hardware` \u003c/code\u003e \u003c/summary\u003e\n\u003cp dir=\"auto\"\u003e\u003cb\u003e A10: \u003c/b\u003e This warning is safe to ignore in the context of this repository.\u003c/p\u003e\n\u003c/details\u003e\n\u003cdetails\u003e\n\u003csummary\u003e \u003cb\u003e Q11: \u003c/b\u003e \u003ccode\u003e TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect \u003c/code\u003e \u003c/summary\u003e\n\u003cp dir=\"auto\"\u003e\u003cb\u003e A11: \u003c/b\u003e This warning is safe to ignore in the context of this repository.\u003c/p\u003e\n\u003c/details\u003e\n\u003cdetails\u003e\n\u003csummary\u003e \u003cb\u003e Q12: \u003c/b\u003e \u003ccode\u003e UserWarning: resource_tracker: There appear to be 1 leaked semaphore objects to clean up at shutdown \u003c/code\u003e \u003c/summary\u003e\n\u003cp dir=\"auto\"\u003e\u003cb\u003e A12: \u003c/b\u003e If this warning is printed right after \u003ccode\u003e zsh: killed python -m python_coreml_stable_diffusion.torch2coreml ... \u003c/code\u003e, then it is highly likely that your Mac has run out of memory while converting models to Core ML. Please see \u003ca href=\"#low-mem-conversion\"\u003eQ3\u003c/a\u003e from above for the solution.\u003c/p\u003e\n\u003c/details\u003e\n\u003c/details\u003e\n\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003e\u003ca name=\"user-content-bibtex\"\u003e\u003c/a\u003e BibTeX Reference\u003c/h2\u003e\u003ca id=\"user-content--bibtex-reference\" class=\"anchor\" aria-label=\"Permalink: BibTeX Reference\" href=\"#-bibtex-reference\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cdiv class=\"highlight highlight-text-tex-latex notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"@misc{stable-diffusion-coreml-apple-silicon,\ntitle = {Stable Diffusion with Core ML on Apple Silicon},\nauthor = {Atila Orhon and Michael Siracusa and Aseem Wadhwa},\nyear = {2022},\nURL = {null}\n}\"\u003e\u003cpre\u003e@misc{stable-diffusion-coreml-apple-silicon,\ntitle = {Stable Diffusion with Core ML on Apple Silicon},\nauthor = {Atila Orhon and Michael Siracusa and Aseem Wadhwa},\nyear = {2022},\nURL = {null}\n}\u003c/pre\u003e\u003c/div\u003e\n\u003c/article\u003e","loaded":true,"timedOut":false,"errorMessage":null,"headerInfo":{"toc":[{"level":1,"text":"Core ML Stable Diffusion","anchor":"core-ml-stable-diffusion","htmlText":"Core ML Stable Diffusion"},{"level":2,"text":" System Requirements","anchor":"-system-requirements","htmlText":" System Requirements"},{"level":2,"text":" Performance Benchmarks","anchor":"-performance-benchmarks","htmlText":" Performance Benchmarks"},{"level":2,"text":" Weight Compression (6-bits and higher)","anchor":"-weight-compression-6-bits-and-higher","htmlText":" Weight Compression (6-bits and higher)"},{"level":2,"text":" Advanced Weight Compression (Lower than 6-bits)","anchor":"-advanced-weight-compression-lower-than-6-bits","htmlText":" Advanced Weight Compression (Lower than 6-bits)"},{"level":2,"text":" Activation Quantization","anchor":"-activation-quantization","htmlText":" Activation Quantization"},{"level":2,"text":" Using Stable Diffusion 3","anchor":"-using-stable-diffusion-3","htmlText":" Using Stable Diffusion 3"},{"level":3,"text":"Model Conversion","anchor":"model-conversion","htmlText":"Model Conversion"},{"level":3,"text":"Swift Inference","anchor":"swift-inference","htmlText":"Swift Inference"},{"level":2,"text":" Using Stable Diffusion XL","anchor":"-using-stable-diffusion-xl","htmlText":" Using Stable Diffusion XL"},{"level":3,"text":"Model Conversion","anchor":"model-conversion-1","htmlText":"Model Conversion"},{"level":3,"text":"Swift Inference","anchor":"swift-inference-1","htmlText":"Swift Inference"},{"level":3,"text":"Python Inference","anchor":"python-inference","htmlText":"Python Inference"},{"level":2,"text":" Using ControlNet","anchor":"-using-controlnet","htmlText":" Using ControlNet"},{"level":2,"text":" Using the System Multilingual Text Encoder","anchor":"-using-the-system-multilingual-text-encoder","htmlText":" Using the System Multilingual Text Encoder"},{"level":2,"text":" Using Ready-made Core ML Models from Hugging Face Hub","anchor":"-using-ready-made-core-ml-models-from-hugging-face-hub","htmlText":" Using Ready-made Core ML Models from Hugging Face Hub"},{"level":2,"text":" Converting Models to Core ML","anchor":"-converting-models-to-core-ml","htmlText":" Converting Models to Core ML"},{"level":2,"text":" Image Generation with Python","anchor":"-image-generation-with-python","htmlText":" Image Generation with Python"},{"level":2,"text":" Image Generation with Swift","anchor":"-image-generation-with-swift","htmlText":" Image Generation with Swift"},{"level":3,"text":"Example CLI Usage","anchor":"example-cli-usage","htmlText":"Example CLI Usage"},{"level":3,"text":"Example Library Usage","anchor":"example-library-usage","htmlText":"Example Library Usage"},{"level":3,"text":"Swift Package Details","anchor":"swift-package-details","htmlText":"Swift Package Details"},{"level":2,"text":" Example Swift App","anchor":"-example-swift-app","htmlText":" Example Swift App"},{"level":2,"text":" FAQ","anchor":"-faq","htmlText":" FAQ"},{"level":2,"text":" BibTeX Reference","anchor":"-bibtex-reference","htmlText":" BibTeX Reference"}],"siteNavLoginPath":"/login?return_to=https%3A%2F%2Fgithub.com%2Fapple%2Fml-stable-diffusion"}},{"displayName":"CODE_OF_CONDUCT.md","repoName":"ml-stable-diffusion","refName":"main","path":"CODE_OF_CONDUCT.md","preferredFileType":"code_of_conduct","tabName":"Code of conduct","richText":null,"loaded":false,"timedOut":false,"errorMessage":null,"headerInfo":{"toc":null,"siteNavLoginPath":"/login?return_to=https%3A%2F%2Fgithub.com%2Fapple%2Fml-stable-diffusion"}},{"displayName":"LICENSE.md","repoName":"ml-stable-diffusion","refName":"main","path":"LICENSE.md","preferredFileType":"license","tabName":"MIT","richText":null,"loaded":false,"timedOut":false,"errorMessage":null,"headerInfo":{"toc":null,"siteNavLoginPath":"/login?return_to=https%3A%2F%2Fgithub.com%2Fapple%2Fml-stable-diffusion"}}],"overviewFilesProcessingTime":0}},"appPayload":{"helpUrl":"https://docs.github.com","findFileWorkerPath":"/assets-cdn/worker/find-file-worker-7d7eb7c71814.js","findInFileWorkerPath":"/assets-cdn/worker/find-in-file-worker-96e76d5fdb2c.js","githubDevUrl":null,"enabled_features":{"copilot_workspace":null,"code_nav_ui_events":false,"overview_shared_code_dropdown_button":false,"react_blob_overlay":false,"accessible_code_button":true,"github_models_repo_integration":false}}}}</script> <div data-target="react-partial.reactRoot"><style data-styled="true" data-styled-version="5.3.11">.iVEunk{margin-top:16px;margin-bottom:16px;}/*!sc*/ .jzuOtQ{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;-webkit-box-pack:justify;-webkit-justify-content:space-between;-ms-flex-pack:justify;justify-content:space-between;}/*!sc*/ .bGojzy{margin-bottom:0;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;row-gap:16px;}/*!sc*/ .iNSVHo{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:justify;-webkit-justify-content:space-between;-ms-flex-pack:justify;justify-content:space-between;-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;padding-bottom:16px;padding-top:8px;}/*!sc*/ .bVgnfw{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;gap:8px;}/*!sc*/ @media screen and (max-width:320px){.bVgnfw{-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;}}/*!sc*/ .CEgMp{position:relative;}/*!sc*/ @media screen and (max-width:380px){.CEgMp .ref-selector-button-text-container{max-width:80px;}}/*!sc*/ @media screen and (max-width:320px){.CEgMp{-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;}.CEgMp .overview-ref-selector{width:100%;}.CEgMp .overview-ref-selector > span{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:start;-webkit-justify-content:flex-start;-ms-flex-pack:start;justify-content:flex-start;}.CEgMp .overview-ref-selector > span > span[data-component="text"]{-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;}}/*!sc*/ .gMOVLe[data-size="medium"]{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;min-width:0;}/*!sc*/ .gMOVLe[data-size="medium"] svg{color:var(--fgColor-muted,var(--color-fg-muted,#656d76));}/*!sc*/ .gMOVLe[data-size="medium"] > span{width:inherit;}/*!sc*/ .gUkoLg{-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;}/*!sc*/ .bZBlpz{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;width:100%;}/*!sc*/ .lhTYNA{margin-right:4px;color:var(--fgColor-muted,var(--color-fg-muted,#656d76));}/*!sc*/ .ffLUq{font-size:14px;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}/*!sc*/ .bmcJak{min-width:0;}/*!sc*/ .fLXEGX{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}/*!sc*/ @media screen and (max-width:1079px){.fLXEGX{display:none;}}/*!sc*/ .lmSMZJ[data-size="medium"]{color:var(--fgColor-muted,var(--color-fg-muted,#656d76));padding-left:4px;padding-right:4px;}/*!sc*/ .lmSMZJ[data-size="medium"] span[data-component="leadingVisual"]{margin-right:4px !important;}/*!sc*/ .dqfxud{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}/*!sc*/ @media screen and (min-width:1080px){.dqfxud{display:none;}}/*!sc*/ @media screen and (max-width:543px){.dqfxud{display:none;}}/*!sc*/ .fGwBZA[data-size="medium"][data-no-visuals]{color:var(--fgColor-muted,var(--color-fg-muted,#656d76));}/*!sc*/ .jxTzTd{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;padding-left:8px;gap:8px;}/*!sc*/ .gqqBXN{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;gap:8px;}/*!sc*/ @media screen and (max-width:543px){.gqqBXN{display:none;}}/*!sc*/ .dzXgxt{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}/*!sc*/ @media screen and (max-width:1011px){.dzXgxt{display:none;}}/*!sc*/ .iWFGlI{margin-left:8px;margin-right:8px;margin:0;}/*!sc*/ .vcvyP{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;min-width:160px;}/*!sc*/ .YUPas{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}/*!sc*/ @media screen and (min-width:1012px){.YUPas{display:none;}}/*!sc*/ .izFOf{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}/*!sc*/ @media screen and (min-width:544px){.izFOf{display:none;}}/*!sc*/ .vIPPs{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;gap:16px;}/*!sc*/ .fdROMU{width:100%;border-collapse:separate;border-spacing:0;border:1px solid;border-color:var(--borderColor-default,var(--color-border-default,#d0d7de));border-radius:6px;table-layout:fixed;overflow:unset;}/*!sc*/ .jGKpsv{height:0px;line-height:0px;}/*!sc*/ .jGKpsv tr{height:0px;font-size:0px;}/*!sc*/ .jdgHnn{padding:16px;color:var(--fgColor-muted,var(--color-fg-muted,#656d76));font-size:12px;text-align:left;height:40px;}/*!sc*/ .jdgHnn th{padding-left:16px;background-color:var(--bgColor-muted,var(--color-canvas-subtle,#f6f8fa));}/*!sc*/ .bQivRW{width:100%;border-top-left-radius:6px;}/*!sc*/ @media screen and (min-width:544px){.bQivRW{display:none;}}/*!sc*/ .ldkMIO{width:40%;border-top-left-radius:6px;}/*!sc*/ @media screen and (max-width:543px){.ldkMIO{display:none;}}/*!sc*/ .jMbWeI{text-align:right;padding-right:16px;width:136px;border-top-right-radius:6px;}/*!sc*/ .gpqjiB{color:var(--fgColor-muted,var(--color-fg-muted,#656d76));font-size:12px;height:40px;}/*!sc*/ .dzCJzi{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;-webkit-flex-wrap:wrap;-ms-flex-wrap:wrap;flex-wrap:wrap;-webkit-box-pack:justify;-webkit-justify-content:space-between;-ms-flex-pack:justify;justify-content:space-between;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;gap:8px;min-width:273px;padding:8px;}/*!sc*/ @media screen and (min-width:544px){.dzCJzi{-webkit-flex-wrap:nowrap;-ms-flex-wrap:nowrap;flex-wrap:nowrap;}}/*!sc*/ .eNCcrz{text-align:center;vertical-align:center;height:40px;border-top:1px solid;border-color:var(--borderColor-default,var(--color-border-default,#d0d7de));}/*!sc*/ .bHTcCe{border-top:1px solid var(--borderColor-default,var(--color-border-default));cursor:pointer;}/*!sc*/ .csrIcr{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;gap:16px;}/*!sc*/ .bUQNHB{border:1px solid;border-color:var(--borderColor-default,var(--color-border-default,#d0d7de));border-radius:6px;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;}/*!sc*/ @media screen and (max-width:543px){.bUQNHB{margin-left:-16px;margin-right:-16px;max-width:calc(100% + 32px);}}/*!sc*/ @media screen and (min-width:544px){.bUQNHB{max-width:100%;}}/*!sc*/ .jPdcfu{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;border-bottom:1px solid;border-bottom-color:var(--borderColor-default,var(--color-border-default,#d0d7de));-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;padding-right:8px;position:-webkit-sticky;position:sticky;top:0;background-color:var(--bgColor-default,var(--color-canvas-default,#ffffff));z-index:1;border-top-left-radius:6px;border-top-right-radius:6px;}/*!sc*/ .iphEWz{-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;border-bottom:none;max-width:100%;padding-left:8px;padding-right:8px;}/*!sc*/ .hUCRAk{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}/*!sc*/ .cwoBXV[data-size="medium"]{color:var(--fgColor-muted,var(--color-fg-subtle,#6e7781));padding-left:8px;padding-right:8px;}/*!sc*/ .QkQOb{padding:32px;overflow:auto;}/*!sc*/ data-styled.g1[id="Box-sc-g0xbh4-0"]{content:"iVEunk,jzuOtQ,bGojzy,iNSVHo,bVgnfw,CEgMp,gMOVLe,gUkoLg,bZBlpz,lhTYNA,ffLUq,bmcJak,fLXEGX,lmSMZJ,dqfxud,fGwBZA,jxTzTd,gqqBXN,dzXgxt,iWFGlI,vcvyP,YUPas,izFOf,vIPPs,fdROMU,jGKpsv,jdgHnn,bQivRW,ldkMIO,jMbWeI,gpqjiB,dzCJzi,eNCcrz,bHTcCe,csrIcr,bUQNHB,jPdcfu,iphEWz,hUCRAk,cwoBXV,QkQOb,"}/*!sc*/ .brGdpi{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;-webkit-clip:rect(0,0,0,0);clip:rect(0,0,0,0);white-space:nowrap;border-width:0;}/*!sc*/ data-styled.g5[id="_VisuallyHidden__VisuallyHidden-sc-11jhm7a-0"]{content:"brGdpi,"}/*!sc*/ .hWlpPn{position:relative;display:inline-block;}/*!sc*/ .hWlpPn::after{position:absolute;z-index:1000000;display:none;padding:0.5em 0.75em;font:normal normal 11px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";-webkit-font-smoothing:subpixel-antialiased;color:var(--tooltip-fgColor,var(--fgColor-onEmphasis,var(--color-fg-on-emphasis,#ffffff)));text-align:center;-webkit-text-decoration:none;text-decoration:none;text-shadow:none;text-transform:none;-webkit-letter-spacing:normal;-moz-letter-spacing:normal;-ms-letter-spacing:normal;letter-spacing:normal;word-wrap:break-word;white-space:pre;pointer-events:none;content:attr(aria-label);background:var(--tooltip-bgColor,var(--bgColor-emphasis,var(--color-neutral-emphasis-plus,#24292f)));border-radius:6px;opacity:0;}/*!sc*/ @-webkit-keyframes tooltip-appear{from{opacity:0;}to{opacity:1;}}/*!sc*/ @keyframes tooltip-appear{from{opacity:0;}to{opacity:1;}}/*!sc*/ .hWlpPn:hover::after,.hWlpPn:active::after,.hWlpPn:focus::after,.hWlpPn:focus-within::after{display:inline-block;-webkit-text-decoration:none;text-decoration:none;-webkit-animation-name:tooltip-appear;animation-name:tooltip-appear;-webkit-animation-duration:0.1s;animation-duration:0.1s;-webkit-animation-fill-mode:forwards;animation-fill-mode:forwards;-webkit-animation-timing-function:ease-in;animation-timing-function:ease-in;-webkit-animation-delay:0s;animation-delay:0s;}/*!sc*/ .hWlpPn.tooltipped-no-delay:hover::after,.hWlpPn.tooltipped-no-delay:active::after,.hWlpPn.tooltipped-no-delay:focus::after,.hWlpPn.tooltipped-no-delay:focus-within::after{-webkit-animation-delay:0s;animation-delay:0s;}/*!sc*/ .hWlpPn.tooltipped-multiline:hover::after,.hWlpPn.tooltipped-multiline:active::after,.hWlpPn.tooltipped-multiline:focus::after,.hWlpPn.tooltipped-multiline:focus-within::after{display:table-cell;}/*!sc*/ .hWlpPn.tooltipped-s::after,.hWlpPn.tooltipped-se::after,.hWlpPn.tooltipped-sw::after{top:100%;right:50%;margin-top:6px;}/*!sc*/ .hWlpPn.tooltipped-se::after{right:auto;left:50%;margin-left:-16px;}/*!sc*/ .hWlpPn.tooltipped-sw::after{margin-right:-16px;}/*!sc*/ .hWlpPn.tooltipped-n::after,.hWlpPn.tooltipped-ne::after,.hWlpPn.tooltipped-nw::after{right:50%;bottom:100%;margin-bottom:6px;}/*!sc*/ .hWlpPn.tooltipped-ne::after{right:auto;left:50%;margin-left:-16px;}/*!sc*/ .hWlpPn.tooltipped-nw::after{margin-right:-16px;}/*!sc*/ .hWlpPn.tooltipped-s::after,.hWlpPn.tooltipped-n::after{-webkit-transform:translateX(50%);-ms-transform:translateX(50%);transform:translateX(50%);}/*!sc*/ .hWlpPn.tooltipped-w::after{right:100%;bottom:50%;margin-right:6px;-webkit-transform:translateY(50%);-ms-transform:translateY(50%);transform:translateY(50%);}/*!sc*/ .hWlpPn.tooltipped-e::after{bottom:50%;left:100%;margin-left:6px;-webkit-transform:translateY(50%);-ms-transform:translateY(50%);transform:translateY(50%);}/*!sc*/ .hWlpPn.tooltipped-multiline::after{width:-webkit-max-content;width:-moz-max-content;width:max-content;max-width:250px;word-wrap:break-word;white-space:pre-line;border-collapse:separate;}/*!sc*/ .hWlpPn.tooltipped-multiline.tooltipped-s::after,.hWlpPn.tooltipped-multiline.tooltipped-n::after{right:auto;left:50%;-webkit-transform:translateX(-50%);-ms-transform:translateX(-50%);transform:translateX(-50%);}/*!sc*/ .hWlpPn.tooltipped-multiline.tooltipped-w::after,.hWlpPn.tooltipped-multiline.tooltipped-e::after{right:100%;}/*!sc*/ .hWlpPn.tooltipped-align-right-2::after{right:0;margin-right:0;}/*!sc*/ .hWlpPn.tooltipped-align-left-2::after{left:0;margin-left:0;}/*!sc*/ data-styled.g16[id="Tooltip__TooltipBase-sc-17tf59c-0"]{content:"hWlpPn,"}/*!sc*/ .liVpTx{display:inline-block;overflow:hidden;text-overflow:ellipsis;vertical-align:top;white-space:nowrap;max-width:125px;}/*!sc*/ data-styled.g18[id="Truncate__StyledTruncate-sc-23o1d2-0"]{content:"liVpTx,"}/*!sc*/ </style> <!-- --> <!-- --> <div class="Box-sc-g0xbh4-0 iVEunk"><div class="Box-sc-g0xbh4-0 jzuOtQ"><div class="Box-sc-g0xbh4-0 bGojzy"></div></div><div class="Box-sc-g0xbh4-0 iNSVHo"><div class="Box-sc-g0xbh4-0 bVgnfw"><div class="Box-sc-g0xbh4-0 CEgMp"><button type="button" aria-haspopup="true" aria-expanded="false" tabindex="0" aria-label="main branch" data-testid="anchor-button" class="Box-sc-g0xbh4-0 gMOVLe prc-Button-ButtonBase-c50BI overview-ref-selector width-full" data-loading="false" data-size="medium" data-variant="default" aria-describedby="branch-picker-repos-header-ref-selector-loading-announcement" id="branch-picker-repos-header-ref-selector"><span data-component="buttonContent" class="Box-sc-g0xbh4-0 gUkoLg prc-Button-ButtonContent-HKbr-"><span data-component="text" class="prc-Button-Label-pTQ3x"><div class="Box-sc-g0xbh4-0 bZBlpz"><div class="Box-sc-g0xbh4-0 lhTYNA"><svg aria-hidden="true" focusable="false" class="octicon octicon-git-branch" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M9.5 3.25a2.25 2.25 0 1 1 3 2.122V6A2.5 2.5 0 0 1 10 8.5H6a1 1 0 0 0-1 1v1.128a2.251 2.251 0 1 1-1.5 0V5.372a2.25 2.25 0 1 1 1.5 0v1.836A2.493 2.493 0 0 1 6 7h4a1 1 0 0 0 1-1v-.628A2.25 2.25 0 0 1 9.5 3.25Zm-6 0a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Zm8.25-.75a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5ZM4.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Z"></path></svg></div><div class="Box-sc-g0xbh4-0 ffLUq ref-selector-button-text-container"><span class="Box-sc-g0xbh4-0 bmcJak prc-Text-Text-0ima0"> <!-- -->main</span></div></div></span><span data-component="trailingVisual" class="prc-Button-Visual-2epfX prc-Button-VisualWrap-Db-eB"><svg aria-hidden="true" focusable="false" class="octicon octicon-triangle-down" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="m4.427 7.427 3.396 3.396a.25.25 0 0 0 .354 0l3.396-3.396A.25.25 0 0 0 11.396 7H4.604a.25.25 0 0 0-.177.427Z"></path></svg></span></span></button><button hidden="" data-hotkey-scope="read-only-cursor-text-area"></button></div><div class="Box-sc-g0xbh4-0 fLXEGX"><a style="--button-color:fg.muted" type="button" href="/apple/ml-stable-diffusion/branches" class="Box-sc-g0xbh4-0 lmSMZJ prc-Button-ButtonBase-c50BI" data-loading="false" data-size="medium" data-variant="invisible" aria-describedby=":Rclab:-loading-announcement"><span data-component="buttonContent" class="Box-sc-g0xbh4-0 gUkoLg prc-Button-ButtonContent-HKbr-"><span data-component="leadingVisual" class="prc-Button-Visual-2epfX prc-Button-VisualWrap-Db-eB"><svg aria-hidden="true" focusable="false" class="octicon octicon-git-branch" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M9.5 3.25a2.25 2.25 0 1 1 3 2.122V6A2.5 2.5 0 0 1 10 8.5H6a1 1 0 0 0-1 1v1.128a2.251 2.251 0 1 1-1.5 0V5.372a2.25 2.25 0 1 1 1.5 0v1.836A2.493 2.493 0 0 1 6 7h4a1 1 0 0 0 1-1v-.628A2.25 2.25 0 0 1 9.5 3.25Zm-6 0a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Zm8.25-.75a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5ZM4.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Z"></path></svg></span><span data-component="text" class="prc-Button-Label-pTQ3x">Branches</span></span></a><a style="--button-color:fg.muted" type="button" href="/apple/ml-stable-diffusion/tags" class="Box-sc-g0xbh4-0 lmSMZJ prc-Button-ButtonBase-c50BI" data-loading="false" data-size="medium" data-variant="invisible" aria-describedby=":Rklab:-loading-announcement"><span data-component="buttonContent" class="Box-sc-g0xbh4-0 gUkoLg prc-Button-ButtonContent-HKbr-"><span data-component="leadingVisual" class="prc-Button-Visual-2epfX prc-Button-VisualWrap-Db-eB"><svg aria-hidden="true" focusable="false" class="octicon octicon-tag" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M1 7.775V2.75C1 1.784 1.784 1 2.75 1h5.025c.464 0 .91.184 1.238.513l6.25 6.25a1.75 1.75 0 0 1 0 2.474l-5.026 5.026a1.75 1.75 0 0 1-2.474 0l-6.25-6.25A1.752 1.752 0 0 1 1 7.775Zm1.5 0c0 .066.026.13.073.177l6.25 6.25a.25.25 0 0 0 .354 0l5.025-5.025a.25.25 0 0 0 0-.354l-6.25-6.25a.25.25 0 0 0-.177-.073H2.75a.25.25 0 0 0-.25.25ZM6 5a1 1 0 1 1 0 2 1 1 0 0 1 0-2Z"></path></svg></span><span data-component="text" class="prc-Button-Label-pTQ3x">Tags</span></span></a></div><div class="Box-sc-g0xbh4-0 dqfxud"><a style="--button-color:fg.muted" type="button" aria-label="Go to Branches page" href="/apple/ml-stable-diffusion/branches" class="Box-sc-g0xbh4-0 fGwBZA prc-Button-ButtonBase-c50BI" data-loading="false" data-no-visuals="true" data-size="medium" data-variant="invisible" aria-describedby=":Relab:-loading-announcement"><svg aria-hidden="true" focusable="false" class="octicon octicon-git-branch" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M9.5 3.25a2.25 2.25 0 1 1 3 2.122V6A2.5 2.5 0 0 1 10 8.5H6a1 1 0 0 0-1 1v1.128a2.251 2.251 0 1 1-1.5 0V5.372a2.25 2.25 0 1 1 1.5 0v1.836A2.493 2.493 0 0 1 6 7h4a1 1 0 0 0 1-1v-.628A2.25 2.25 0 0 1 9.5 3.25Zm-6 0a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Zm8.25-.75a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5ZM4.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Z"></path></svg></a><a style="--button-color:fg.muted" type="button" aria-label="Go to Tags page" href="/apple/ml-stable-diffusion/tags" class="Box-sc-g0xbh4-0 fGwBZA prc-Button-ButtonBase-c50BI" data-loading="false" data-no-visuals="true" data-size="medium" data-variant="invisible" aria-describedby=":Rmlab:-loading-announcement"><svg aria-hidden="true" focusable="false" class="octicon octicon-tag" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M1 7.775V2.75C1 1.784 1.784 1 2.75 1h5.025c.464 0 .91.184 1.238.513l6.25 6.25a1.75 1.75 0 0 1 0 2.474l-5.026 5.026a1.75 1.75 0 0 1-2.474 0l-6.25-6.25A1.752 1.752 0 0 1 1 7.775Zm1.5 0c0 .066.026.13.073.177l6.25 6.25a.25.25 0 0 0 .354 0l5.025-5.025a.25.25 0 0 0 0-.354l-6.25-6.25a.25.25 0 0 0-.177-.073H2.75a.25.25 0 0 0-.25.25ZM6 5a1 1 0 1 1 0 2 1 1 0 0 1 0-2Z"></path></svg></a></div></div><div class="Box-sc-g0xbh4-0 jxTzTd"><div class="Box-sc-g0xbh4-0 gqqBXN"><div class="Box-sc-g0xbh4-0 dzXgxt"><!--$--><div class="Box-sc-g0xbh4-0 iWFGlI"><span class="Box-sc-g0xbh4-0 vcvyP TextInput-wrapper prc-components-TextInputWrapper-i1ofR prc-components-TextInputBaseWrapper-ueK9q" data-leading-visual="true" data-trailing-visual="true" aria-busy="false"><span class="TextInput-icon" id=":R2j5ab:" aria-hidden="true"><svg aria-hidden="true" focusable="false" class="octicon octicon-search" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg></span><input type="text" aria-label="Go to file" role="combobox" aria-controls="file-results-list" aria-expanded="false" aria-haspopup="dialog" autoCorrect="off" spellcheck="false" placeholder="Go to file" aria-describedby=":R2j5ab: :R2j5abH1:" data-component="input" class="prc-components-Input-Ic-y8" value=""/><span class="TextInput-icon" id=":R2j5abH1:" aria-hidden="true"></span></span></div><!--/$--></div><div class="Box-sc-g0xbh4-0 YUPas"><button type="button" class="prc-Button-ButtonBase-c50BI" data-loading="false" data-no-visuals="true" data-size="medium" data-variant="default" aria-describedby=":Rr5ab:-loading-announcement"><span data-component="buttonContent" data-align="center" class="prc-Button-ButtonContent-HKbr-"><span data-component="text" class="prc-Button-Label-pTQ3x">Go to file</span></span></button></div><div class="react-directory-add-file-icon"></div><div class="react-directory-remove-file-icon"></div></div><button type="button" aria-haspopup="true" aria-expanded="false" tabindex="0" class="prc-Button-ButtonBase-c50BI" data-loading="false" data-size="medium" data-variant="primary" aria-describedby=":R55ab:-loading-announcement" id=":R55ab:"><span data-component="buttonContent" data-align="center" class="prc-Button-ButtonContent-HKbr-"><span data-component="leadingVisual" class="prc-Button-Visual-2epfX prc-Button-VisualWrap-Db-eB"><svg aria-hidden="true" focusable="false" class="octicon octicon-code hide-sm" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="m11.28 3.22 4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L13.94 8l-3.72-3.72a.749.749 0 0 1 .326-1.275.749.749 0 0 1 .734.215Zm-6.56 0a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042L2.06 8l3.72 3.72a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L.47 8.53a.75.75 0 0 1 0-1.06Z"></path></svg></span><span data-component="text" class="prc-Button-Label-pTQ3x">Code</span><span data-component="trailingVisual" class="prc-Button-Visual-2epfX prc-Button-VisualWrap-Db-eB"><svg aria-hidden="true" focusable="false" class="octicon octicon-triangle-down" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="m4.427 7.427 3.396 3.396a.25.25 0 0 0 .354 0l3.396-3.396A.25.25 0 0 0 11.396 7H4.604a.25.25 0 0 0-.177.427Z"></path></svg></span></span></button><div class="Box-sc-g0xbh4-0 izFOf"><button data-component="IconButton" type="button" aria-label="Open more actions menu" aria-haspopup="true" aria-expanded="false" tabindex="0" class="prc-Button-ButtonBase-c50BI prc-Button-IconButton-szpyj" data-loading="false" data-no-visuals="true" data-size="medium" data-variant="default" aria-describedby=":R75ab:-loading-announcement" id=":R75ab:"><svg aria-hidden="true" focusable="false" class="octicon octicon-kebab-horizontal" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M8 9a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3ZM1.5 9a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Zm13 0a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z"></path></svg></button></div></div></div><div class="Box-sc-g0xbh4-0 vIPPs"><div data-hpc="true"><button hidden="" data-testid="focus-next-element-button" data-hotkey="j"></button><button hidden="" data-testid="focus-previous-element-button" data-hotkey="k"></button><h2 class="sr-only ScreenReaderHeading-module__userSelectNone--vW4Cq prc-Heading-Heading-6CmGO" data-testid="screen-reader-heading" id="folders-and-files">Folders and files</h2><table aria-labelledby="folders-and-files" class="Box-sc-g0xbh4-0 fdROMU"><thead class="Box-sc-g0xbh4-0 jGKpsv"><tr class="Box-sc-g0xbh4-0 jdgHnn"><th colSpan="2" class="Box-sc-g0xbh4-0 bQivRW"><span class="text-bold">Name</span></th><th colSpan="1" class="Box-sc-g0xbh4-0 ldkMIO"><span class="text-bold">Name</span></th><th class="hide-sm"><div title="Last commit message" class="Truncate__StyledTruncate-sc-23o1d2-0 liVpTx width-fit"><span class="text-bold">Last commit message</span></div></th><th colSpan="1" class="Box-sc-g0xbh4-0 jMbWeI"><div title="Last commit date" class="Truncate__StyledTruncate-sc-23o1d2-0 liVpTx width-fit"><span class="text-bold">Last commit date</span></div></th></tr></thead><tbody><tr class="Box-sc-g0xbh4-0 gpqjiB"><td colSpan="3" class="bgColor-muted p-1 rounded-top-2"><div class="Box-sc-g0xbh4-0 dzCJzi"><h2 class="sr-only ScreenReaderHeading-module__userSelectNone--vW4Cq prc-Heading-Heading-6CmGO" data-testid="screen-reader-heading">Latest commit</h2><div style="width:120px" class="Skeleton Skeleton--text" data-testid="loading"> </div><div class="d-flex flex-shrink-0 gap-2"><div data-testid="latest-commit-details" class="d-none d-sm-flex flex-items-center"></div><div class="d-flex gap-2"><h2 class="sr-only ScreenReaderHeading-module__userSelectNone--vW4Cq prc-Heading-Heading-6CmGO" data-testid="screen-reader-heading">History</h2><a href="/apple/ml-stable-diffusion/commits/main/" class="prc-Button-ButtonBase-c50BI d-none d-lg-flex LinkButton-module__code-view-link-button--xvCGA flex-items-center fgColor-default" data-loading="false" data-size="small" data-variant="invisible" aria-describedby=":Raqj8pab:-loading-announcement"><span data-component="buttonContent" data-align="center" class="prc-Button-ButtonContent-HKbr-"><span data-component="leadingVisual" class="prc-Button-Visual-2epfX prc-Button-VisualWrap-Db-eB"><svg aria-hidden="true" focusable="false" class="octicon octicon-history" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="m.427 1.927 1.215 1.215a8.002 8.002 0 1 1-1.6 5.685.75.75 0 1 1 1.493-.154 6.5 6.5 0 1 0 1.18-4.458l1.358 1.358A.25.25 0 0 1 3.896 6H.25A.25.25 0 0 1 0 5.75V2.104a.25.25 0 0 1 .427-.177ZM7.75 4a.75.75 0 0 1 .75.75v2.992l2.028.812a.75.75 0 0 1-.557 1.392l-2.5-1A.751.751 0 0 1 7 8.25v-3.5A.75.75 0 0 1 7.75 4Z"></path></svg></span><span data-component="text" class="prc-Button-Label-pTQ3x"><span class="fgColor-default">121 Commits</span></span></span></a><div class="d-sm-none"></div><div class="d-flex d-lg-none"><span role="tooltip" aria-label="121 Commits" id="history-icon-button-tooltip" class="Tooltip__TooltipBase-sc-17tf59c-0 hWlpPn tooltipped-n"><a href="/apple/ml-stable-diffusion/commits/main/" class="prc-Button-ButtonBase-c50BI LinkButton-module__code-view-link-button--xvCGA flex-items-center fgColor-default" data-loading="false" data-size="small" data-variant="invisible" aria-describedby=":R1iqj8pab:-loading-announcement history-icon-button-tooltip"><span data-component="buttonContent" data-align="center" class="prc-Button-ButtonContent-HKbr-"><span data-component="leadingVisual" class="prc-Button-Visual-2epfX prc-Button-VisualWrap-Db-eB"><svg aria-hidden="true" focusable="false" class="octicon octicon-history" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="m.427 1.927 1.215 1.215a8.002 8.002 0 1 1-1.6 5.685.75.75 0 1 1 1.493-.154 6.5 6.5 0 1 0 1.18-4.458l1.358 1.358A.25.25 0 0 1 3.896 6H.25A.25.25 0 0 1 0 5.75V2.104a.25.25 0 0 1 .427-.177ZM7.75 4a.75.75 0 0 1 .75.75v2.992l2.028.812a.75.75 0 0 1-.557 1.392l-2.5-1A.751.751 0 0 1 7 8.25v-3.5A.75.75 0 0 1 7.75 4Z"></path></svg></span></span></a></span></div></div></div></div></td></tr><tr class="react-directory-row undefined" id="folder-row-0"><td class="react-directory-row-name-cell-small-screen" colSpan="2"><div class="react-directory-filename-column"><svg aria-hidden="true" focusable="false" class="octicon octicon-file-directory-fill icon-directory" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M1.75 1A1.75 1.75 0 0 0 0 2.75v10.5C0 14.216.784 15 1.75 15h12.5A1.75 1.75 0 0 0 16 13.25v-8.5A1.75 1.75 0 0 0 14.25 3H7.5a.25.25 0 0 1-.2-.1l-.9-1.2C6.07 1.26 5.55 1 5 1H1.75Z"></path></svg><div class="overflow-hidden"><div class="react-directory-filename-cell"><div class="react-directory-truncate"><a title=".github" aria-label=".github, (Directory)" class="Link--primary" href="/apple/ml-stable-diffusion/tree/main/.github">.github</a></div></div></div></div></td><td class="react-directory-row-name-cell-large-screen" colSpan="1"><div class="react-directory-filename-column"><svg aria-hidden="true" focusable="false" class="octicon octicon-file-directory-fill icon-directory" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M1.75 1A1.75 1.75 0 0 0 0 2.75v10.5C0 14.216.784 15 1.75 15h12.5A1.75 1.75 0 0 0 16 13.25v-8.5A1.75 1.75 0 0 0 14.25 3H7.5a.25.25 0 0 1-.2-.1l-.9-1.2C6.07 1.26 5.55 1 5 1H1.75Z"></path></svg><div class="overflow-hidden"><div class="react-directory-filename-cell"><div class="react-directory-truncate"><a title=".github" aria-label=".github, (Directory)" class="Link--primary" href="/apple/ml-stable-diffusion/tree/main/.github">.github</a></div></div></div></div></td><td class="react-directory-row-commit-cell"><div class="Skeleton Skeleton--text"> </div></td><td><div class="Skeleton Skeleton--text"> </div></td></tr><tr class="react-directory-row undefined" id="folder-row-1"><td class="react-directory-row-name-cell-small-screen" colSpan="2"><div class="react-directory-filename-column"><svg aria-hidden="true" focusable="false" class="octicon octicon-file-directory-fill icon-directory" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M1.75 1A1.75 1.75 0 0 0 0 2.75v10.5C0 14.216.784 15 1.75 15h12.5A1.75 1.75 0 0 0 16 13.25v-8.5A1.75 1.75 0 0 0 14.25 3H7.5a.25.25 0 0 1-.2-.1l-.9-1.2C6.07 1.26 5.55 1 5 1H1.75Z"></path></svg><div class="overflow-hidden"><div class="react-directory-filename-cell"><div class="react-directory-truncate"><a title="assets" aria-label="assets, (Directory)" class="Link--primary" href="/apple/ml-stable-diffusion/tree/main/assets">assets</a></div></div></div></div></td><td class="react-directory-row-name-cell-large-screen" colSpan="1"><div class="react-directory-filename-column"><svg aria-hidden="true" focusable="false" class="octicon octicon-file-directory-fill icon-directory" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M1.75 1A1.75 1.75 0 0 0 0 2.75v10.5C0 14.216.784 15 1.75 15h12.5A1.75 1.75 0 0 0 16 13.25v-8.5A1.75 1.75 0 0 0 14.25 3H7.5a.25.25 0 0 1-.2-.1l-.9-1.2C6.07 1.26 5.55 1 5 1H1.75Z"></path></svg><div class="overflow-hidden"><div class="react-directory-filename-cell"><div class="react-directory-truncate"><a title="assets" aria-label="assets, (Directory)" class="Link--primary" href="/apple/ml-stable-diffusion/tree/main/assets">assets</a></div></div></div></div></td><td class="react-directory-row-commit-cell"><div class="Skeleton Skeleton--text"> </div></td><td><div class="Skeleton Skeleton--text"> </div></td></tr><tr class="react-directory-row undefined" id="folder-row-2"><td class="react-directory-row-name-cell-small-screen" colSpan="2"><div class="react-directory-filename-column"><svg aria-hidden="true" focusable="false" class="octicon octicon-file-directory-fill icon-directory" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M1.75 1A1.75 1.75 0 0 0 0 2.75v10.5C0 14.216.784 15 1.75 15h12.5A1.75 1.75 0 0 0 16 13.25v-8.5A1.75 1.75 0 0 0 14.25 3H7.5a.25.25 0 0 1-.2-.1l-.9-1.2C6.07 1.26 5.55 1 5 1H1.75Z"></path></svg><div class="overflow-hidden"><div class="react-directory-filename-cell"><div class="react-directory-truncate"><a title="python_coreml_stable_diffusion" aria-label="python_coreml_stable_diffusion, (Directory)" class="Link--primary" href="/apple/ml-stable-diffusion/tree/main/python_coreml_stable_diffusion">python_coreml_stable_diffusion</a></div></div></div></div></td><td class="react-directory-row-name-cell-large-screen" colSpan="1"><div class="react-directory-filename-column"><svg aria-hidden="true" focusable="false" class="octicon octicon-file-directory-fill icon-directory" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M1.75 1A1.75 1.75 0 0 0 0 2.75v10.5C0 14.216.784 15 1.75 15h12.5A1.75 1.75 0 0 0 16 13.25v-8.5A1.75 1.75 0 0 0 14.25 3H7.5a.25.25 0 0 1-.2-.1l-.9-1.2C6.07 1.26 5.55 1 5 1H1.75Z"></path></svg><div class="overflow-hidden"><div class="react-directory-filename-cell"><div class="react-directory-truncate"><a title="python_coreml_stable_diffusion" aria-label="python_coreml_stable_diffusion, (Directory)" class="Link--primary" href="/apple/ml-stable-diffusion/tree/main/python_coreml_stable_diffusion">python_coreml_stable_diffusion</a></div></div></div></div></td><td class="react-directory-row-commit-cell"><div class="Skeleton Skeleton--text"> </div></td><td><div class="Skeleton Skeleton--text"> </div></td></tr><tr class="react-directory-row undefined" id="folder-row-3"><td class="react-directory-row-name-cell-small-screen" colSpan="2"><div class="react-directory-filename-column"><svg aria-hidden="true" focusable="false" class="octicon octicon-file-directory-fill icon-directory" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M1.75 1A1.75 1.75 0 0 0 0 2.75v10.5C0 14.216.784 15 1.75 15h12.5A1.75 1.75 0 0 0 16 13.25v-8.5A1.75 1.75 0 0 0 14.25 3H7.5a.25.25 0 0 1-.2-.1l-.9-1.2C6.07 1.26 5.55 1 5 1H1.75Z"></path></svg><div class="overflow-hidden"><div class="react-directory-filename-cell"><div class="react-directory-truncate"><a title="swift" aria-label="swift, (Directory)" class="Link--primary" href="/apple/ml-stable-diffusion/tree/main/swift">swift</a></div></div></div></div></td><td class="react-directory-row-name-cell-large-screen" colSpan="1"><div class="react-directory-filename-column"><svg aria-hidden="true" focusable="false" class="octicon octicon-file-directory-fill icon-directory" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M1.75 1A1.75 1.75 0 0 0 0 2.75v10.5C0 14.216.784 15 1.75 15h12.5A1.75 1.75 0 0 0 16 13.25v-8.5A1.75 1.75 0 0 0 14.25 3H7.5a.25.25 0 0 1-.2-.1l-.9-1.2C6.07 1.26 5.55 1 5 1H1.75Z"></path></svg><div class="overflow-hidden"><div class="react-directory-filename-cell"><div class="react-directory-truncate"><a title="swift" aria-label="swift, (Directory)" class="Link--primary" href="/apple/ml-stable-diffusion/tree/main/swift">swift</a></div></div></div></div></td><td class="react-directory-row-commit-cell"><div class="Skeleton Skeleton--text"> </div></td><td><div class="Skeleton Skeleton--text"> </div></td></tr><tr class="react-directory-row undefined" id="folder-row-4"><td class="react-directory-row-name-cell-small-screen" colSpan="2"><div class="react-directory-filename-column"><svg aria-hidden="true" focusable="false" class="octicon octicon-file-directory-fill icon-directory" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M1.75 1A1.75 1.75 0 0 0 0 2.75v10.5C0 14.216.784 15 1.75 15h12.5A1.75 1.75 0 0 0 16 13.25v-8.5A1.75 1.75 0 0 0 14.25 3H7.5a.25.25 0 0 1-.2-.1l-.9-1.2C6.07 1.26 5.55 1 5 1H1.75Z"></path></svg><div class="overflow-hidden"><div class="react-directory-filename-cell"><div class="react-directory-truncate"><a title="tests" aria-label="tests, (Directory)" class="Link--primary" href="/apple/ml-stable-diffusion/tree/main/tests">tests</a></div></div></div></div></td><td class="react-directory-row-name-cell-large-screen" colSpan="1"><div class="react-directory-filename-column"><svg aria-hidden="true" focusable="false" class="octicon octicon-file-directory-fill icon-directory" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M1.75 1A1.75 1.75 0 0 0 0 2.75v10.5C0 14.216.784 15 1.75 15h12.5A1.75 1.75 0 0 0 16 13.25v-8.5A1.75 1.75 0 0 0 14.25 3H7.5a.25.25 0 0 1-.2-.1l-.9-1.2C6.07 1.26 5.55 1 5 1H1.75Z"></path></svg><div class="overflow-hidden"><div class="react-directory-filename-cell"><div class="react-directory-truncate"><a title="tests" aria-label="tests, (Directory)" class="Link--primary" href="/apple/ml-stable-diffusion/tree/main/tests">tests</a></div></div></div></div></td><td class="react-directory-row-commit-cell"><div class="Skeleton Skeleton--text"> </div></td><td><div class="Skeleton Skeleton--text"> </div></td></tr><tr class="react-directory-row undefined" id="folder-row-5"><td class="react-directory-row-name-cell-small-screen" colSpan="2"><div class="react-directory-filename-column"><svg aria-hidden="true" focusable="false" class="octicon octicon-file color-fg-muted" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path></svg><div class="overflow-hidden"><div class="react-directory-filename-cell"><div class="react-directory-truncate"><a title=".gitignore" aria-label=".gitignore, (File)" class="Link--primary" href="/apple/ml-stable-diffusion/blob/main/.gitignore">.gitignore</a></div></div></div></div></td><td class="react-directory-row-name-cell-large-screen" colSpan="1"><div class="react-directory-filename-column"><svg aria-hidden="true" focusable="false" class="octicon octicon-file color-fg-muted" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path></svg><div class="overflow-hidden"><div class="react-directory-filename-cell"><div class="react-directory-truncate"><a title=".gitignore" aria-label=".gitignore, (File)" class="Link--primary" href="/apple/ml-stable-diffusion/blob/main/.gitignore">.gitignore</a></div></div></div></div></td><td class="react-directory-row-commit-cell"><div class="Skeleton Skeleton--text"> </div></td><td><div class="Skeleton Skeleton--text"> </div></td></tr><tr class="react-directory-row undefined" id="folder-row-6"><td class="react-directory-row-name-cell-small-screen" colSpan="2"><div class="react-directory-filename-column"><svg aria-hidden="true" focusable="false" class="octicon octicon-file color-fg-muted" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path></svg><div class="overflow-hidden"><div class="react-directory-filename-cell"><div class="react-directory-truncate"><a title="ACKNOWLEDGEMENTS" aria-label="ACKNOWLEDGEMENTS, (File)" class="Link--primary" href="/apple/ml-stable-diffusion/blob/main/ACKNOWLEDGEMENTS">ACKNOWLEDGEMENTS</a></div></div></div></div></td><td class="react-directory-row-name-cell-large-screen" colSpan="1"><div class="react-directory-filename-column"><svg aria-hidden="true" focusable="false" class="octicon octicon-file color-fg-muted" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path></svg><div class="overflow-hidden"><div class="react-directory-filename-cell"><div class="react-directory-truncate"><a title="ACKNOWLEDGEMENTS" aria-label="ACKNOWLEDGEMENTS, (File)" class="Link--primary" href="/apple/ml-stable-diffusion/blob/main/ACKNOWLEDGEMENTS">ACKNOWLEDGEMENTS</a></div></div></div></div></td><td class="react-directory-row-commit-cell"><div class="Skeleton Skeleton--text"> </div></td><td><div class="Skeleton Skeleton--text"> </div></td></tr><tr class="react-directory-row undefined" id="folder-row-7"><td class="react-directory-row-name-cell-small-screen" colSpan="2"><div class="react-directory-filename-column"><svg aria-hidden="true" focusable="false" class="octicon octicon-file color-fg-muted" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path></svg><div class="overflow-hidden"><div class="react-directory-filename-cell"><div class="react-directory-truncate"><a title="CODE_OF_CONDUCT.md" aria-label="CODE_OF_CONDUCT.md, (File)" class="Link--primary" href="/apple/ml-stable-diffusion/blob/main/CODE_OF_CONDUCT.md">CODE_OF_CONDUCT.md</a></div></div></div></div></td><td class="react-directory-row-name-cell-large-screen" colSpan="1"><div class="react-directory-filename-column"><svg aria-hidden="true" focusable="false" class="octicon octicon-file color-fg-muted" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path></svg><div class="overflow-hidden"><div class="react-directory-filename-cell"><div class="react-directory-truncate"><a title="CODE_OF_CONDUCT.md" aria-label="CODE_OF_CONDUCT.md, (File)" class="Link--primary" href="/apple/ml-stable-diffusion/blob/main/CODE_OF_CONDUCT.md">CODE_OF_CONDUCT.md</a></div></div></div></div></td><td class="react-directory-row-commit-cell"><div class="Skeleton Skeleton--text"> </div></td><td><div class="Skeleton Skeleton--text"> </div></td></tr><tr class="react-directory-row undefined" id="folder-row-8"><td class="react-directory-row-name-cell-small-screen" colSpan="2"><div class="react-directory-filename-column"><svg aria-hidden="true" focusable="false" class="octicon octicon-file color-fg-muted" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path></svg><div class="overflow-hidden"><div class="react-directory-filename-cell"><div class="react-directory-truncate"><a title="CONTRIBUTING.md" aria-label="CONTRIBUTING.md, (File)" class="Link--primary" href="/apple/ml-stable-diffusion/blob/main/CONTRIBUTING.md">CONTRIBUTING.md</a></div></div></div></div></td><td class="react-directory-row-name-cell-large-screen" colSpan="1"><div class="react-directory-filename-column"><svg aria-hidden="true" focusable="false" class="octicon octicon-file color-fg-muted" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path></svg><div class="overflow-hidden"><div class="react-directory-filename-cell"><div class="react-directory-truncate"><a title="CONTRIBUTING.md" aria-label="CONTRIBUTING.md, (File)" class="Link--primary" href="/apple/ml-stable-diffusion/blob/main/CONTRIBUTING.md">CONTRIBUTING.md</a></div></div></div></div></td><td class="react-directory-row-commit-cell"><div class="Skeleton Skeleton--text"> </div></td><td><div class="Skeleton Skeleton--text"> </div></td></tr><tr class="react-directory-row undefined" id="folder-row-9"><td class="react-directory-row-name-cell-small-screen" colSpan="2"><div class="react-directory-filename-column"><svg aria-hidden="true" focusable="false" class="octicon octicon-file color-fg-muted" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path></svg><div class="overflow-hidden"><div class="react-directory-filename-cell"><div class="react-directory-truncate"><a title="LICENSE.md" aria-label="LICENSE.md, (File)" class="Link--primary" href="/apple/ml-stable-diffusion/blob/main/LICENSE.md">LICENSE.md</a></div></div></div></div></td><td class="react-directory-row-name-cell-large-screen" colSpan="1"><div class="react-directory-filename-column"><svg aria-hidden="true" focusable="false" class="octicon octicon-file color-fg-muted" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path></svg><div class="overflow-hidden"><div class="react-directory-filename-cell"><div class="react-directory-truncate"><a title="LICENSE.md" aria-label="LICENSE.md, (File)" class="Link--primary" href="/apple/ml-stable-diffusion/blob/main/LICENSE.md">LICENSE.md</a></div></div></div></div></td><td class="react-directory-row-commit-cell"><div class="Skeleton Skeleton--text"> </div></td><td><div class="Skeleton Skeleton--text"> </div></td></tr><tr class="react-directory-row truncate-for-mobile" id="folder-row-10"><td class="react-directory-row-name-cell-small-screen" colSpan="2"><div class="react-directory-filename-column"><svg aria-hidden="true" focusable="false" class="octicon octicon-file color-fg-muted" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path></svg><div class="overflow-hidden"><div class="react-directory-filename-cell"><div class="react-directory-truncate"><a title="Package.swift" aria-label="Package.swift, (File)" class="Link--primary" href="/apple/ml-stable-diffusion/blob/main/Package.swift">Package.swift</a></div></div></div></div></td><td class="react-directory-row-name-cell-large-screen" colSpan="1"><div class="react-directory-filename-column"><svg aria-hidden="true" focusable="false" class="octicon octicon-file color-fg-muted" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path></svg><div class="overflow-hidden"><div class="react-directory-filename-cell"><div class="react-directory-truncate"><a title="Package.swift" aria-label="Package.swift, (File)" class="Link--primary" href="/apple/ml-stable-diffusion/blob/main/Package.swift">Package.swift</a></div></div></div></div></td><td class="react-directory-row-commit-cell"><div class="Skeleton Skeleton--text"> </div></td><td><div class="Skeleton Skeleton--text"> </div></td></tr><tr class="react-directory-row truncate-for-mobile" id="folder-row-11"><td class="react-directory-row-name-cell-small-screen" colSpan="2"><div class="react-directory-filename-column"><svg aria-hidden="true" focusable="false" class="octicon octicon-file color-fg-muted" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path></svg><div class="overflow-hidden"><div class="react-directory-filename-cell"><div class="react-directory-truncate"><a title="README.md" aria-label="README.md, (File)" class="Link--primary" href="/apple/ml-stable-diffusion/blob/main/README.md">README.md</a></div></div></div></div></td><td class="react-directory-row-name-cell-large-screen" colSpan="1"><div class="react-directory-filename-column"><svg aria-hidden="true" focusable="false" class="octicon octicon-file color-fg-muted" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path></svg><div class="overflow-hidden"><div class="react-directory-filename-cell"><div class="react-directory-truncate"><a title="README.md" aria-label="README.md, (File)" class="Link--primary" href="/apple/ml-stable-diffusion/blob/main/README.md">README.md</a></div></div></div></div></td><td class="react-directory-row-commit-cell"><div class="Skeleton Skeleton--text"> </div></td><td><div class="Skeleton Skeleton--text"> </div></td></tr><tr class="react-directory-row truncate-for-mobile" id="folder-row-12"><td class="react-directory-row-name-cell-small-screen" colSpan="2"><div class="react-directory-filename-column"><svg aria-hidden="true" focusable="false" class="octicon octicon-file color-fg-muted" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path></svg><div class="overflow-hidden"><div class="react-directory-filename-cell"><div class="react-directory-truncate"><a title="requirements.txt" aria-label="requirements.txt, (File)" class="Link--primary" href="/apple/ml-stable-diffusion/blob/main/requirements.txt">requirements.txt</a></div></div></div></div></td><td class="react-directory-row-name-cell-large-screen" colSpan="1"><div class="react-directory-filename-column"><svg aria-hidden="true" focusable="false" class="octicon octicon-file color-fg-muted" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path></svg><div class="overflow-hidden"><div class="react-directory-filename-cell"><div class="react-directory-truncate"><a title="requirements.txt" aria-label="requirements.txt, (File)" class="Link--primary" href="/apple/ml-stable-diffusion/blob/main/requirements.txt">requirements.txt</a></div></div></div></div></td><td class="react-directory-row-commit-cell"><div class="Skeleton Skeleton--text"> </div></td><td><div class="Skeleton Skeleton--text"> </div></td></tr><tr class="react-directory-row truncate-for-mobile" id="folder-row-13"><td class="react-directory-row-name-cell-small-screen" colSpan="2"><div class="react-directory-filename-column"><svg aria-hidden="true" focusable="false" class="octicon octicon-file color-fg-muted" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path></svg><div class="overflow-hidden"><div class="react-directory-filename-cell"><div class="react-directory-truncate"><a title="setup.py" aria-label="setup.py, (File)" class="Link--primary" href="/apple/ml-stable-diffusion/blob/main/setup.py">setup.py</a></div></div></div></div></td><td class="react-directory-row-name-cell-large-screen" colSpan="1"><div class="react-directory-filename-column"><svg aria-hidden="true" focusable="false" class="octicon octicon-file color-fg-muted" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path></svg><div class="overflow-hidden"><div class="react-directory-filename-cell"><div class="react-directory-truncate"><a title="setup.py" aria-label="setup.py, (File)" class="Link--primary" href="/apple/ml-stable-diffusion/blob/main/setup.py">setup.py</a></div></div></div></div></td><td class="react-directory-row-commit-cell"><div class="Skeleton Skeleton--text"> </div></td><td><div class="Skeleton Skeleton--text"> </div></td></tr><tr class="Box-sc-g0xbh4-0 eNCcrz show-for-mobile" data-testid="view-all-files-row"><td colSpan="3" class="Box-sc-g0xbh4-0 bHTcCe"><div><button class="prc-Link-Link-85e08">View all files</button></div></td></tr></tbody></table></div><div class="Box-sc-g0xbh4-0 csrIcr"><div class="Box-sc-g0xbh4-0 bUQNHB"><div itemscope="" itemType="https://schema.org/abstract" class="Box-sc-g0xbh4-0 jPdcfu"><h2 class="_VisuallyHidden__VisuallyHidden-sc-11jhm7a-0 brGdpi">Repository files navigation</h2><nav class="Box-sc-g0xbh4-0 iphEWz prc-components-UnderlineWrapper-oOh5J" aria-label="Repository files"><ul class="prc-components-UnderlineItemList-b23Hf" role="list"><li class="Box-sc-g0xbh4-0 hUCRAk"><a class="prc-components-UnderlineItem-lJsg-" href="#" aria-current="page"><span data-component="icon"><svg aria-hidden="true" focusable="false" class="octicon octicon-book" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M0 1.75A.75.75 0 0 1 .75 1h4.253c1.227 0 2.317.59 3 1.501A3.743 3.743 0 0 1 11.006 1h4.245a.75.75 0 0 1 .75.75v10.5a.75.75 0 0 1-.75.75h-4.507a2.25 2.25 0 0 0-1.591.659l-.622.621a.75.75 0 0 1-1.06 0l-.622-.621A2.25 2.25 0 0 0 5.258 13H.75a.75.75 0 0 1-.75-.75Zm7.251 10.324.004-5.073-.002-2.253A2.25 2.25 0 0 0 5.003 2.5H1.5v9h3.757a3.75 3.75 0 0 1 1.994.574ZM8.755 4.75l-.004 7.322a3.752 3.752 0 0 1 1.992-.572H14.5v-9h-3.495a2.25 2.25 0 0 0-2.25 2.25Z"></path></svg></span><span data-component="text" data-content="README">README</span></a></li><li class="Box-sc-g0xbh4-0 hUCRAk"><a class="prc-components-UnderlineItem-lJsg-" href="#"><span data-component="icon"><svg aria-hidden="true" focusable="false" class="octicon octicon-code-of-conduct" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M8.048 2.241c.964-.709 2.079-1.238 3.325-1.241a4.616 4.616 0 0 1 3.282 1.355c.41.408.757.86.996 1.428.238.568.348 1.206.347 1.968 0 2.193-1.505 4.254-3.081 5.862-1.496 1.526-3.213 2.796-4.249 3.563l-.22.163a.749.749 0 0 1-.895 0l-.221-.163c-1.036-.767-2.753-2.037-4.249-3.563C1.51 10.008.007 7.952.002 5.762a4.614 4.614 0 0 1 1.353-3.407C3.123.585 6.223.537 8.048 2.24Zm-1.153.983c-1.25-1.033-3.321-.967-4.48.191a3.115 3.115 0 0 0-.913 2.335c0 1.556 1.109 3.24 2.652 4.813C5.463 11.898 6.96 13.032 8 13.805c.353-.262.758-.565 1.191-.905l-1.326-1.223a.75.75 0 0 1 1.018-1.102l1.48 1.366c.328-.281.659-.577.984-.887L9.99 9.802a.75.75 0 1 1 1.019-1.103l1.384 1.28c.295-.329.566-.661.81-.995L12.92 8.7l-1.167-1.168c-.674-.671-1.78-.664-2.474.03-.268.269-.538.537-.802.797-.893.882-2.319.843-3.185-.032-.346-.35-.693-.697-1.043-1.047a.75.75 0 0 1-.04-1.016c.162-.191.336-.401.52-.623.62-.748 1.356-1.637 2.166-2.417Zm7.112 4.442c.313-.65.491-1.293.491-1.916v-.001c0-.614-.088-1.045-.23-1.385-.143-.339-.357-.633-.673-.949a3.111 3.111 0 0 0-2.218-.915c-1.092.003-2.165.627-3.226 1.602-.823.755-1.554 1.637-2.228 2.45l-.127.154.562.566a.755.755 0 0 0 1.066.02l.794-.79c1.258-1.258 3.312-1.31 4.594-.032.396.394.792.791 1.173 1.173Z"></path></svg></span><span data-component="text" data-content="Code of conduct">Code of conduct</span></a></li><li class="Box-sc-g0xbh4-0 hUCRAk"><a class="prc-components-UnderlineItem-lJsg-" href="#"><span data-component="icon"><svg aria-hidden="true" focusable="false" class="octicon octicon-law" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M8.75.75V2h.985c.304 0 .603.08.867.231l1.29.736c.038.022.08.033.124.033h2.234a.75.75 0 0 1 0 1.5h-.427l2.111 4.692a.75.75 0 0 1-.154.838l-.53-.53.529.531-.001.002-.002.002-.006.006-.006.005-.01.01-.045.04c-.21.176-.441.327-.686.45C14.556 10.78 13.88 11 13 11a4.498 4.498 0 0 1-2.023-.454 3.544 3.544 0 0 1-.686-.45l-.045-.04-.016-.015-.006-.006-.004-.004v-.001a.75.75 0 0 1-.154-.838L12.178 4.5h-.162c-.305 0-.604-.079-.868-.231l-1.29-.736a.245.245 0 0 0-.124-.033H8.75V13h2.5a.75.75 0 0 1 0 1.5h-6.5a.75.75 0 0 1 0-1.5h2.5V3.5h-.984a.245.245 0 0 0-.124.033l-1.289.737c-.265.15-.564.23-.869.23h-.162l2.112 4.692a.75.75 0 0 1-.154.838l-.53-.53.529.531-.001.002-.002.002-.006.006-.016.015-.045.04c-.21.176-.441.327-.686.45C4.556 10.78 3.88 11 3 11a4.498 4.498 0 0 1-2.023-.454 3.544 3.544 0 0 1-.686-.45l-.045-.04-.016-.015-.006-.006-.004-.004v-.001a.75.75 0 0 1-.154-.838L2.178 4.5H1.75a.75.75 0 0 1 0-1.5h2.234a.249.249 0 0 0 .125-.033l1.288-.737c.265-.15.564-.23.869-.23h.984V.75a.75.75 0 0 1 1.5 0Zm2.945 8.477c.285.135.718.273 1.305.273s1.02-.138 1.305-.273L13 6.327Zm-10 0c.285.135.718.273 1.305.273s1.02-.138 1.305-.273L3 6.327Z"></path></svg></span><span data-component="text" data-content="MIT license">MIT license</span></a></li></ul></nav><button style="--button-color:fg.subtle" type="button" aria-label="Outline" aria-haspopup="true" aria-expanded="false" tabindex="0" class="Box-sc-g0xbh4-0 cwoBXV prc-Button-ButtonBase-c50BI" data-loading="false" data-size="medium" data-variant="invisible" aria-describedby=":Rr9ab:-loading-announcement" id=":Rr9ab:"><svg aria-hidden="true" focusable="false" class="octicon octicon-list-unordered" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M5.75 2.5h8.5a.75.75 0 0 1 0 1.5h-8.5a.75.75 0 0 1 0-1.5Zm0 5h8.5a.75.75 0 0 1 0 1.5h-8.5a.75.75 0 0 1 0-1.5Zm0 5h8.5a.75.75 0 0 1 0 1.5h-8.5a.75.75 0 0 1 0-1.5ZM2 14a1 1 0 1 1 0-2 1 1 0 0 1 0 2Zm1-6a1 1 0 1 1-2 0 1 1 0 0 1 2 0ZM2 4a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"></path></svg></button></div><div class="Box-sc-g0xbh4-0 QkQOb js-snippet-clipboard-copy-unpositioned undefined" data-hpc="true"><article class="markdown-body entry-content container-lg" itemprop="text"><div class="markdown-heading" dir="auto"><h1 tabindex="-1" class="heading-element" dir="auto">Core ML Stable Diffusion</h1><a id="user-content-core-ml-stable-diffusion" class="anchor" aria-label="Permalink: Core ML Stable Diffusion" href="#core-ml-stable-diffusion"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">Run Stable Diffusion on Apple Silicon with Core ML</p> <p dir="auto"><a href="https://machinelearning.apple.com/research/stable-diffusion-coreml-apple-silicon" rel="nofollow">[Blog Post]</a> <a href="#bibtex">[BibTeX]</a></p> <p dir="auto">This repository comprises:</p> <ul dir="auto"> <li><code>python_coreml_stable_diffusion</code>, a Python package for converting PyTorch models to Core ML format and performing image generation with Hugging Face <a href="https://github.com/huggingface/diffusers">diffusers</a> in Python</li> <li><code>StableDiffusion</code>, a Swift package that developers can add to their Xcode projects as a dependency to deploy image generation capabilities in their apps. The Swift package relies on the Core ML model files generated by <code>python_coreml_stable_diffusion</code></li> </ul> <p dir="auto">If you run into issues during installation or runtime, please refer to the <a href="#faq">FAQ</a> section. Please refer to the <a href="#system-requirements">System Requirements</a> section before getting started.</p> <p dir="auto"><a target="_blank" rel="noopener noreferrer" href="/apple/ml-stable-diffusion/blob/main/assets/readme_reel.png"><img src="/apple/ml-stable-diffusion/raw/main/assets/readme_reel.png" style="max-width: 100%;"></a></p> <div class="markdown-heading" dir="auto"><h2 tabindex="-1" class="heading-element" dir="auto"><a name="user-content-system-requirements"></a> System Requirements</h2><a id="user-content--system-requirements" class="anchor" aria-label="Permalink: System Requirements" href="#-system-requirements"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <details> <summary> Details (Click to expand) </summary> <p dir="auto">Model Conversion:</p> <markdown-accessiblity-table><table> <thead> <tr> <th align="center">macOS</th> <th align="center">Python</th> <th align="center">coremltools</th> </tr> </thead> <tbody> <tr> <td align="center">13.1</td> <td align="center">3.8</td> <td align="center">7.0</td> </tr> </tbody> </table></markdown-accessiblity-table> <p dir="auto">Project Build:</p> <markdown-accessiblity-table><table> <thead> <tr> <th align="center">macOS</th> <th align="center">Xcode</th> <th align="center">Swift</th> </tr> </thead> <tbody> <tr> <td align="center">13.1</td> <td align="center">14.3</td> <td align="center">5.8</td> </tr> </tbody> </table></markdown-accessiblity-table> <p dir="auto">Target Device Runtime:</p> <markdown-accessiblity-table><table> <thead> <tr> <th align="center">macOS</th> <th align="center">iPadOS, iOS</th> </tr> </thead> <tbody> <tr> <td align="center">13.1</td> <td align="center">16.2</td> </tr> </tbody> </table></markdown-accessiblity-table> <p dir="auto">Target Device Runtime (<a href="#compression-6-bits-and-higher">With Memory Improvements</a>):</p> <markdown-accessiblity-table><table> <thead> <tr> <th align="center">macOS</th> <th align="center">iPadOS, iOS</th> </tr> </thead> <tbody> <tr> <td align="center">14.0</td> <td align="center">17.0</td> </tr> </tbody> </table></markdown-accessiblity-table> <p dir="auto">Target Device Hardware Generation:</p> <markdown-accessiblity-table><table> <thead> <tr> <th align="center">Mac</th> <th align="center">iPad</th> <th align="center">iPhone</th> </tr> </thead> <tbody> <tr> <td align="center">M1</td> <td align="center">M1</td> <td align="center">A14</td> </tr> </tbody> </table></markdown-accessiblity-table> </details> <div class="markdown-heading" dir="auto"><h2 tabindex="-1" class="heading-element" dir="auto"><a name="user-content-performance-benchmark"></a> Performance Benchmarks</h2><a id="user-content--performance-benchmarks" class="anchor" aria-label="Permalink: Performance Benchmarks" href="#-performance-benchmarks"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <details> <summary> Details (Click to expand) </summary> <p dir="auto"><a href="https://huggingface.co/apple/coreml-stable-diffusion-2-1-base" rel="nofollow"><code>stabilityai/stable-diffusion-2-1-base</code></a> (512x512)</p> <markdown-accessiblity-table><table> <thead> <tr> <th>Device</th> <th><code>--compute-unit</code></th> <th><code>--attention-implementation</code></th> <th>End-to-End Latency (s)</th> <th>Diffusion Speed (iter/s)</th> </tr> </thead> <tbody> <tr> <td>iPhone 12 Mini</td> <td><code>CPU_AND_NE</code></td> <td><code>SPLIT_EINSUM_V2</code></td> <td>18.5*</td> <td>1.44</td> </tr> <tr> <td>iPhone 12 Pro Max</td> <td><code>CPU_AND_NE</code></td> <td><code>SPLIT_EINSUM_V2</code></td> <td>15.4</td> <td>1.45</td> </tr> <tr> <td>iPhone 13</td> <td><code>CPU_AND_NE</code></td> <td><code>SPLIT_EINSUM_V2</code></td> <td>10.8*</td> <td>2.53</td> </tr> <tr> <td>iPhone 13 Pro Max</td> <td><code>CPU_AND_NE</code></td> <td><code>SPLIT_EINSUM_V2</code></td> <td>10.4</td> <td>2.55</td> </tr> <tr> <td>iPhone 14</td> <td><code>CPU_AND_NE</code></td> <td><code>SPLIT_EINSUM_V2</code></td> <td>8.6</td> <td>2.57</td> </tr> <tr> <td>iPhone 14 Pro Max</td> <td><code>CPU_AND_NE</code></td> <td><code>SPLIT_EINSUM_V2</code></td> <td>7.9</td> <td>2.69</td> </tr> <tr> <td>iPad Pro (M1)</td> <td><code>CPU_AND_NE</code></td> <td><code>SPLIT_EINSUM_V2</code></td> <td>11.2</td> <td>2.19</td> </tr> <tr> <td>iPad Pro (M2)</td> <td><code>CPU_AND_NE</code></td> <td><code>SPLIT_EINSUM_V2</code></td> <td>7.0</td> <td>3.07</td> </tr> </tbody> </table></markdown-accessiblity-table> <details> <summary> Details (Click to expand) </summary> <ul dir="auto"> <li>This benchmark was conducted by Apple and Hugging Face using public beta versions of iOS 17.0, iPadOS 17.0 and macOS 14.0 Seed 8 in August 2023.</li> <li>The performance data was collected using the <code>benchmark</code> branch of the <a href="https://github.com/huggingface/swift-coreml-diffusers">Diffusers app</a></li> <li>Swift code is not fully optimized, introducing up to ~10% overhead unrelated to Core ML model execution.</li> <li>The median latency value across 5 back-to-back end-to-end executions are reported</li> <li>The image generation procedure follows the standard configuration: 20 inference steps, 512x512 output image resolution, 77 text token sequence length, classifier-free guidance (batch size of 2 for unet).</li> <li>The actual prompt length does not impact performance because the Core ML model is converted with a static shape that computes the forward pass for all of the 77 elements (<code>tokenizer.model_max_length</code>) in the text token sequence regardless of the actual length of the input text.</li> <li>Weights are compressed to 6 bit precision. Please refer to <a href="#compression-6-bits-and-higher">this section</a> for details.</li> <li>Activations are in float16 precision for both the GPU and the Neural Engine.</li> <li><code>*</code> indicates that the <a href="https://github.com/apple/ml-stable-diffusion/blob/main/swift/StableDiffusion/pipeline/StableDiffusionPipeline.swift#L91">reduceMemory</a> option was enabled which loads and unloads models just-in-time to avoid memory shortage. This added up to 2 seconds to the end-to-end latency.</li> <li>In the benchmark table, we report the best performing <code>--compute-unit</code> and <code>--attention-implementation</code> values per device. The former does not modify the Core ML model and can be applied during runtime. The latter modifies the Core ML model. Note that the best performing compute unit is model version and hardware-specific.</li> <li>Note that the performance optimizations in this repository (e.g. <code>--attention-implementation</code>) are generally applicable to Transformers and not customized to Stable Diffusion. Better performance may be observed upon custom kernel tuning. Therefore, these numbers do not represent <strong>peak</strong> HW capability.</li> <li>Performance may vary across different versions of Stable Diffusion due to architecture changes in the model itself. Each reported number is specific to the model version mentioned in that context.</li> <li>Performance may vary due to factors like increased system load from other applications or suboptimal device thermal state.</li> </ul> </details> <p dir="auto"><a href="https://huggingface.co/apple/coreml-stable-diffusion-xl-base-ios" rel="nofollow"><code>stabilityai/stable-diffusion-xl-base-1.0-ios</code></a> (768x768)</p> <markdown-accessiblity-table><table> <thead> <tr> <th>Device</th> <th><code>--compute-unit</code></th> <th><code>--attention-implementation</code></th> <th>End-to-End Latency (s)</th> <th>Diffusion Speed (iter/s)</th> </tr> </thead> <tbody> <tr> <td>iPhone 12 Pro</td> <td><code>CPU_AND_NE</code></td> <td><code>SPLIT_EINSUM</code></td> <td>116*</td> <td>0.50</td> </tr> <tr> <td>iPhone 13 Pro Max</td> <td><code>CPU_AND_NE</code></td> <td><code>SPLIT_EINSUM</code></td> <td>86*</td> <td>0.68</td> </tr> <tr> <td>iPhone 14 Pro Max</td> <td><code>CPU_AND_NE</code></td> <td><code>SPLIT_EINSUM</code></td> <td>77*</td> <td>0.83</td> </tr> <tr> <td>iPhone 15 Pro Max</td> <td><code>CPU_AND_NE</code></td> <td><code>SPLIT_EINSUM</code></td> <td>31</td> <td>0.85</td> </tr> <tr> <td>iPad Pro (M1)</td> <td><code>CPU_AND_NE</code></td> <td><code>SPLIT_EINSUM</code></td> <td>36</td> <td>0.69</td> </tr> <tr> <td>iPad Pro (M2)</td> <td><code>CPU_AND_NE</code></td> <td><code>SPLIT_EINSUM</code></td> <td>27</td> <td>0.98</td> </tr> </tbody> </table></markdown-accessiblity-table> <details> <summary> Details (Click to expand) </summary> <ul dir="auto"> <li>This benchmark was conducted by Apple and Hugging Face using iOS 17.0.2 and iPadOS 17.0.2 in September 2023.</li> <li>The performance data was collected using the <code>benchmark</code> branch of the <a href="https://github.com/huggingface/swift-coreml-diffusers">Diffusers app</a></li> <li>The median latency value across 5 back-to-back end-to-end executions are reported</li> <li>The image generation procedure follows this configuration: 20 inference steps, 768x768 output image resolution, 77 text token sequence length, classifier-free guidance (batch size of 2 for unet).</li> <li><code>Unet.mlmodelc</code> is compressed to 4.04 bit precision following the <a href="#compression-lower-than-6-bits">Mixed-Bit Palettization</a> algorithm recipe published <a href="https://huggingface.co/apple/coreml-stable-diffusion-mixed-bit-palettization/blob/main/recipes/stabilityai-stable-diffusion-xl-base-1.0_palettization_recipe.json" rel="nofollow">here</a></li> <li>All models except for <code>Unet.mlmodelc</code> are compressed to 16 bit precision</li> <li><a href="https://huggingface.co/madebyollin/sdxl-vae-fp16-fix" rel="nofollow">madebyollin/sdxl-vae-fp16-fix</a> by <a href="https://github.com/madebyollin">@madebyollin</a> was used as the source PyTorch model for <code>VAEDecoder.mlmodelc</code> in order to enable float16 weight and activation quantization for the VAE model.</li> <li><code>--attention-implementation SPLIT_EINSUM</code> is chosen in lieu of <code>SPLIT_EINSUM_V2</code> due to the prohibitively long compilation time of the latter</li> <li><code>*</code> indicates that the <a href="https://github.com/apple/ml-stable-diffusion/blob/main/swift/StableDiffusion/pipeline/StableDiffusionPipeline.swift#L91">reduceMemory</a> option was enabled which loads and unloads models just-in-time to avoid memory shortage. This added significant overhead to the end-to-end latency. Note that end-to-end latency difference between <code>iPad Pro (M1)</code> and <code>iPhone 13 Pro Max</code> despite identical diffusion speed.</li> <li>The actual prompt length does not impact performance because the Core ML model is converted with a static shape that computes the forward pass for all of the 77 elements (<code>tokenizer.model_max_length</code>) in the text token sequence regardless of the actual length of the input text.</li> <li>In the benchmark table, we report the best performing <code>--compute-unit</code> and <code>--attention-implementation</code> values per device. The former does not modify the Core ML model and can be applied during runtime. The latter modifies the Core ML model. Note that the best performing compute unit is model version and hardware-specific.</li> <li>Note that the performance optimizations in this repository (e.g. <code>--attention-implementation</code>) are generally applicable to Transformers and not customized to Stable Diffusion. Better performance may be observed upon custom kernel tuning. Therefore, these numbers do not represent <strong>peak</strong> HW capability.</li> <li>Performance may vary across different versions of Stable Diffusion due to architecture changes in the model itself. Each reported number is specific to the model version mentioned in that context.</li> <li>Performance may vary due to factors like increased system load from other applications or suboptimal device thermal state.</li> </ul> </details> <p dir="auto"><a href="https://huggingface.co/apple/coreml-stable-diffusion-xl-base" rel="nofollow"><code>stabilityai/stable-diffusion-xl-base-1.0</code></a> (1024x1024)</p> <markdown-accessiblity-table><table> <thead> <tr> <th>Device</th> <th><code>--compute-unit</code></th> <th><code>--attention-implementation</code></th> <th>End-to-End Latency (s)</th> <th>Diffusion Speed (iter/s)</th> </tr> </thead> <tbody> <tr> <td>MacBook Pro (M1 Max)</td> <td><code>CPU_AND_GPU</code></td> <td><code>ORIGINAL</code></td> <td>46</td> <td>0.46</td> </tr> <tr> <td>MacBook Pro (M2 Max)</td> <td><code>CPU_AND_GPU</code></td> <td><code>ORIGINAL</code></td> <td>37</td> <td>0.57</td> </tr> <tr> <td>Mac Studio (M1 Ultra)</td> <td><code>CPU_AND_GPU</code></td> <td><code>ORIGINAL</code></td> <td>25</td> <td>0.89</td> </tr> <tr> <td>Mac Studio (M2 Ultra)</td> <td><code>CPU_AND_GPU</code></td> <td><code>ORIGINAL</code></td> <td>20</td> <td>1.11</td> </tr> </tbody> </table></markdown-accessiblity-table> <details> <summary> Details (Click to expand) </summary> <ul dir="auto"> <li>This benchmark was conducted by Apple and Hugging Face using public beta versions of iOS 17.0, iPadOS 17.0 and macOS 14.0 in July 2023.</li> <li>The performance data was collected by running the <code>StableDiffusion</code> Swift pipeline.</li> <li>The median latency value across 3 back-to-back end-to-end executions are reported</li> <li>The image generation procedure follows the standard configuration: 20 inference steps, 1024x1024 output image resolution, classifier-free guidance (batch size of 2 for unet).</li> <li>Weights and activations are in float16 precision</li> <li>Performance may vary across different versions of Stable Diffusion due to architecture changes in the model itself. Each reported number is specific to the model version mentioned in that context.</li> <li>Performance may vary due to factors like increased system load from other applications or suboptimal device thermal state. Given these factors, we do not report sub-second variance in latency.</li> </ul> </details> </details> <div class="markdown-heading" dir="auto"><h2 tabindex="-1" class="heading-element" dir="auto"><a name="user-content-compression-6-bits-and-higher"></a> Weight Compression (6-bits and higher)</h2><a id="user-content--weight-compression-6-bits-and-higher" class="anchor" aria-label="Permalink: Weight Compression (6-bits and higher)" href="#-weight-compression-6-bits-and-higher"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <details> <summary> Details (Click to expand) </summary> <p dir="auto">coremltools-7.0 supports advanced weight compression techniques for <a href="https://coremltools.readme.io/v7.0/docs/pruning" rel="nofollow">pruning</a>, <a href="https://coremltools.readme.io/v7.0/docs/palettization-overview" rel="nofollow">palettization</a> and <a href="https://coremltools.readme.io/v7.0/docs/quantization-aware-training" rel="nofollow">linear 8-bit quantization</a>. For these techniques, <code>coremltools.optimize.torch.*</code> includes APIs that require fine-tuning to maintain accuracy at higher compression rates whereas <code>coremltools.optimize.coreml.*</code> includes APIs that are applied post-training and are data-free.</p> <p dir="auto">We demonstrate how data-free <a href="https://coremltools.readme.io/v7.0/docs/post-training-palettization" rel="nofollow">post-training palettization</a> implemented in <code>coremltools.optimize.coreml.palettize_weights</code> enables us to achieve greatly improved performance for Stable Diffusion on mobile devices. This API implements the <a href="https://arxiv.org/abs/1701.07204" rel="nofollow">Fast Exact k-Means</a> algorithm for optimal weight clustering which yields more accurate palettes. Using <code>--quantize-nbits {2,4,6,8}</code> during <a href="#converting-models-to-coreml">conversion</a> is going to apply this compression to the unet and text_encoder models.</p> <p dir="auto">For best results, we recommend <a href="https://coremltools.readme.io/v7.0/docs/training-time-palettization" rel="nofollow">training-time palettization</a>: <code>coremltools.optimize.torch.palettization.DKMPalettizer</code> if fine-tuning your model is feasible. This API implements the <a href="https://machinelearning.apple.com/research/differentiable-k-means" rel="nofollow">Differentiable k-Means (DKM)</a> learned palettization algorithm. In this exercise, we stick to post-training palettization for the sake of simplicity and ease of reproducibility.</p> <p dir="auto">The Neural Engine is capable of accelerating models with low-bit palettization: 1, 2, 4, 6 or 8 bits. With iOS 17 and macOS 14, compressed weights for Core ML models can be just-in-time decompressed during runtime (as opposed to ahead-of-time decompression upon load) to match the precision of activation tensors. This yields significant memory savings and enables models to run on devices with smaller RAM (e.g. iPhone 12 Mini). In addition, compressed weights are faster to fetch from memory which reduces the latency of memory bandwidth-bound layers. The just-in-time decompression behavior depends on the compute unit, layer type and hardware generation.</p> <markdown-accessiblity-table><table> <thead> <tr> <th align="center">Weight Precision</th> <th align="center"><code>--compute-unit</code></th> <th><a href="https://huggingface.co/apple/coreml-stable-diffusion-2-1-base" rel="nofollow"><code>stabilityai/stable-diffusion-2-1-base</code></a> generating <em>"a high quality photo of a surfing dog"</em></th> </tr> </thead> <tbody> <tr> <td align="center">6-bit</td> <td align="center">cpuAndNeuralEngine</td> <td><a target="_blank" rel="noopener noreferrer" href="/apple/ml-stable-diffusion/blob/main/assets/palette6_cpuandne_readmereel.png"><img src="/apple/ml-stable-diffusion/raw/main/assets/palette6_cpuandne_readmereel.png" style="max-width: 100%;"></a></td> </tr> <tr> <td align="center">16-bit</td> <td align="center">cpuAndNeuralEngine</td> <td><a target="_blank" rel="noopener noreferrer" href="/apple/ml-stable-diffusion/blob/main/assets/float16_cpuandne_readmereel.png"><img src="/apple/ml-stable-diffusion/raw/main/assets/float16_cpuandne_readmereel.png" style="max-width: 100%;"></a></td> </tr> <tr> <td align="center">16-bit</td> <td align="center">cpuAndGPU</td> <td><a target="_blank" rel="noopener noreferrer" href="/apple/ml-stable-diffusion/blob/main/assets/float16_gpu_readmereel.png"><img src="/apple/ml-stable-diffusion/raw/main/assets/float16_gpu_readmereel.png" style="max-width: 100%;"></a></td> </tr> </tbody> </table></markdown-accessiblity-table> <p dir="auto">Note that there are minor differences across 16-bit (float16) and 6-bit results. These differences are comparable to the differences across float16 and float32 or differences across compute units as exemplified above. We recommend a minimum of 6 bits for palettizing Stable Diffusion. Smaller number of bits (1, 2 and 4) will require either fine-tuning or advanced palettization techniques such as <a href="#compression-lower-than-6-bits">MBP</a>.</p> <p dir="auto">Resources:</p> <ul dir="auto"> <li><a href="https://coremltools.readme.io/v7.0/docs/optimizing-models" rel="nofollow">Core ML Tools Docs: Optimizing Models</a></li> <li><a href="https://developer.apple.com/videos/play/wwdc2023/10047" rel="nofollow">WWDC23 Session Video: Use Core ML Tools for machine learning model compression</a></li> </ul> </details> <div class="markdown-heading" dir="auto"><h2 tabindex="-1" class="heading-element" dir="auto"><a name="user-content-compression-lower-than-6-bits"></a> Advanced Weight Compression (Lower than 6-bits)</h2><a id="user-content--advanced-weight-compression-lower-than-6-bits" class="anchor" aria-label="Permalink: Advanced Weight Compression (Lower than 6-bits)" href="#-advanced-weight-compression-lower-than-6-bits"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <details> <summary> Details (Click to expand) </summary> <p dir="auto">This section describes an advanced compression algorithm called <a href="https://huggingface.co/blog/stable-diffusion-xl-coreml#what-is-mixed-bit-palettization" rel="nofollow">Mixed-Bit Palettization (MBP)</a> built on top of the <a href="https://apple.github.io/coremltools/docs-guides/source/post-training-palettization.html" rel="nofollow">Post-Training Weight Palettization tools</a> and using the <a href="https://apple.github.io/coremltools/docs-guides/source/mlmodel-utilities.html#get-weights-metadata" rel="nofollow">Weights Metadata API</a> from <a href="https://github.com/apple/coremltools">coremltools</a>.</p> <p dir="auto">MBP builds a per-layer "palettization recipe" by picking a suitable number of bits among the Neural Engine supported bit-widths of 1, 2, 4, 6 and 8 in order to achieve the minimum average bit-width while maintaining a desired level of signal strength. The signal strength is measured by comparing the compressed model's output to that of the original float16 model. Given the same random seed and text prompts, PSNR between denoised latents is computed. The compression rate will depend on the model version as well as the tolerance for signal loss (drop in PSNR) since this algorithm is adaptive.</p> <markdown-accessiblity-table><table> <thead> <tr> <th align="center">3.41-bit</th> <th align="center">4.50-bit</th> <th align="center">6.55-bit</th> <th align="center">16-bit (original)</th> </tr> </thead> <tbody> <tr> <td align="center"><a target="_blank" rel="noopener noreferrer" href="/apple/ml-stable-diffusion/blob/main/assets/mbp/a_high_quality_photo_of_a_surfing_dog.7667.final_3.41-bits.png"><img src="/apple/ml-stable-diffusion/raw/main/assets/mbp/a_high_quality_photo_of_a_surfing_dog.7667.final_3.41-bits.png" style="max-width: 100%;"></a></td> <td align="center"><a target="_blank" rel="noopener noreferrer" href="/apple/ml-stable-diffusion/blob/main/assets/mbp/a_high_quality_photo_of_a_surfing_dog.7667.final_4.50-bits.png"><img src="/apple/ml-stable-diffusion/raw/main/assets/mbp/a_high_quality_photo_of_a_surfing_dog.7667.final_4.50-bits.png" style="max-width: 100%;"></a></td> <td align="center"><a target="_blank" rel="noopener noreferrer" href="/apple/ml-stable-diffusion/blob/main/assets/mbp/a_high_quality_photo_of_a_surfing_dog.7667.final_6.55-bits.png"><img src="/apple/ml-stable-diffusion/raw/main/assets/mbp/a_high_quality_photo_of_a_surfing_dog.7667.final_6.55-bits.png" style="max-width: 100%;"></a></td> <td align="center"><a target="_blank" rel="noopener noreferrer" href="/apple/ml-stable-diffusion/blob/main/assets/mbp/a_high_quality_photo_of_a_surfing_dog.7667.final_float16_original.png"><img src="/apple/ml-stable-diffusion/raw/main/assets/mbp/a_high_quality_photo_of_a_surfing_dog.7667.final_float16_original.png" style="max-width: 100%;"></a></td> </tr> </tbody> </table></markdown-accessiblity-table> <p dir="auto">For example, the original float16 <a href="https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0" rel="nofollow">stabilityai/stable-diffusion-xl-base-1.0</a> model has an ~82 dB signal strength. Naively applying <a href="https://coremltools.readme.io/docs/data-free-quantization" rel="nofollow">linear 8-bit quantization</a> to the Unet model drops the signal to ~65 dB. Instead, applying MBP yields an average of 2.81-bits quantization while maintaining a signal strength of ~67 dB. This technique generally yields better results compared to using <code>--quantize-nbits</code> during model conversion but requires a "pre-analysis" run that takes up to a few hours on a single GPU (<code>mps</code> or <code>cuda</code>).</p> <p dir="auto">Here is the signal strength (PSNR in dB) versus model size reduction (% of float16 size) for <code>stabilityai/stable-diffusion-xl-base-1.0</code>. The <code>{1,2,4,6,8}-bit</code> curves are generated by progressively palettizing more layers using a palette with fixed number of bits. The layers were ordered in ascending order of their isolated impact to end-to-end signal strength so the cumulative compression's impact is delayed as much as possible. The mixed-bit curve is based on falling back to a higher number of bits as soon as a layer's isolated impact to end-to-end signal integrity drops below a threshold. Note that all curves based on palettization outperform linear 8-bit quantization at the same model size except for 1-bit.</p> <a target="_blank" rel="noopener noreferrer" href="/apple/ml-stable-diffusion/blob/main/assets/mbp/stabilityai_stable-diffusion-xl-base-1.0_psnr_vs_size.png"><img src="/apple/ml-stable-diffusion/raw/main/assets/mbp/stabilityai_stable-diffusion-xl-base-1.0_psnr_vs_size.png" width="640" style="max-width: 100%;"></a> <p dir="auto">Here are the steps for applying this technique on another model version:</p> <p dir="auto"><strong>Step 1:</strong> Run the pre-analysis script to generate "recipes" with varying signal strength:</p> <div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="python -m python_coreml_stable_diffusion.mixed_bit_compression_pre_analysis --model-version &lt;model-version&gt; -o &lt;output-dir&gt;"><pre><span class="pl-s1">python</span> <span class="pl-c1">-</span><span class="pl-s1">m</span> <span class="pl-s1">python_coreml_stable_diffusion</span>.<span class="pl-c1">mixed_bit_compression_pre_analysis</span> <span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-s1">model</span><span class="pl-c1">-</span><span class="pl-s1">version</span> <span class="pl-c1">&lt;</span><span class="pl-s1">model</span><span class="pl-c1">-</span><span class="pl-s1">version</span><span class="pl-c1">&gt;</span> <span class="pl-c1">-</span><span class="pl-s1">o</span> <span class="pl-c1">&lt;</span><span class="pl-s1">output</span><span class="pl-c1">-</span><span class="pl-s1">dir</span><span class="pl-c1">&gt;</span></pre></div> <p dir="auto">For popular base models, you may find the pre-computed pre-analysis results <a href="https://huggingface.co/apple/coreml-stable-diffusion-mixed-bit-palettization/tree/main/recipes" rel="nofollow">here</a>. Fine-tuned models models are likely to honor the recipes of their corresponding base models but this is untested.</p> <p dir="auto"><strong>Step 2:</strong> The resulting JSON file from Step 1 will list "baselines", e.g.:</p> <div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{ &quot;model_version&quot;: &quot;stabilityai/stable-diffusion-xl-base-1.0&quot;, &quot;baselines&quot;: { &quot;original&quot;: 82.2, &quot;linear_8bit&quot;: 66.025, &quot;recipe_6.55_bit_mixedpalette&quot;: 79.9, &quot;recipe_5.52_bit_mixedpalette&quot;: 78.2, &quot;recipe_4.89_bit_mixedpalette&quot;: 76.8, &quot;recipe_4.41_bit_mixedpalette&quot;: 75.5, &quot;recipe_4.04_bit_mixedpalette&quot;: 73.2, &quot;recipe_3.67_bit_mixedpalette&quot;: 72.2, &quot;recipe_3.32_bit_mixedpalette&quot;: 71.4, &quot;recipe_3.19_bit_mixedpalette&quot;: 70.4, &quot;recipe_3.08_bit_mixedpalette&quot;: 69.6, &quot;recipe_2.98_bit_mixedpalette&quot;: 68.6, &quot;recipe_2.90_bit_mixedpalette&quot;: 67.8, &quot;recipe_2.83_bit_mixedpalette&quot;: 67.0, &quot;recipe_2.71_bit_mixedpalette&quot;: 66.3 }, }"><pre>{ <span class="pl-ent">"model_version"</span>: <span class="pl-s"><span class="pl-pds">"</span>stabilityai/stable-diffusion-xl-base-1.0<span class="pl-pds">"</span></span>, <span class="pl-ent">"baselines"</span>: { <span class="pl-ent">"original"</span>: <span class="pl-c1">82.2</span>, <span class="pl-ent">"linear_8bit"</span>: <span class="pl-c1">66.025</span>, <span class="pl-ent">"recipe_6.55_bit_mixedpalette"</span>: <span class="pl-c1">79.9</span>, <span class="pl-ent">"recipe_5.52_bit_mixedpalette"</span>: <span class="pl-c1">78.2</span>, <span class="pl-ent">"recipe_4.89_bit_mixedpalette"</span>: <span class="pl-c1">76.8</span>, <span class="pl-ent">"recipe_4.41_bit_mixedpalette"</span>: <span class="pl-c1">75.5</span>, <span class="pl-ent">"recipe_4.04_bit_mixedpalette"</span>: <span class="pl-c1">73.2</span>, <span class="pl-ent">"recipe_3.67_bit_mixedpalette"</span>: <span class="pl-c1">72.2</span>, <span class="pl-ent">"recipe_3.32_bit_mixedpalette"</span>: <span class="pl-c1">71.4</span>, <span class="pl-ent">"recipe_3.19_bit_mixedpalette"</span>: <span class="pl-c1">70.4</span>, <span class="pl-ent">"recipe_3.08_bit_mixedpalette"</span>: <span class="pl-c1">69.6</span>, <span class="pl-ent">"recipe_2.98_bit_mixedpalette"</span>: <span class="pl-c1">68.6</span>, <span class="pl-ent">"recipe_2.90_bit_mixedpalette"</span>: <span class="pl-c1">67.8</span>, <span class="pl-ent">"recipe_2.83_bit_mixedpalette"</span>: <span class="pl-c1">67.0</span>, <span class="pl-ent">"recipe_2.71_bit_mixedpalette"</span>: <span class="pl-c1">66.3</span> }, }</pre></div> <p dir="auto">Among these baselines, select a recipe based on your desired signal strength. We recommend palettizing to ~4 bits depending on the use case even if the signal integrity for lower bit values are higher than the linear 8-bit quantization baseline.</p> <p dir="auto">Finally, apply the selected recipe to the float16 Core ML model as follows:</p> <div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="python -m python_coreml_stable_diffusion.mixed_bit_compression_apply --mlpackage-path &lt;path-to-float16-unet-mlpackage&gt; -o &lt;output-dir&gt; --pre-analysis-json-path &lt;path-to--pre-analysis-json&gt; --selected-recipe &lt;selected-recipe-string-key&gt;"><pre><span class="pl-s1">python</span> <span class="pl-c1">-</span><span class="pl-s1">m</span> <span class="pl-s1">python_coreml_stable_diffusion</span>.<span class="pl-c1">mixed_bit_compression_apply</span> <span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-s1">mlpackage</span><span class="pl-c1">-</span><span class="pl-s1">path</span> <span class="pl-c1">&lt;</span><span class="pl-s1">path</span><span class="pl-c1">-</span><span class="pl-s1">to</span><span class="pl-c1">-</span><span class="pl-s1">float16</span><span class="pl-c1">-</span><span class="pl-s1">unet</span><span class="pl-c1">-</span><span class="pl-s1">mlpackage</span><span class="pl-c1">&gt;</span> <span class="pl-c1">-</span><span class="pl-s1">o</span> <span class="pl-c1">&lt;</span><span class="pl-s1">output</span><span class="pl-c1">-</span><span class="pl-s1">dir</span><span class="pl-c1">&gt;</span> <span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-s1">pre</span><span class="pl-c1">-</span><span class="pl-s1">analysis</span><span class="pl-c1">-</span><span class="pl-s1">json</span><span class="pl-c1">-</span><span class="pl-s1">path</span> <span class="pl-c1">&lt;</span><span class="pl-s1">path</span><span class="pl-c1">-</span><span class="pl-s1">to</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-s1">pre</span><span class="pl-c1">-</span><span class="pl-s1">analysis</span><span class="pl-c1">-</span><span class="pl-s1">json</span><span class="pl-c1">&gt;</span> <span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-s1">selected</span><span class="pl-c1">-</span><span class="pl-s1">recipe</span> <span class="pl-c1">&lt;</span><span class="pl-s1">selected</span><span class="pl-c1">-</span><span class="pl-s1">recipe</span><span class="pl-c1">-</span><span class="pl-s1">string</span><span class="pl-c1">-</span><span class="pl-s1">key</span><span class="pl-c1">&gt;</span></pre></div> <p dir="auto">An example <code>&lt;selected-recipe-string-key&gt;</code> would be <code>"recipe_4.50_bit_mixedpalette"</code> which achieves an average of 4.50-bits compression (compressed from ~5.2GB to ~1.46GB for SDXL). Please note that signal strength does not directly map to image-text alignment. Always verify that your MBP-compressed model variant is accurately generating images for your test prompts.</p> </details> <div class="markdown-heading" dir="auto"><h2 tabindex="-1" class="heading-element" dir="auto"><a name="user-content-activation-quant"></a> Activation Quantization</h2><a id="user-content--activation-quantization" class="anchor" aria-label="Permalink: Activation Quantization" href="#-activation-quantization"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <details> <summary> Details (Click to expand) </summary> <p dir="auto">On newer hardware with A17 Pro or M4 chips, such as the iPhone 15 Pro, quantizing both activations and weight to int8 can leverage optimized compute on the Neural Engine which can be used to improve runtime latency in compute-bound models.</p> <p dir="auto">In this section, we demonstrate how to apply <a href="https://apple.github.io/coremltools/docs-guides/source/opt-quantization-algos.html#post-training-data-calibration-activation-quantization" rel="nofollow">Post Training Activation Quantization</a>, using calibration data, on Stable Diffusion UNet model.</p> <p dir="auto">Similar to Mixed-Bit Palettization (MBP) described <a href="#a-namecompression-lower-than-6-bitsa-advanced-weight-compression-lower-than-6-bits">above</a>, first, a per-layer analysis is run to determine which intermediate activations are more sensitive to 8-bit compression. Less sensitive layers are weight and activation quantized (W8A8), whereas more sensitive layers are only weight quantized (W8A16).</p> <p dir="auto">Here are the steps for applying this technique:</p> <p dir="auto"><strong>Step 1:</strong> Generate calibration data</p> <div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="python -m python_coreml_stable_diffusion.activation_quantization --model-version &lt;model-version&gt; --generate-calibration-data -o &lt;output-dir&gt;"><pre><span class="pl-s1">python</span> <span class="pl-c1">-</span><span class="pl-s1">m</span> <span class="pl-s1">python_coreml_stable_diffusion</span>.<span class="pl-c1">activation_quantization</span> <span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-s1">model</span><span class="pl-c1">-</span><span class="pl-s1">version</span> <span class="pl-c1">&lt;</span><span class="pl-s1">model</span><span class="pl-c1">-</span><span class="pl-s1">version</span><span class="pl-c1">&gt;</span> <span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-s1">generate</span><span class="pl-c1">-</span><span class="pl-s1">calibration</span><span class="pl-c1">-</span><span class="pl-s1">data</span> <span class="pl-c1">-</span><span class="pl-s1">o</span> <span class="pl-c1">&lt;</span><span class="pl-s1">output</span><span class="pl-c1">-</span><span class="pl-s1">dir</span><span class="pl-c1">&gt;</span></pre></div> <p dir="auto">A set of calibration text prompts are run through StableDiffusionPipeline and UNet model inputs are recorded and stored as pickle files in <code>calibration_data_&lt;model-version&gt;</code> folder inside specified output directory.</p> <p dir="auto"><strong>Step 2:</strong> Run layer-wise sensitivity analysis</p> <div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="python -m python_coreml_stable_diffusion.activation_quantization --model-version &lt;model-version&gt; --layerwise-sensitivity --calibration-nsamples &lt;num-samples&gt; -o &lt;output-dir&gt;"><pre><span class="pl-s1">python</span> <span class="pl-c1">-</span><span class="pl-s1">m</span> <span class="pl-s1">python_coreml_stable_diffusion</span>.<span class="pl-c1">activation_quantization</span> <span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-s1">model</span><span class="pl-c1">-</span><span class="pl-s1">version</span> <span class="pl-c1">&lt;</span><span class="pl-s1">model</span><span class="pl-c1">-</span><span class="pl-s1">version</span><span class="pl-c1">&gt;</span> <span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-s1">layerwise</span><span class="pl-c1">-</span><span class="pl-s1">sensitivity</span> <span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-s1">calibration</span><span class="pl-c1">-</span><span class="pl-s1">nsamples</span> <span class="pl-c1">&lt;</span><span class="pl-s1">num</span><span class="pl-c1">-</span><span class="pl-s1">samples</span><span class="pl-c1">&gt;</span> <span class="pl-c1">-</span><span class="pl-s1">o</span> <span class="pl-c1">&lt;</span><span class="pl-s1">output</span><span class="pl-c1">-</span><span class="pl-s1">dir</span><span class="pl-c1">&gt;</span></pre></div> <p dir="auto">This will run the analysis on all Convolutional and Attention (Einsum) modules in the model. For each module, a compressed version is generated by quantizing only that layer’s weights and activations. Then the PSNR between the outputs of the compressed and original model is calculated, using the same random seed and text prompts.</p> <p dir="auto">This analysis takes up to a few hours on a single GPU (cuda). The number of calibration samples used to quantize the model can be reduced to speed up the process.</p> <p dir="auto">The resulting JSON file looks like this:</p> <div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{ &quot;conv&quot;: { &quot;conv_in&quot;: 30.74, &quot;down_blocks.0.attentions.0.proj_in&quot;: 38.93, &quot;down_blocks.0.attentions.0.transformer_blocks.0.attn1.to_q&quot;: 48.15, &quot;down_blocks.0.attentions.0.transformer_blocks.0.attn1.to_k&quot;: 50.13, &quot;down_blocks.0.attentions.0.transformer_blocks.0.attn1.to_v&quot;: 45.70, &quot;down_blocks.0.attentions.0.transformer_blocks.0.attn1.to_out.0&quot;: 39.56, ... }, &quot;einsum&quot;: { &quot;down_blocks.0.attentions.0.transformer_blocks.0.attn1.einsum&quot;: 25.34, &quot;down_blocks.0.attentions.0.transformer_blocks.0.attn2.einsum&quot;: 31.76, &quot;down_blocks.0.attentions.1.transformer_blocks.0.attn1.einsum&quot;: 23.40, &quot;down_blocks.0.attentions.1.transformer_blocks.0.attn2.einsum&quot;: 31.56, ... }, &quot;model_version&quot;: &quot;stabilityai/stable-diffusion-2-1-base&quot; }"><pre>{ <span class="pl-ent">"conv"</span>: { <span class="pl-ent">"conv_in"</span>: <span class="pl-c1">30.74</span>, <span class="pl-ent">"down_blocks.0.attentions.0.proj_in"</span>: <span class="pl-c1">38.93</span>, <span class="pl-ent">"down_blocks.0.attentions.0.transformer_blocks.0.attn1.to_q"</span>: <span class="pl-c1">48.15</span>, <span class="pl-ent">"down_blocks.0.attentions.0.transformer_blocks.0.attn1.to_k"</span>: <span class="pl-c1">50.13</span>, <span class="pl-ent">"down_blocks.0.attentions.0.transformer_blocks.0.attn1.to_v"</span>: <span class="pl-c1">45.70</span>, <span class="pl-ent">"down_blocks.0.attentions.0.transformer_blocks.0.attn1.to_out.0"</span>: <span class="pl-c1">39.56</span>, <span class="pl-ii">...</span> }, <span class="pl-ent">"einsum"</span>: { <span class="pl-ent">"down_blocks.0.attentions.0.transformer_blocks.0.attn1.einsum"</span>: <span class="pl-c1">25.34</span>, <span class="pl-ent">"down_blocks.0.attentions.0.transformer_blocks.0.attn2.einsum"</span>: <span class="pl-c1">31.76</span>, <span class="pl-ent">"down_blocks.0.attentions.1.transformer_blocks.0.attn1.einsum"</span>: <span class="pl-c1">23.40</span>, <span class="pl-ent">"down_blocks.0.attentions.1.transformer_blocks.0.attn2.einsum"</span>: <span class="pl-c1">31.56</span>, <span class="pl-ii">...</span> }, <span class="pl-ent">"model_version"</span>: <span class="pl-s"><span class="pl-pds">"</span>stabilityai/stable-diffusion-2-1-base<span class="pl-pds">"</span></span> }</pre></div> <p dir="auto"><strong>Step 3:</strong> Generate quantized model</p> <p dir="auto">Using calibration data and layer-wise sensitivity the quantized CoreML model can be generated as follows:</p> <div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="python -m python_coreml_stable_diffusion.activation_quantization --model-version &lt;model-version&gt; --quantize-pytorch --conv-psnr 38 --attn-psnr 26 -o &lt;output-dir&gt;"><pre><span class="pl-s1">python</span> <span class="pl-c1">-</span><span class="pl-s1">m</span> <span class="pl-s1">python_coreml_stable_diffusion</span>.<span class="pl-c1">activation_quantization</span> <span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-s1">model</span><span class="pl-c1">-</span><span class="pl-s1">version</span> <span class="pl-c1">&lt;</span><span class="pl-s1">model</span><span class="pl-c1">-</span><span class="pl-s1">version</span><span class="pl-c1">&gt;</span> <span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-s1">quantize</span><span class="pl-c1">-</span><span class="pl-s1">pytorch</span> <span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-s1">conv</span><span class="pl-c1">-</span><span class="pl-s1">psnr</span> <span class="pl-c1">38</span> <span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-s1">attn</span><span class="pl-c1">-</span><span class="pl-s1">psnr</span> <span class="pl-c1">26</span> <span class="pl-c1">-</span><span class="pl-s1">o</span> <span class="pl-c1">&lt;</span><span class="pl-s1">output</span><span class="pl-c1">-</span><span class="pl-s1">dir</span><span class="pl-c1">&gt;</span></pre></div> <p dir="auto">The PSNR thresholds determine which layers will be activation quantized. This number can be tuned to trade-off between output quality and inference latency.</p> </details> <div class="markdown-heading" dir="auto"><h2 tabindex="-1" class="heading-element" dir="auto"><a name="user-content-using-stable-diffusion-3"></a> Using Stable Diffusion 3</h2><a id="user-content--using-stable-diffusion-3" class="anchor" aria-label="Permalink: Using Stable Diffusion 3" href="#-using-stable-diffusion-3"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <details> <summary> Details (Click to expand) </summary> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Model Conversion</h3><a id="user-content-model-conversion" class="anchor" aria-label="Permalink: Model Conversion" href="#model-conversion"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">Stable Diffusion 3 uses some new and some old models to run. For the text encoders, the conversion can be done using a similar command as before with the <code>--sd3-version</code> flag.</p> <div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="python -m python_coreml_stable_diffusion.torch2coreml --model-version stabilityai/stable-diffusion-3-medium --bundle-resources-for-swift-cli --convert-text-encoder --sd3-version -o &lt;output-dir&gt;"><pre>python -m python_coreml_stable_diffusion.torch2coreml --model-version stabilityai/stable-diffusion-3-medium --bundle-resources-for-swift-cli --convert-text-encoder --sd3-version -o <span class="pl-k">&lt;</span>output-dir<span class="pl-k">&gt;</span></pre></div> <p dir="auto">For the new models (MMDiT, a new VAE with 16 channels, and the T5 text encoder), there are a number of new CLI flags that utilize the <a href="https://www.github.com/argmaxinc/DiffusionKit">DiffusionKit</a> repo:</p> <ul dir="auto"> <li><code>--sd3-version</code>: Indicates to the converter to treat this as a Stable Diffusion 3 model</li> <li><code>--convert-mmdit</code>: Convert the MMDiT model</li> <li><code>--convert-vae-decoder</code>: Convert the new VAE model (this will use the 16 channel version if --sd3-version is set)</li> <li><code>--include-t5</code>: Downloads and includes a pre-converted T5 text encoder in the conversion</li> </ul> <p dir="auto">e.g.:</p> <div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="python -m python_coreml_stable_diffusion.torch2coreml --model-version stabilityai/stable-diffusion-3-medium --bundle-resources-for-swift-cli --convert-vae-decoder --convert-mmdit --include-t5 --sd3-version -o &lt;output-dir&gt;"><pre>python -m python_coreml_stable_diffusion.torch2coreml --model-version stabilityai/stable-diffusion-3-medium --bundle-resources-for-swift-cli --convert-vae-decoder --convert-mmdit --include-t5 --sd3-version -o <span class="pl-k">&lt;</span>output-dir<span class="pl-k">&gt;</span></pre></div> <p dir="auto">To convert the full pipeline with at 1024x1024 resolution, the following command may be used:</p> <div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="python -m python_coreml_stable_diffusion.torch2coreml --model-version stabilityai/stable-diffusion-3-medium --bundle-resources-for-swift-cli --convert-text-encoder --convert-vae-decoder --convert-mmdit --include-t5 --sd3-version --latent-h 128 --latent-w 128 -o &lt;output-dir&gt;"><pre>python -m python_coreml_stable_diffusion.torch2coreml --model-version stabilityai/stable-diffusion-3-medium --bundle-resources-for-swift-cli --convert-text-encoder --convert-vae-decoder --convert-mmdit --include-t5 --sd3-version --latent-h 128 --latent-w 128 -o <span class="pl-k">&lt;</span>output-dir<span class="pl-k">&gt;</span></pre></div> <p dir="auto">Keep in mind that the MMDiT model is quite large and will require increasingly more memory and time to convert as the latent resolution increases.</p> <p dir="auto">Also note that currently the MMDiT model requires fp32 and therefore only supports <code>CPU_AND_GPU</code> compute units and <code>ORIGINAL</code> attention implementation (the default for this pipeline).</p> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Swift Inference</h3><a id="user-content-swift-inference" class="anchor" aria-label="Permalink: Swift Inference" href="#swift-inference"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">Swift inference for Stable Diffusion 3 is similar to the previous versions. The only difference is that the <code>--sd3</code> flag should be used to indicate that the model is a Stable Diffusion 3 model.</p> <div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="swift run StableDiffusionSample &lt;prompt&gt; --resource-path &lt;output-mlpackages-directory/Resources&gt; --output-path &lt;output-dir&gt; --compute-units cpuAndGPU --sd3"><pre>swift run StableDiffusionSample <span class="pl-k">&lt;</span>prompt<span class="pl-k">&gt;</span> --resource-path <span class="pl-k">&lt;</span>output-mlpackages-directory/Resources<span class="pl-k">&gt;</span> --output-path <span class="pl-k">&lt;</span>output-dir<span class="pl-k">&gt;</span> --compute-units cpuAndGPU --sd3</pre></div> </details> <div class="markdown-heading" dir="auto"><h2 tabindex="-1" class="heading-element" dir="auto"><a name="user-content-using-stable-diffusion-xl"></a> Using Stable Diffusion XL</h2><a id="user-content--using-stable-diffusion-xl" class="anchor" aria-label="Permalink: Using Stable Diffusion XL" href="#-using-stable-diffusion-xl"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <details> <summary> Details (Click to expand) </summary> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Model Conversion</h3><a id="user-content-model-conversion-1" class="anchor" aria-label="Permalink: Model Conversion" href="#model-conversion-1"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">e.g.:</p> <div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="python -m python_coreml_stable_diffusion.torch2coreml --convert-unet --convert-vae-decoder --convert-text-encoder --xl-version --model-version stabilityai/stable-diffusion-xl-base-1.0 --refiner-version stabilityai/stable-diffusion-xl-refiner-1.0 --bundle-resources-for-swift-cli --attention-implementation {ORIGINAL,SPLIT_EINSUM} -o &lt;output-dir&gt;"><pre>python -m python_coreml_stable_diffusion.torch2coreml --convert-unet --convert-vae-decoder --convert-text-encoder --xl-version --model-version stabilityai/stable-diffusion-xl-base-1.0 --refiner-version stabilityai/stable-diffusion-xl-refiner-1.0 --bundle-resources-for-swift-cli --attention-implementation {ORIGINAL,SPLIT_EINSUM} -o <span class="pl-k">&lt;</span>output-dir<span class="pl-k">&gt;</span></pre></div> <ul dir="auto"> <li><code>--xl-version</code>: Additional argument to pass to the conversion script when specifying an XL model</li> <li><code>--refiner-version</code>: Additional argument to pass to the conversion script when specifying an XL refiner model, required for <a href="https://huggingface.co/docs/diffusers/main/en/api/pipelines/stable_diffusion/stable_diffusion_xl#1-ensemble-of-expert-denoisers" rel="nofollow">"Ensemble of Expert Denoisers"</a> inference.</li> <li><code>--attention-implementation</code>: <code>ORIGINAL</code> is recommended for <code>cpuAndGPU</code> for deployment on Mac</li> <li><code>--attention-implementation</code>: <code>SPLIT_EINSUM</code> is recommended for <code>cpuAndNeuralEngine</code> for deployment on iPhone &amp; iPad</li> <li><code>--attention-implementation</code>: <code>SPLIT_EINSUM_V2</code> is not recommended for Stable Diffusion XL because of prohibitively long compilation time</li> <li><strong>Tip:</strong> Adding <code>--latent-h 96 --latent-w 96</code> is recommended for iOS and iPadOS deployment which leads to 768x768 generation as opposed to the default 1024x1024.</li> <li><strong>Tip:</strong> Due to known float16 overflow issues in the original Stable Diffusion XL VAE, <a href="https://github.com/apple/ml-stable-diffusion/blob/main/python_coreml_stable_diffusion/torch2coreml.py#L486">the model conversion script enforces float32 precision</a>. Using a custom VAE version such as <a href="https://huggingface.co/madebyollin/sdxl-vae-fp16-fix" rel="nofollow">madebyollin/sdxl-vae-fp16-fix</a> by <a href="https://github.com/madebyollin">@madebyollin</a> via <code>--custom-vae-version madebyollin/sdxl-vae-fp16-fix</code> will restore the default float16 precision for VAE.</li> </ul> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Swift Inference</h3><a id="user-content-swift-inference-1" class="anchor" aria-label="Permalink: Swift Inference" href="#swift-inference-1"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="swift run StableDiffusionSample &lt;prompt&gt; --resource-path &lt;output-mlpackages-directory/Resources&gt; --output-path &lt;output-dir&gt; --compute-units {cpuAndGPU,cpuAndNeuralEngine} --xl"><pre>swift run StableDiffusionSample <span class="pl-k">&lt;</span>prompt<span class="pl-k">&gt;</span> --resource-path <span class="pl-k">&lt;</span>output-mlpackages-directory/Resources<span class="pl-k">&gt;</span> --output-path <span class="pl-k">&lt;</span>output-dir<span class="pl-k">&gt;</span> --compute-units {cpuAndGPU,cpuAndNeuralEngine} --xl</pre></div> <ul dir="auto"> <li>Only the <code>base</code> model is required, <code>refiner</code> model is optional and will be used by default if provided in the resource directory</li> <li>ControlNet for XL is not yet supported</li> </ul> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Python Inference</h3><a id="user-content-python-inference" class="anchor" aria-label="Permalink: Python Inference" href="#python-inference"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="python -m python_coreml_stable_diffusion.pipeline --prompt &lt;prompt&gt; --compute-unit {CPU_AND_GPU,CPU_AND_NE} -o &lt;output-dir&gt; -i &lt;output-mlpackages-directory/Resources&gt; --model-version stabilityai/stable-diffusion-xl-base-1.0"><pre>python -m python_coreml_stable_diffusion.pipeline --prompt <span class="pl-k">&lt;</span>prompt<span class="pl-k">&gt;</span> --compute-unit {CPU_AND_GPU,CPU_AND_NE} -o <span class="pl-k">&lt;</span>output-dir<span class="pl-k">&gt;</span> -i <span class="pl-k">&lt;</span>output-mlpackages-directory/Resources<span class="pl-k">&gt;</span> --model-version stabilityai/stable-diffusion-xl-base-1.0</pre></div> <ul dir="auto"> <li><code>refiner</code> model is not yet supported</li> <li>ControlNet for XL is not yet supported</li> </ul> </details> <div class="markdown-heading" dir="auto"><h2 tabindex="-1" class="heading-element" dir="auto"><a name="user-content-using-controlnet"></a> Using ControlNet</h2><a id="user-content--using-controlnet" class="anchor" aria-label="Permalink: Using ControlNet" href="#-using-controlnet"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <details> <summary> Details (Click to expand) </summary> <p dir="auto">Example results using the prompt <em>"a high quality photo of a surfing dog"</em> conditioned on the scribble (leftmost):</p> <a target="_blank" rel="noopener noreferrer" href="/apple/ml-stable-diffusion/blob/main/assets/controlnet_readme_reel.png"><img src="/apple/ml-stable-diffusion/raw/main/assets/controlnet_readme_reel.png" style="max-width: 100%;"></a> <p dir="auto"><a href="https://huggingface.co/lllyasviel/ControlNet" rel="nofollow">ControlNet</a> allows users to condition image generation with Stable Diffusion on signals such as edge maps, depth maps, segmentation maps, scribbles and pose. Thanks to <a href="https://github.com/apple/ml-stable-diffusion/pull/153" data-hovercard-type="pull_request" data-hovercard-url="/apple/ml-stable-diffusion/pull/153/hovercard">@ryu38's contribution</a>, both the Python CLI and the Swift package support ControlNet models. Please refer to <a href="#converting-models-to-coreml">this section</a> for details on setting up Stable Diffusion with ControlNet.</p> <p dir="auto">Note that ControlNet is not yet supported for Stable Diffusion XL.</p> </details> <div class="markdown-heading" dir="auto"><h2 tabindex="-1" class="heading-element" dir="auto"><a name="user-content-system-multilingual-text-encoder"></a> Using the System Multilingual Text Encoder</h2><a id="user-content--using-the-system-multilingual-text-encoder" class="anchor" aria-label="Permalink: Using the System Multilingual Text Encoder" href="#-using-the-system-multilingual-text-encoder"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <details> <summary> Details (Click to expand) </summary> <p dir="auto">With iOS 17 and macOS 14, <code>NaturalLanguage</code> framework introduced the <a href="https://developer.apple.com/documentation/naturallanguage/nlcontextualembedding" rel="nofollow">NLContextualEmbedding</a> which provides Transformer-based textual embeddings for Latin (20 languages), Cyrillic (4 languages) and CJK (3 languages) scripts. The WWDC23 session titled <a href="https://developer.apple.com/videos/play/wwdc2023/10042" rel="nofollow">Explore Natural Language multilingual models</a> demonstrated how this powerful new model can be used by developers to train downstream tasks such as multilingual image generation with Stable Diffusion.</p> <p dir="auto">The code to reproduce this demo workflow is made available in this repository. There are several ways in which this workflow can be implemented. Here is an example:</p> <p dir="auto"><strong>Step 1:</strong> Curate an image-text dataset with the desired languages.</p> <p dir="auto"><strong>Step 2:</strong> Pre-compute the NLContextualEmbedding values and replace the text strings with these embedding vectors in your dataset.</p> <p dir="auto"><strong>Step 3:</strong> Fine-tune a base model from Hugging Face Hub that is compatible with the <a href="https://huggingface.co/docs/diffusers/api/pipelines/stable_diffusion/overview" rel="nofollow">StableDiffusionPipeline</a> by using your new dataset and replacing the default text_encoder with your pre-computed NLContextualEmbedding values.</p> <p dir="auto"><strong>Step 4:</strong> In order to be able to swap the text_encoder of a base model without training new layers, the base model's <code>text_encoder.hidden_size</code> must match that of NLContextualEmbedding. If it doesn't, you will need to train a linear projection layer to map between the two dimensionalities. After fine-tuning, this linear layer should be converted to CoreML as follows:</p> <div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="python -m python_coreml_stable_diffusion.multilingual_projection --input-path &lt;path-to-projection-torchscript&gt; --output-dir &lt;output-dir&gt;"><pre>python -m python_coreml_stable_diffusion.multilingual_projection --input-path <span class="pl-k">&lt;</span>path-to-projection-torchscript<span class="pl-k">&gt;</span> --output-dir <span class="pl-k">&lt;</span>output-dir<span class="pl-k">&gt;</span></pre></div> <p dir="auto">The command above will yield a <code>MultilingualTextEncoderProjection.mlmodelc</code> file under <code>--output-dir</code> and this should be colocated with the rest of the Core ML model assets that were generated through <code>--bundle-resources-for-swift-cli</code>.</p> <p dir="auto"><strong>Step 5:</strong> The multilingual system text encoder can now be invoked by setting <code>useMultilingualTextEncoder</code> to true when initializing a pipeline or setting <code>--use-multilingual-text-encoder</code> in the CLI. Note that the model assets are distributed over-the-air so the first invocation will trigger asset downloads which is less than 100MB.</p> <p dir="auto">Resources:</p> <ul dir="auto"> <li><a href="https://developer.apple.com/videos/play/wwdc2023/10042" rel="nofollow">WWDC23 Session Video: Explore Natural Language multilingual models</a></li> <li><a href="https://developer.apple.com/documentation/naturallanguage/nlcontextualembedding" rel="nofollow">NLContextualEmbedding API Documentation</a></li> </ul> </details> <div class="markdown-heading" dir="auto"><h2 tabindex="-1" class="heading-element" dir="auto"><a name="user-content-using-converted-weights"></a> Using Ready-made Core ML Models from Hugging Face Hub</h2><a id="user-content--using-ready-made-core-ml-models-from-hugging-face-hub" class="anchor" aria-label="Permalink: Using Ready-made Core ML Models from Hugging Face Hub" href="#-using-ready-made-core-ml-models-from-hugging-face-hub"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <details> <summary> Click to expand </summary> <p dir="auto">🤗 Hugging Face ran the <a href="#converting-models-to-coreml">conversion procedure</a> on the following models and made the Core ML weights publicly available on the Hub. If you would like to convert a version of Stable Diffusion that is not already available on the Hub, please refer to the <a href="#converting-models-to-coreml">Converting Models to Core ML</a>.</p> <ul dir="auto"> <li> <p dir="auto">6-bit quantized models (suitable for iOS 17 and macOS 14):</p> <ul dir="auto"> <li><a href="https://huggingface.co/apple/coreml-stable-diffusion-1-4-palettized" rel="nofollow"><code>CompVis/stable-diffusion-v1-4</code></a></li> <li><a href="https://huggingface.co/apple/coreml-stable-diffusion-v1-5-palettized" rel="nofollow"><code>runwayml/stable-diffusion-v1-5</code></a></li> <li><a href="https://huggingface.co/apple/coreml-stable-diffusion-2-base-palettized" rel="nofollow"><code>stabilityai/stable-diffusion-2-base</code></a></li> <li><a href="https://huggingface.co/apple/coreml-stable-diffusion-2-1-base-palettized" rel="nofollow"><code>stabilityai/stable-diffusion-2-1-base</code></a></li> </ul> </li> <li> <p dir="auto">Mixed-bit quantized models</p> </li> </ul> <ul dir="auto"> <li><a href="https://huggingface.co/apple/coreml-stable-diffusion-mixed-bit-palettization" rel="nofollow"><code>stabilityai/stable-diffusion-xl-base-1.0</code></a></li> <li><a href="https://huggingface.co/apple/coreml-stable-diffusion-xl-base-ios" rel="nofollow"><code>stabilityai/stable-diffusion-xl-base-1.0-ios</code></a></li> </ul> <ul dir="auto"> <li>Uncompressed models: <ul dir="auto"> <li><a href="https://huggingface.co/apple/coreml-stable-diffusion-v1-4" rel="nofollow"><code>CompVis/stable-diffusion-v1-4</code></a></li> <li><a href="https://huggingface.co/apple/coreml-stable-diffusion-v1-5" rel="nofollow"><code>runwayml/stable-diffusion-v1-5</code></a></li> <li><a href="https://huggingface.co/apple/coreml-stable-diffusion-2-base" rel="nofollow"><code>stabilityai/stable-diffusion-2-base</code></a></li> <li><a href="https://huggingface.co/apple/coreml-stable-diffusion-2-1-base" rel="nofollow"><code>stabilityai/stable-diffusion-2-1-base</code></a></li> <li><a href="https://huggingface.co/apple/coreml-stable-diffusion-xl-base" rel="nofollow"><code>stabilityai/stable-diffusion-xl-base-1.0</code></a></li> <li><a href="https://huggingface.co/apple/coreml-stable-diffusion-xl-base-with-refiner" rel="nofollow"><code>stabilityai/stable-diffusion-xl-{base+refiner}-1.0</code></a></li> <li><a href="https://huggingface.co/stabilityai/stable-diffusion-3-medium" rel="nofollow"><code>stabilityai/stable-diffusion-3-medium</code></a></li> </ul> </li> </ul> <p dir="auto">If you want to use any of those models you may download the weights and proceed to <a href="#image-generation-with-python">generate images with Python</a> or <a href="#image-generation-with-swift">Swift</a>.</p> <p dir="auto">There are several variants in each model repository. You may clone the whole repos using <code>git</code> and <code>git lfs</code> to download all variants, or selectively download the ones you need.</p> <p dir="auto">To clone the repos using <code>git</code>, please follow this process:</p> <p dir="auto"><strong>Step 1:</strong> Install the <code>git lfs</code> extension for your system.</p> <p dir="auto"><code>git lfs</code> stores large files outside the main git repo, and it downloads them from the appropriate server after you clone or checkout. It is available in most package managers, check <a href="https://git-lfs.com" rel="nofollow">the installation page</a> for details.</p> <p dir="auto"><strong>Step 2:</strong> Enable <code>git lfs</code> by running this command once:</p> <div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="git lfs install"><pre>git lfs install</pre></div> <p dir="auto"><strong>Step 3:</strong> Use <code>git clone</code> to download a copy of the repo that includes all model variants. For Stable Diffusion version 1.4, you'd issue the following command in your terminal:</p> <div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="git clone https://huggingface.co/apple/coreml-stable-diffusion-v1-4"><pre>git clone https://huggingface.co/apple/coreml-stable-diffusion-v1-4</pre></div> <p dir="auto">If you prefer to download specific variants instead of cloning the repos, you can use the <code>huggingface_hub</code> Python library. For example, to do generation in Python using the <code>ORIGINAL</code> attention implementation (read <a href="#converting-models-to-coreml">this section</a> for details), you could use the following helper code:</p> <div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="from huggingface_hub import snapshot_download from pathlib import Path repo_id = &quot;apple/coreml-stable-diffusion-v1-4&quot; variant = &quot;original/packages&quot; model_path = Path(&quot;./models&quot;) / (repo_id.split(&quot;/&quot;)[-1] + &quot;_&quot; + variant.replace(&quot;/&quot;, &quot;_&quot;)) snapshot_download(repo_id, allow_patterns=f&quot;{variant}/*&quot;, local_dir=model_path, local_dir_use_symlinks=False) print(f&quot;Model downloaded at {model_path}&quot;)"><pre><span class="pl-k">from</span> <span class="pl-s1">huggingface_hub</span> <span class="pl-k">import</span> <span class="pl-s1">snapshot_download</span> <span class="pl-k">from</span> <span class="pl-s1">pathlib</span> <span class="pl-k">import</span> <span class="pl-v">Path</span> <span class="pl-s1">repo_id</span> <span class="pl-c1">=</span> <span class="pl-s">"apple/coreml-stable-diffusion-v1-4"</span> <span class="pl-s1">variant</span> <span class="pl-c1">=</span> <span class="pl-s">"original/packages"</span> <span class="pl-s1">model_path</span> <span class="pl-c1">=</span> <span class="pl-en">Path</span>(<span class="pl-s">"./models"</span>) <span class="pl-c1">/</span> (<span class="pl-s1">repo_id</span>.<span class="pl-c1">split</span>(<span class="pl-s">"/"</span>)[<span class="pl-c1">-</span><span class="pl-c1">1</span>] <span class="pl-c1">+</span> <span class="pl-s">"_"</span> <span class="pl-c1">+</span> <span class="pl-s1">variant</span>.<span class="pl-c1">replace</span>(<span class="pl-s">"/"</span>, <span class="pl-s">"_"</span>)) <span class="pl-en">snapshot_download</span>(<span class="pl-s1">repo_id</span>, <span class="pl-s1">allow_patterns</span><span class="pl-c1">=</span><span class="pl-s">f"<span class="pl-s1"><span class="pl-kos">{</span><span class="pl-s1">variant</span><span class="pl-kos">}</span></span>/*"</span>, <span class="pl-s1">local_dir</span><span class="pl-c1">=</span><span class="pl-s1">model_path</span>, <span class="pl-s1">local_dir_use_symlinks</span><span class="pl-c1">=</span><span class="pl-c1">False</span>) <span class="pl-en">print</span>(<span class="pl-s">f"Model downloaded at <span class="pl-s1"><span class="pl-kos">{</span><span class="pl-s1">model_path</span><span class="pl-kos">}</span></span>"</span>)</pre></div> <p dir="auto"><code>model_path</code> would be the path in your local filesystem where the checkpoint was saved. Please, refer to <a href="https://huggingface.co/blog/diffusers-coreml" rel="nofollow">this post</a> for additional details.</p> </details> <div class="markdown-heading" dir="auto"><h2 tabindex="-1" class="heading-element" dir="auto"><a name="user-content-converting-models-to-coreml"></a> Converting Models to Core ML</h2><a id="user-content--converting-models-to-core-ml" class="anchor" aria-label="Permalink: Converting Models to Core ML" href="#-converting-models-to-core-ml"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <details> <summary> Click to expand </summary> <p dir="auto"><strong>Step 1:</strong> Create a Python environment and install dependencies:</p> <div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="conda create -n coreml_stable_diffusion python=3.8 -y conda activate coreml_stable_diffusion cd /path/to/cloned/ml-stable-diffusion/repository pip install -e ."><pre>conda create -n coreml_stable_diffusion python=3.8 -y conda activate coreml_stable_diffusion <span class="pl-c1">cd</span> /path/to/cloned/ml-stable-diffusion/repository pip install -e <span class="pl-c1">.</span></pre></div> <p dir="auto"><strong>Step 2:</strong> Log in to or register for your <a href="https://huggingface.co" rel="nofollow">Hugging Face account</a>, generate a <a href="https://huggingface.co/settings/tokens" rel="nofollow">User Access Token</a> and use this token to set up Hugging Face API access by running <code>huggingface-cli login</code> in a Terminal window.</p> <p dir="auto"><strong>Step 3:</strong> Navigate to the version of Stable Diffusion that you would like to use on <a href="https://huggingface.co/models?search=stable-diffusion" rel="nofollow">Hugging Face Hub</a> and accept its Terms of Use. The default model version is <a href="https://huggingface.co/CompVis/stable-diffusion-v1-4" rel="nofollow">CompVis/stable-diffusion-v1-4</a>. The model version may be changed by the user as described in the next step.</p> <p dir="auto"><strong>Step 4:</strong> Execute the following command from the Terminal to generate Core ML model files (<code>.mlpackage</code>)</p> <div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="python -m python_coreml_stable_diffusion.torch2coreml --convert-unet --convert-text-encoder --convert-vae-decoder --convert-safety-checker --model-version &lt;model-version-string-from-hub&gt; -o &lt;output-mlpackages-directory&gt;"><pre>python -m python_coreml_stable_diffusion.torch2coreml --convert-unet --convert-text-encoder --convert-vae-decoder --convert-safety-checker --model-version <span class="pl-k">&lt;</span>model-version-string-from-hub<span class="pl-k">&gt;</span> -o <span class="pl-k">&lt;</span>output-mlpackages-directory<span class="pl-k">&gt;</span></pre></div> <p dir="auto"><strong>WARNING:</strong> This command will download several GB worth of PyTorch checkpoints from Hugging Face. Please ensure that you are on Wi-Fi and have enough disk space.</p> <p dir="auto">This generally takes 15-20 minutes on an M1 MacBook Pro. Upon successful execution, the 4 neural network models that comprise Stable Diffusion will have been converted from PyTorch to Core ML (<code>.mlpackage</code>) and saved into the specified <code>&lt;output-mlpackages-directory&gt;</code>. Some additional notable arguments:</p> <ul dir="auto"> <li> <p dir="auto"><code>--model-version</code>: The model version name as published on the <a href="https://huggingface.co/models?search=stable-diffusion" rel="nofollow">Hugging Face Hub</a></p> </li> <li> <p dir="auto"><code>--refiner-version</code>: The refiner version name as published on the <a href="https://huggingface.co/models?search=stable-diffusion" rel="nofollow">Hugging Face Hub</a>. This is optional and if specified, this argument will convert and bundle the refiner unet alongside the model unet.</p> </li> <li> <p dir="auto"><code>--bundle-resources-for-swift-cli</code>: Compiles all 4 models and bundles them along with necessary resources for text tokenization into <code>&lt;output-mlpackages-directory&gt;/Resources</code> which should provided as input to the Swift package. This flag is not necessary for the diffusers-based Python pipeline. <a href="https://apple.github.io/coremltools/docs-guides/source/model-prediction.html#why-use-a-compiled-model" rel="nofollow">However using these compiled models in Python will significantly speed up inference</a>.</p> </li> <li> <p dir="auto"><code>--quantize-nbits</code>: Quantizes the weights of unet and text_encoder models down to 2, 4, 6 or 8 bits using a globally optimal k-means clustering algorithm. By default all models are weight-quantized to 16 bits even if this argument is not specified. Please refer to [this section](#compression-6-bits-and-higher for details and further guidance on weight compression.</p> </li> <li> <p dir="auto"><code>--chunk-unet</code>: Splits the Unet model in two approximately equal chunks (each with less than 1GB of weights) for mobile-friendly deployment. This is <strong>required</strong> for Neural Engine deployment on iOS and iPadOS if weights are not quantized to 6-bits or less (<code>--quantize-nbits {2,4,6}</code>). This is not required for macOS. Swift CLI is able to consume both the chunked and regular versions of the Unet model but prioritizes the former. Note that chunked unet is not compatible with the Python pipeline because Python pipeline is intended for macOS only.</p> </li> <li> <p dir="auto"><code>--attention-implementation</code>: Defaults to <code>SPLIT_EINSUM</code> which is the implementation described in <a href="https://machinelearning.apple.com/research/neural-engine-transformers" rel="nofollow">Deploying Transformers on the Apple Neural Engine</a>. <code>--attention-implementation SPLIT_EINSUM_V2</code> yields 10-30% improvement for mobile devices, still targeting the Neural Engine. <code>--attention-implementation ORIGINAL</code> will switch to an alternative implementation that should be used for CPU or GPU deployment on some Mac devices. Please refer to the <a href="#performance-benchmark">Performance Benchmark</a> section for further guidance.</p> </li> <li> <p dir="auto"><code>--check-output-correctness</code>: Compares original PyTorch model's outputs to final Core ML model's outputs. This flag increases RAM consumption significantly so it is recommended only for debugging purposes.</p> </li> <li> <p dir="auto"><code>--convert-controlnet</code>: Converts ControlNet models specified after this option. This can also convert multiple models if you specify like <code>--convert-controlnet lllyasviel/sd-controlnet-mlsd lllyasviel/sd-controlnet-depth</code>.</p> </li> <li> <p dir="auto"><code>--unet-support-controlnet</code>: enables a converted UNet model to receive additional inputs from ControlNet. This is required for generating image with using ControlNet and saved with a different name, <code>*_control-unet.mlpackage</code>, distinct from normal UNet. On the other hand, this UNet model can not work without ControlNet. Please use normal UNet for just txt2img.</p> </li> <li> <p dir="auto"><code>--unet-batch-one</code>: use a batch size of one for the unet, this is needed if you do not want to do classifier free guidance, i.e. using a <code>guidance-scale</code> of less than one.</p> </li> <li> <p dir="auto"><code>--convert-vae-encoder</code>: not required for text-to-image applications. Required for image-to-image applications in order to map the input image to the latent space.</p> </li> </ul> </details> <div class="markdown-heading" dir="auto"><h2 tabindex="-1" class="heading-element" dir="auto"><a name="user-content-image-generation-with-python"></a> Image Generation with Python</h2><a id="user-content--image-generation-with-python" class="anchor" aria-label="Permalink: Image Generation with Python" href="#-image-generation-with-python"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <details> <summary> Click to expand </summary> <p dir="auto">Run text-to-image generation using the example Python pipeline based on <a href="https://github.com/huggingface/diffusers">diffusers</a>:</p> <div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="python -m python_coreml_stable_diffusion.pipeline --prompt &quot;a photo of an astronaut riding a horse on mars&quot; -i &lt;core-ml-model-directory&gt; -o &lt;/path/to/output/image&gt; --compute-unit ALL --seed 93"><pre>python -m python_coreml_stable_diffusion.pipeline --prompt <span class="pl-s"><span class="pl-pds">"</span>a photo of an astronaut riding a horse on mars<span class="pl-pds">"</span></span> -i <span class="pl-k">&lt;</span>core-ml-model-directory<span class="pl-k">&gt;</span> -o <span class="pl-k">&lt;</span>/path/to/output/image<span class="pl-k">&gt;</span> --compute-unit ALL --seed 93</pre></div> <p dir="auto">Please refer to the help menu for all available arguments: <code>python -m python_coreml_stable_diffusion.pipeline -h</code>. Some notable arguments:</p> <ul dir="auto"> <li><code>-i</code>: Should point to the <code>-o</code> directory from Step 4 of <a href="#converting-models-to-coreml">Converting Models to Core ML</a> section from above. If you specified <code>--bundle-resources-for-swift-cli</code> during conversion, then use the resulting <code>Resources</code> folder (which holds the compiled <code>.mlmodelc</code> files). <a href="https://apple.github.io/coremltools/docs-guides/source/model-prediction.html#why-use-a-compiled-model" rel="nofollow">The compiled models load much faster after first use</a>.</li> <li><code>--model-version</code>: If you overrode the default model version while converting models to Core ML, you will need to specify the same model version here.</li> <li><code>--compute-unit</code>: Note that the most performant compute unit for this particular implementation may differ across different hardware. <code>CPU_AND_GPU</code> or <code>CPU_AND_NE</code> may be faster than <code>ALL</code>. Please refer to the <a href="#performance-benchmark">Performance Benchmark</a> section for further guidance.</li> <li><code>--scheduler</code>: If you would like to experiment with different schedulers, you may specify it here. For available options, please see the help menu. You may also specify a custom number of inference steps by <code>--num-inference-steps</code> which defaults to 50.</li> <li><code>--controlnet</code>: ControlNet models specified with this option are used in image generation. Use this option in the format <code>--controlnet lllyasviel/sd-controlnet-mlsd lllyasviel/sd-controlnet-depth</code> and make sure to use <code>--controlnet-inputs</code> in conjunction.</li> <li><code>--controlnet-inputs</code>: Image inputs corresponding to each ControlNet model. Please provide image paths in same order as models in <code>--controlnet</code>, for example: <code>--controlnet-inputs image_mlsd image_depth</code>.</li> <li><code>--unet-batch-one</code>: Do not batch unet predictions for the prompt and negative prompt. This requires the unet has been converted with a batch size of one, see <code>--unet-batch-one</code> option in conversion script.</li> </ul> </details> <div class="markdown-heading" dir="auto"><h2 tabindex="-1" class="heading-element" dir="auto"><a name="user-content-image-gen-swift"></a> Image Generation with Swift</h2><a id="user-content--image-generation-with-swift" class="anchor" aria-label="Permalink: Image Generation with Swift" href="#-image-generation-with-swift"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <details> <summary> Click to expand </summary> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Example CLI Usage</h3><a id="user-content-example-cli-usage" class="anchor" aria-label="Permalink: Example CLI Usage" href="#example-cli-usage"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="swift run StableDiffusionSample &quot;a photo of an astronaut riding a horse on mars&quot; --resource-path &lt;output-mlpackages-directory&gt;/Resources/ --seed 93 --output-path &lt;/path/to/output/image&gt;"><pre>swift run StableDiffusionSample <span class="pl-s"><span class="pl-pds">"</span>a photo of an astronaut riding a horse on mars<span class="pl-pds">"</span></span> --resource-path <span class="pl-k">&lt;</span>output-mlpackages-directory<span class="pl-k">&gt;</span>/Resources/ --seed 93 --output-path <span class="pl-k">&lt;</span>/path/to/output/image<span class="pl-k">&gt;</span></pre></div> <p dir="auto">The output will be named based on the prompt and random seed: e.g. <code>&lt;/path/to/output/image&gt;/a_photo_of_an_astronaut_riding_a_horse_on_mars.93.final.png</code></p> <p dir="auto">Please use the <code>--help</code> flag to learn about batched generation and more.</p> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Example Library Usage</h3><a id="user-content-example-library-usage" class="anchor" aria-label="Permalink: Example Library Usage" href="#example-library-usage"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <div class="highlight highlight-source-swift notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import StableDiffusion ... let pipeline = try StableDiffusionPipeline(resourcesAt: resourceURL) pipeline.loadResources() let image = try pipeline.generateImages(prompt: prompt, seed: seed).first"><pre><span class="pl-k">import</span> StableDiffusion <span class="pl-c1">...</span> <span class="pl-k">let</span> <span class="pl-s1">pipeline</span> <span class="pl-c1">=</span> <span class="pl-c1"><span class="pl-k">try</span></span> <span class="pl-en">StableDiffusionPipeline</span><span class="pl-kos">(</span>resourcesAt<span class="pl-kos">:</span> resourceURL<span class="pl-kos">)</span> pipeline<span class="pl-kos">.</span><span class="pl-en">loadResources</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-k">let</span> <span class="pl-s1">image</span> <span class="pl-c1">=</span> <span class="pl-c1"><span class="pl-k">try</span></span> pipeline<span class="pl-kos">.</span><span class="pl-en">generateImages</span><span class="pl-kos">(</span>prompt<span class="pl-kos">:</span> prompt<span class="pl-kos">,</span> seed<span class="pl-kos">:</span> seed<span class="pl-kos">)</span><span class="pl-kos">.</span>first</pre></div> <p dir="auto">On iOS, the <code>reduceMemory</code> option should be set to <code>true</code> when constructing <code>StableDiffusionPipeline</code></p> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Swift Package Details</h3><a id="user-content-swift-package-details" class="anchor" aria-label="Permalink: Swift Package Details" href="#swift-package-details"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">This Swift package contains two products:</p> <ul dir="auto"> <li><code>StableDiffusion</code> library</li> <li><code>StableDiffusionSample</code> command-line tool</li> </ul> <p dir="auto">Both of these products require the Core ML models and tokenization resources to be supplied. When specifying resources via a directory path that directory must contain the following:</p> <ul dir="auto"> <li><code>TextEncoder.mlmodelc</code> or `TextEncoder2.mlmodelc (text embedding model)</li> <li><code>Unet.mlmodelc</code> or <code>UnetChunk1.mlmodelc</code> &amp; <code>UnetChunk2.mlmodelc</code> (denoising autoencoder model)</li> <li><code>VAEDecoder.mlmodelc</code> (image decoder model)</li> <li><code>vocab.json</code> (tokenizer vocabulary file)</li> <li><code>merges.text</code> (merges for byte pair encoding file)</li> </ul> <p dir="auto">Optionally, for image2image, in-painting, or similar:</p> <ul dir="auto"> <li><code>VAEEncoder.mlmodelc</code> (image encoder model)</li> </ul> <p dir="auto">Optionally, it may also include the safety checker model that some versions of Stable Diffusion include:</p> <ul dir="auto"> <li><code>SafetyChecker.mlmodelc</code></li> </ul> <p dir="auto">Optionally, for the SDXL refiner:</p> <ul dir="auto"> <li><code>UnetRefiner.mlmodelc</code> (refiner unet model)</li> </ul> <p dir="auto">Optionally, for ControlNet:</p> <ul dir="auto"> <li><code>ControlledUNet.mlmodelc</code> or <code>ControlledUnetChunk1.mlmodelc</code> &amp; <code>ControlledUnetChunk2.mlmodelc</code> (enabled to receive ControlNet values)</li> <li><code>controlnet/</code> (directory containing ControlNet models) <ul dir="auto"> <li><code>LllyasvielSdControlnetMlsd.mlmodelc</code> (for example, from lllyasviel/sd-controlnet-mlsd)</li> <li><code>LllyasvielSdControlnetDepth.mlmodelc</code> (for example, from lllyasviel/sd-controlnet-depth)</li> <li>Other models you converted</li> </ul> </li> </ul> <p dir="auto">Note that the chunked version of Unet is checked for first. Only if it is not present will the full <code>Unet.mlmodelc</code> be loaded. Chunking is required for iOS and iPadOS and not necessary for macOS.</p> </details> <div class="markdown-heading" dir="auto"><h2 tabindex="-1" class="heading-element" dir="auto"><a name="user-content-swift-app"></a> Example Swift App</h2><a id="user-content--example-swift-app" class="anchor" aria-label="Permalink: Example Swift App" href="#-example-swift-app"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <details> <summary> Click to expand </summary> <p dir="auto">🤗 Hugging Face created an <a href="https://github.com/huggingface/swift-coreml-diffusers">open-source demo app</a> on top of this library. It's written in native Swift and Swift UI, and runs on macOS, iOS and iPadOS. You can use the code as a starting point for your app, or to see how to integrate this library in your own projects.</p> <p dir="auto">Hugging Face has made the app <a href="https://apps.apple.com/app/diffusers/id1666309574?mt=12" rel="nofollow">available in the Mac App Store</a>.</p> </details> <div class="markdown-heading" dir="auto"><h2 tabindex="-1" class="heading-element" dir="auto"><a name="user-content-faq"></a> FAQ</h2><a id="user-content--faq" class="anchor" aria-label="Permalink: FAQ" href="#-faq"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <details> <summary> Click to expand </summary> <details> <summary> <b> Q1: </b> <code> ERROR: Failed building wheel for tokenizers or error: can't find Rust compiler </code> </summary> <p dir="auto"><b> A1: </b> Please review this <a href="https://github.com/huggingface/transformers/issues/2831#issuecomment-592724471" data-hovercard-type="issue" data-hovercard-url="/huggingface/transformers/issues/2831/hovercard">potential solution</a>.</p> </details> <details> <summary> <b> Q2: </b> <code> RuntimeError: {NSLocalizedDescription = "Error computing NN outputs." </code> </summary> <p dir="auto"><b> A2: </b> There are many potential causes for this error. In this context, it is highly likely to be encountered when your system is under increased memory pressure from other applications. Reducing memory utilization of other applications is likely to help alleviate the issue.</p> </details> <details> <summary> <b> <a name="user-content-low-mem-conversion"></a> Q3: </b> My Mac has 8GB RAM and I am converting models to Core ML using the example command. The process is getting killed because of memory issues. How do I fix this issue? </summary> <p dir="auto"><b> A3: </b> In order to minimize the memory impact of the model conversion process, please execute the following command instead:</p> <div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="python -m python_coreml_stable_diffusion.torch2coreml --convert-vae-encoder --model-version &lt;model-version-string-from-hub&gt; -o &lt;output-mlpackages-directory&gt; &amp;&amp; \ python -m python_coreml_stable_diffusion.torch2coreml --convert-vae-decoder --model-version &lt;model-version-string-from-hub&gt; -o &lt;output-mlpackages-directory&gt; &amp;&amp; \ python -m python_coreml_stable_diffusion.torch2coreml --convert-unet --model-version &lt;model-version-string-from-hub&gt; -o &lt;output-mlpackages-directory&gt; &amp;&amp; \ python -m python_coreml_stable_diffusion.torch2coreml --convert-text-encoder --model-version &lt;model-version-string-from-hub&gt; -o &lt;output-mlpackages-directory&gt; &amp;&amp; \ python -m python_coreml_stable_diffusion.torch2coreml --convert-safety-checker --model-version &lt;model-version-string-from-hub&gt; -o &lt;output-mlpackages-directory&gt; &amp;&amp;"><pre>python -m python_coreml_stable_diffusion.torch2coreml --convert-vae-encoder --model-version <span class="pl-k">&lt;</span>model-version-string-from-hub<span class="pl-k">&gt;</span> -o <span class="pl-k">&lt;</span>output-mlpackages-directory<span class="pl-k">&gt;</span> <span class="pl-k">&amp;&amp;</span> \ python -m python_coreml_stable_diffusion.torch2coreml --convert-vae-decoder --model-version <span class="pl-k">&lt;</span>model-version-string-from-hub<span class="pl-k">&gt;</span> -o <span class="pl-k">&lt;</span>output-mlpackages-directory<span class="pl-k">&gt;</span> <span class="pl-k">&amp;&amp;</span> \ python -m python_coreml_stable_diffusion.torch2coreml --convert-unet --model-version <span class="pl-k">&lt;</span>model-version-string-from-hub<span class="pl-k">&gt;</span> -o <span class="pl-k">&lt;</span>output-mlpackages-directory<span class="pl-k">&gt;</span> <span class="pl-k">&amp;&amp;</span> \ python -m python_coreml_stable_diffusion.torch2coreml --convert-text-encoder --model-version <span class="pl-k">&lt;</span>model-version-string-from-hub<span class="pl-k">&gt;</span> -o <span class="pl-k">&lt;</span>output-mlpackages-directory<span class="pl-k">&gt;</span> <span class="pl-k">&amp;&amp;</span> \ python -m python_coreml_stable_diffusion.torch2coreml --convert-safety-checker --model-version <span class="pl-k">&lt;</span>model-version-string-from-hub<span class="pl-k">&gt;</span> -o <span class="pl-k">&lt;</span>output-mlpackages-directory<span class="pl-k">&gt;</span> <span class="pl-k">&amp;&amp;</span></pre></div> <p dir="auto">If you need <code>--chunk-unet</code>, you may do so in yet another independent command which will reuse the previously exported Unet model and simply chunk it in place:</p> <div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="python -m python_coreml_stable_diffusion.torch2coreml --convert-unet --chunk-unet -o &lt;output-mlpackages-directory&gt;"><pre>python -m python_coreml_stable_diffusion.torch2coreml --convert-unet --chunk-unet -o <span class="pl-k">&lt;</span>output-mlpackages-directory<span class="pl-k">&gt;</span></pre></div> </details> <details> <summary> <b> Q4: </b> My Mac has 8GB RAM, should image generation work on my machine? </summary> <p dir="auto"><b> A4: </b> Yes! Especially the <code>--compute-unit CPU_AND_NE</code> option should work under reasonable system load from other applications. Note that part of the <a href="#example-results">Example Results</a> were generated using an M2 MacBook Air with 8GB RAM.</p> </details> <details> <summary> <b> Q5: </b> Every time I generate an image using the Python pipeline, loading all the Core ML models takes 2-3 minutes. Is this expected? </summary> <p dir="auto"><b> A5: </b> Both <code>.mlpackage</code> and <code>.mlmodelc</code> models are compiled (also known as "model preparation" in Core ML terms) upon first load when a specific compute unit is specified. <code>.mlpackage</code> does not cache this compiled asset so each model load retriggers this compilation which may take up to a few minutes. On the other hand, <code>.mlmodelc</code> files do cache this compiled asset and non-first load times are reduced to just a few seconds.</p> <p dir="auto">In order to benefit from compilation caching, you may use the <code>.mlmodelc</code> assets instead of <code>.mlpackage</code> assets in both Swift (default) and Python (possible thanks to <a href="https://github.com/lopez-hector">@lopez-hector</a>'s <a href="https://github.com/apple/ml-stable-diffusion/commit/f3a212491cf531dd88493c89ad3d98d016db407f">contribution</a>) image generation pipelines.</p> </details> <details> <summary> <b> <a name="user-content-q-mobile-app"></a> Q6: </b> I want to deploy <code>StableDiffusion</code>, the Swift package, in my mobile app. What should I be aware of? </summary> <p dir="auto"><b> A6: </b>The <a href="#image-gen-swift">Image Generation with Swift</a> section describes the minimum SDK and OS versions as well as the device models supported by this package. We recommend carefully testing the package on the device with the least amount of RAM available among your deployment targets.</p> <p dir="auto">The image generation process in <code>StableDiffusion</code> can yield over 2 GB of peak memory during runtime depending on the compute units selected. On iPadOS, we recommend using <code>.cpuAndNeuralEngine</code> in your configuration and the <code>reduceMemory</code> option when constructing a <code>StableDiffusionPipeline</code> to minimize memory pressure.</p> <p dir="auto">If your app crashes during image generation, consider adding the <a href="https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_kernel_increased-memory-limit" rel="nofollow">Increased Memory Limit</a> capability to inform the system that some of your app’s core features may perform better by exceeding the default app memory limit on supported devices.</p> <p dir="auto">On iOS, depending on the iPhone model, Stable Diffusion model versions, selected compute units, system load and design of your app, this may still not be sufficient to keep your apps peak memory under the limit. Please remember, because the device shares memory between apps and iOS processes, one app using too much memory can compromise the user experience across the whole device.</p> <p dir="auto">We <strong>strongly recommend</strong> compressing your models following the recipes in <a href="#compression-lower-than-6-bits">Advanced Weight Compression (Lower than 6-bits)</a> for iOS deployment. This reduces the peak RAM usage by up to 75% (from 16-bit to 4-bit) while preserving model output quality.</p> </details> <details> <summary> <b> Q7: </b> How do I generate images with different resolutions using the same Core ML models? </summary> <p dir="auto"><b> A7: </b> The current version of <code>python_coreml_stable_diffusion</code> does not support single-model multi-resolution out of the box. However, developers may fork this project and leverage the <a href="https://coremltools.readme.io/docs/flexible-inputs" rel="nofollow">flexible shapes</a> support from coremltools to extend the <code>torch2coreml</code> script by using <code>coremltools.EnumeratedShapes</code>. Note that, while the <code>text_encoder</code> is agnostic to the image resolution, the inputs and outputs of <code>vae_decoder</code> and <code>unet</code> models are dependent on the desired image resolution.</p> </details> <details> <summary> <b> Q8: </b> Are the Core ML and PyTorch generated images going to be identical? </summary> <p dir="auto"><b> A8: </b> If desired, the generated images across PyTorch and Core ML can be made approximately identical. However, it is not guaranteed by default. There are several factors that might lead to different images across PyTorch and Core ML:</p> <p dir="auto"><b> 1. Random Number Generator Behavior </b></p> <p dir="auto">The main source of potentially different results across PyTorch and Core ML is the Random Number Generator (<a href="https://en.wikipedia.org/wiki/Random_number_generation" rel="nofollow">RNG</a>) behavior. PyTorch and Numpy have different sources of randomness. <code>python_coreml_stable_diffusion</code> generally relies on Numpy for RNG (e.g. latents initialization) and <code>StableDiffusion</code> Swift Library reproduces this RNG behavior by default. However, PyTorch-based pipelines such as Hugging Face <code>diffusers</code> relies on PyTorch's RNG behavior. Thanks to @liuliu's <a href="https://github.com/apple/ml-stable-diffusion/pull/124" data-hovercard-type="pull_request" data-hovercard-url="/apple/ml-stable-diffusion/pull/124/hovercard">contributions</a>, one can match the PyTorch (CPU/GPU) RNG behavior in Swift by specifying <code>--rng torch/cuda</code> which selects the <code>torchRNG/cudaRNG</code> mode.</p> <p dir="auto"><b> 2. PyTorch </b></p> <p dir="auto"><em>"Completely reproducible results are not guaranteed across PyTorch releases, individual commits, or different platforms. Furthermore, results may not be reproducible between CPU and GPU executions, even when using identical seeds."</em> (<a href="https://pytorch.org/docs/stable/notes/randomness.html#reproducibility" rel="nofollow">source</a>).</p> <p dir="auto"><b> 3. Model Function Drift During Conversion </b></p> <p dir="auto">The difference in outputs across corresponding PyTorch and Core ML models is a potential cause. The signal integrity is tested during the conversion process (enabled via <code>--check-output-correctness</code> argument to <code>python_coreml_stable_diffusion.torch2coreml</code>) and it is verified to be above a minimum <a href="https://en.wikipedia.org/wiki/Peak_signal-to-noise_ratio" rel="nofollow">PSNR</a> value as tested on random inputs. Note that this is simply a sanity check and does not guarantee this minimum PSNR across all possible inputs. Furthermore, the results are not guaranteed to be identical when executing the same Core ML models across different compute units. This is not expected to be a major source of difference as the sample visual results indicate in <a href="#compression-6-bits-and-higher">this section</a>.</p> <p dir="auto"><b> 4. Weights and Activations Data Type </b></p> <p dir="auto">When quantizing models from float32 to lower-precision data types such as float16, the generated images are <a href="https://lambdalabs.com/blog/inference-benchmark-stable-diffusion" rel="nofollow">known to vary slightly</a> in semantics even when using the same PyTorch model. Core ML models generated by coremltools have float16 weights and activations by default <a href="https://github.com/apple/coremltools/blob/main/coremltools/converters/_converters_entry.py#L256">unless explicitly overridden</a>. This is not expected to be a major source of difference.</p> </details> <details> <summary> <b> Q9: </b> The model files are very large, how do I avoid a large binary for my App? </summary> <p dir="auto"><b> A9: </b> The recommended option is to prompt the user to download these assets upon first launch of the app. This keeps the app binary size independent of the Core ML models being deployed. Disclosing the size of the download to the user is extremely important as there could be data charges or storage impact that the user might not be comfortable with.</p> </details> <details> <summary> <b> Q10: </b> <code> `Could not initialize NNPACK! Reason: Unsupported hardware` </code> </summary> <p dir="auto"><b> A10: </b> This warning is safe to ignore in the context of this repository.</p> </details> <details> <summary> <b> Q11: </b> <code> TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect </code> </summary> <p dir="auto"><b> A11: </b> This warning is safe to ignore in the context of this repository.</p> </details> <details> <summary> <b> Q12: </b> <code> UserWarning: resource_tracker: There appear to be 1 leaked semaphore objects to clean up at shutdown </code> </summary> <p dir="auto"><b> A12: </b> If this warning is printed right after <code> zsh: killed python -m python_coreml_stable_diffusion.torch2coreml ... </code>, then it is highly likely that your Mac has run out of memory while converting models to Core ML. Please see <a href="#low-mem-conversion">Q3</a> from above for the solution.</p> </details> </details> <div class="markdown-heading" dir="auto"><h2 tabindex="-1" class="heading-element" dir="auto"><a name="user-content-bibtex"></a> BibTeX Reference</h2><a id="user-content--bibtex-reference" class="anchor" aria-label="Permalink: BibTeX Reference" href="#-bibtex-reference"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <div class="highlight highlight-text-tex-latex notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="@misc{stable-diffusion-coreml-apple-silicon, title = {Stable Diffusion with Core ML on Apple Silicon}, author = {Atila Orhon and Michael Siracusa and Aseem Wadhwa}, year = {2022}, URL = {null} }"><pre>@misc{stable-diffusion-coreml-apple-silicon, title = {Stable Diffusion with Core ML on Apple Silicon}, author = {Atila Orhon and Michael Siracusa and Aseem Wadhwa}, year = {2022}, URL = {null} }</pre></div> </article></div></div></div></div></div> <!-- --> <!-- --> <script type="application/json" id="__PRIMER_DATA_:R0:__">{"resolvedServerColorMode":"day"}</script></div> </react-partial> <input type="hidden" data-csrf="true" value="4u37hRPl5Ow/XQOGl9B8ln582MoBZXVWmV91d7g9CRdWxknLMS499FlzmBLPNH0oZXBEe/lCXptZrBvg9RI09Q==" /> </div> <div data-view-component="true" class="Layout-sidebar"> <div class="BorderGrid about-margin" data-pjax> <div class="BorderGrid-row"> <div class="BorderGrid-cell"> <div class="hide-sm hide-md"> <h2 class="mb-3 h4">About</h2> <p class="f4 my-3"> Stable Diffusion with Core ML on Apple Silicon </p> <h3 class="sr-only">Resources</h3> <div class="mt-2"> <a class="Link--muted" data-analytics-event="{&quot;category&quot;:&quot;Repository Overview&quot;,&quot;action&quot;:&quot;click&quot;,&quot;label&quot;:&quot;location:sidebar;file:readme&quot;}" href="#readme-ov-file"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-book mr-2"> <path d="M0 1.75A.75.75 0 0 1 .75 1h4.253c1.227 0 2.317.59 3 1.501A3.743 3.743 0 0 1 11.006 1h4.245a.75.75 0 0 1 .75.75v10.5a.75.75 0 0 1-.75.75h-4.507a2.25 2.25 0 0 0-1.591.659l-.622.621a.75.75 0 0 1-1.06 0l-.622-.621A2.25 2.25 0 0 0 5.258 13H.75a.75.75 0 0 1-.75-.75Zm7.251 10.324.004-5.073-.002-2.253A2.25 2.25 0 0 0 5.003 2.5H1.5v9h3.757a3.75 3.75 0 0 1 1.994.574ZM8.755 4.75l-.004 7.322a3.752 3.752 0 0 1 1.992-.572H14.5v-9h-3.495a2.25 2.25 0 0 0-2.25 2.25Z"></path> </svg> Readme </a> </div> <h3 class="sr-only">License</h3> <div class="mt-2"> <a href="#MIT-1-ov-file" class="Link--muted" data-analytics-event="{&quot;category&quot;:&quot;Repository Overview&quot;,&quot;action&quot;:&quot;click&quot;,&quot;label&quot;:&quot;location:sidebar;file:license&quot;}" > <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-law mr-2"> <path d="M8.75.75V2h.985c.304 0 .603.08.867.231l1.29.736c.038.022.08.033.124.033h2.234a.75.75 0 0 1 0 1.5h-.427l2.111 4.692a.75.75 0 0 1-.154.838l-.53-.53.529.531-.001.002-.002.002-.006.006-.006.005-.01.01-.045.04c-.21.176-.441.327-.686.45C14.556 10.78 13.88 11 13 11a4.498 4.498 0 0 1-2.023-.454 3.544 3.544 0 0 1-.686-.45l-.045-.04-.016-.015-.006-.006-.004-.004v-.001a.75.75 0 0 1-.154-.838L12.178 4.5h-.162c-.305 0-.604-.079-.868-.231l-1.29-.736a.245.245 0 0 0-.124-.033H8.75V13h2.5a.75.75 0 0 1 0 1.5h-6.5a.75.75 0 0 1 0-1.5h2.5V3.5h-.984a.245.245 0 0 0-.124.033l-1.289.737c-.265.15-.564.23-.869.23h-.162l2.112 4.692a.75.75 0 0 1-.154.838l-.53-.53.529.531-.001.002-.002.002-.006.006-.016.015-.045.04c-.21.176-.441.327-.686.45C4.556 10.78 3.88 11 3 11a4.498 4.498 0 0 1-2.023-.454 3.544 3.544 0 0 1-.686-.45l-.045-.04-.016-.015-.006-.006-.004-.004v-.001a.75.75 0 0 1-.154-.838L2.178 4.5H1.75a.75.75 0 0 1 0-1.5h2.234a.249.249 0 0 0 .125-.033l1.288-.737c.265-.15.564-.23.869-.23h.984V.75a.75.75 0 0 1 1.5 0Zm2.945 8.477c.285.135.718.273 1.305.273s1.02-.138 1.305-.273L13 6.327Zm-10 0c.285.135.718.273 1.305.273s1.02-.138 1.305-.273L3 6.327Z"></path> </svg> MIT license </a> </div> <h3 class="sr-only">Code of conduct</h3> <div class="mt-2"> <a href="#coc-ov-file" class="Link--muted" data-analytics-event="{&quot;category&quot;:&quot;Repository Overview&quot;,&quot;action&quot;:&quot;click&quot;,&quot;label&quot;:&quot;location:sidebar;file:code of conduct&quot;}" > <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-code-of-conduct mr-2"> <path d="M8.048 2.241c.964-.709 2.079-1.238 3.325-1.241a4.616 4.616 0 0 1 3.282 1.355c.41.408.757.86.996 1.428.238.568.348 1.206.347 1.968 0 2.193-1.505 4.254-3.081 5.862-1.496 1.526-3.213 2.796-4.249 3.563l-.22.163a.749.749 0 0 1-.895 0l-.221-.163c-1.036-.767-2.753-2.037-4.249-3.563C1.51 10.008.007 7.952.002 5.762a4.614 4.614 0 0 1 1.353-3.407C3.123.585 6.223.537 8.048 2.24Zm-1.153.983c-1.25-1.033-3.321-.967-4.48.191a3.115 3.115 0 0 0-.913 2.335c0 1.556 1.109 3.24 2.652 4.813C5.463 11.898 6.96 13.032 8 13.805c.353-.262.758-.565 1.191-.905l-1.326-1.223a.75.75 0 0 1 1.018-1.102l1.48 1.366c.328-.281.659-.577.984-.887L9.99 9.802a.75.75 0 1 1 1.019-1.103l1.384 1.28c.295-.329.566-.661.81-.995L12.92 8.7l-1.167-1.168c-.674-.671-1.78-.664-2.474.03-.268.269-.538.537-.802.797-.893.882-2.319.843-3.185-.032-.346-.35-.693-.697-1.043-1.047a.75.75 0 0 1-.04-1.016c.162-.191.336-.401.52-.623.62-.748 1.356-1.637 2.166-2.417Zm7.112 4.442c.313-.65.491-1.293.491-1.916v-.001c0-.614-.088-1.045-.23-1.385-.143-.339-.357-.633-.673-.949a3.111 3.111 0 0 0-2.218-.915c-1.092.003-2.165.627-3.226 1.602-.823.755-1.554 1.637-2.228 2.45l-.127.154.562.566a.755.755 0 0 0 1.066.02l.794-.79c1.258-1.258 3.312-1.31 4.594-.032.396.394.792.791 1.173 1.173Z"></path> </svg> Code of conduct </a> </div> <include-fragment src="/apple/ml-stable-diffusion/hovercards/citation/sidebar_partial?tree_name=main"> </include-fragment> <div class="mt-2"> <a href="/apple/ml-stable-diffusion/activity" data-view-component="true" class="Link Link--muted"><svg text="gray" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-pulse mr-2"> <path d="M6 2c.306 0 .582.187.696.471L10 10.731l1.304-3.26A.751.751 0 0 1 12 7h3.25a.75.75 0 0 1 0 1.5h-2.742l-1.812 4.528a.751.751 0 0 1-1.392 0L6 4.77 4.696 8.03A.75.75 0 0 1 4 8.5H.75a.75.75 0 0 1 0-1.5h2.742l1.812-4.529A.751.751 0 0 1 6 2Z"></path> </svg> <span class="color-fg-muted">Activity</span></a> </div> <div class="mt-2"> <a href="/apple/ml-stable-diffusion/custom-properties" data-view-component="true" class="Link Link--muted"><svg text="gray" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-note mr-2"> <path d="M0 3.75C0 2.784.784 2 1.75 2h12.5c.966 0 1.75.784 1.75 1.75v8.5A1.75 1.75 0 0 1 14.25 14H1.75A1.75 1.75 0 0 1 0 12.25Zm1.75-.25a.25.25 0 0 0-.25.25v8.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25v-8.5a.25.25 0 0 0-.25-.25ZM3.5 6.25a.75.75 0 0 1 .75-.75h7a.75.75 0 0 1 0 1.5h-7a.75.75 0 0 1-.75-.75Zm.75 2.25h4a.75.75 0 0 1 0 1.5h-4a.75.75 0 0 1 0-1.5Z"></path> </svg> <span class="color-fg-muted">Custom properties</span></a> </div> <h3 class="sr-only">Stars</h3> <div class="mt-2"> <a href="/apple/ml-stable-diffusion/stargazers" data-view-component="true" class="Link Link--muted"><svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-star mr-2"> <path d="M8 .25a.75.75 0 0 1 .673.418l1.882 3.815 4.21.612a.75.75 0 0 1 .416 1.279l-3.046 2.97.719 4.192a.751.751 0 0 1-1.088.791L8 12.347l-3.766 1.98a.75.75 0 0 1-1.088-.79l.72-4.194L.818 6.374a.75.75 0 0 1 .416-1.28l4.21-.611L7.327.668A.75.75 0 0 1 8 .25Zm0 2.445L6.615 5.5a.75.75 0 0 1-.564.41l-3.097.45 2.24 2.184a.75.75 0 0 1 .216.664l-.528 3.084 2.769-1.456a.75.75 0 0 1 .698 0l2.77 1.456-.53-3.084a.75.75 0 0 1 .216-.664l2.24-2.183-3.096-.45a.75.75 0 0 1-.564-.41L8 2.694Z"></path> </svg> <strong>17.2k</strong> stars</a> </div> <h3 class="sr-only">Watchers</h3> <div class="mt-2"> <a href="/apple/ml-stable-diffusion/watchers" data-view-component="true" class="Link Link--muted"><svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-eye mr-2"> <path d="M8 2c1.981 0 3.671.992 4.933 2.078 1.27 1.091 2.187 2.345 2.637 3.023a1.62 1.62 0 0 1 0 1.798c-.45.678-1.367 1.932-2.637 3.023C11.67 13.008 9.981 14 8 14c-1.981 0-3.671-.992-4.933-2.078C1.797 10.83.88 9.576.43 8.898a1.62 1.62 0 0 1 0-1.798c.45-.677 1.367-1.931 2.637-3.022C4.33 2.992 6.019 2 8 2ZM1.679 7.932a.12.12 0 0 0 0 .136c.411.622 1.241 1.75 2.366 2.717C5.176 11.758 6.527 12.5 8 12.5c1.473 0 2.825-.742 3.955-1.715 1.124-.967 1.954-2.096 2.366-2.717a.12.12 0 0 0 0-.136c-.412-.621-1.242-1.75-2.366-2.717C10.824 4.242 9.473 3.5 8 3.5c-1.473 0-2.825.742-3.955 1.715-1.124.967-1.954 2.096-2.366 2.717ZM8 10a2 2 0 1 1-.001-3.999A2 2 0 0 1 8 10Z"></path> </svg> <strong>141</strong> watching</a> </div> <h3 class="sr-only">Forks</h3> <div class="mt-2"> <a href="/apple/ml-stable-diffusion/forks" data-view-component="true" class="Link Link--muted"><svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo-forked mr-2"> <path d="M5 5.372v.878c0 .414.336.75.75.75h4.5a.75.75 0 0 0 .75-.75v-.878a2.25 2.25 0 1 1 1.5 0v.878a2.25 2.25 0 0 1-2.25 2.25h-1.5v2.128a2.251 2.251 0 1 1-1.5 0V8.5h-1.5A2.25 2.25 0 0 1 3.5 6.25v-.878a2.25 2.25 0 1 1 1.5 0ZM5 3.25a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Zm6.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm-3 8.75a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Z"></path> </svg> <strong>974</strong> forks</a> </div> <div class="mt-2"> <a class="Link--muted" href="/contact/report-content?content_url=https%3A%2F%2Fgithub.com%2Fapple%2Fml-stable-diffusion&amp;report=apple+%28user%29"> Report repository </a> </div> </div> </div> </div> <div class="BorderGrid-row"> <div class="BorderGrid-cell"> <h2 class="h4 mb-3" data-pjax="#repo-content-pjax-container" data-turbo-frame="repo-content-turbo-frame"> <a href="/apple/ml-stable-diffusion/releases" data-view-component="true" class="Link--primary no-underline Link">Releases <span title="7" data-view-component="true" class="Counter">7</span></a></h2> <a class="Link--primary d-flex no-underline" data-pjax="#repo-content-pjax-container" data-turbo-frame="repo-content-turbo-frame" href="/apple/ml-stable-diffusion/releases/tag/1.1.1"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-tag flex-shrink-0 mt-1 color-fg-success"> <path d="M1 7.775V2.75C1 1.784 1.784 1 2.75 1h5.025c.464 0 .91.184 1.238.513l6.25 6.25a1.75 1.75 0 0 1 0 2.474l-5.026 5.026a1.75 1.75 0 0 1-2.474 0l-6.25-6.25A1.752 1.752 0 0 1 1 7.775Zm1.5 0c0 .066.026.13.073.177l6.25 6.25a.25.25 0 0 0 .354 0l5.025-5.025a.25.25 0 0 0 0-.354l-6.25-6.25a.25.25 0 0 0-.177-.073H2.75a.25.25 0 0 0-.25.25ZM6 5a1 1 0 1 1 0 2 1 1 0 0 1 0-2Z"></path> </svg> <div class="ml-2 min-width-0"> <div class="d-flex"> <span class="css-truncate css-truncate-target text-bold mr-2" style="max-width: none;">1.1.1</span> <span title="Label: Latest" data-view-component="true" class="Label Label--success flex-shrink-0"> Latest </span> </div> <div class="text-small color-fg-muted"><relative-time datetime="2024-05-04T01:05:33Z" class="no-wrap">May 4, 2024</relative-time></div> </div> </a> <div data-view-component="true" class="mt-3"> <a text="small" data-pjax="#repo-content-pjax-container" data-turbo-frame="repo-content-turbo-frame" href="/apple/ml-stable-diffusion/releases" data-view-component="true" class="Link">+ 6 releases</a></div> </div> </div> <div class="BorderGrid-row"> <div class="BorderGrid-cell"> <h2 class="h4 mb-3"> <a href="/orgs/apple/packages?repo_name=ml-stable-diffusion" data-view-component="true" class="Link--primary no-underline Link d-flex flex-items-center">Packages <span title="0" hidden="hidden" data-view-component="true" class="Counter ml-1">0</span></a></h2> <div class="text-small color-fg-muted" > No packages published <br> </div> </div> </div> <div class="BorderGrid-row" hidden> <div class="BorderGrid-cell"> <include-fragment src="/apple/ml-stable-diffusion/used_by_list" accept="text/fragment+html"> </include-fragment> </div> </div> <div class="BorderGrid-row"> <div class="BorderGrid-cell"> <h2 class="h4 mb-3"> <a href="/apple/ml-stable-diffusion/graphs/contributors" data-view-component="true" class="Link--primary no-underline Link d-flex flex-items-center">Contributors <span title="42" data-view-component="true" class="Counter ml-1">42</span></a></h2> <ul class="list-style-none d-flex flex-wrap mb-n2"> <li class="mb-2 mr-2" > <a href="https://github.com/atiorh" class="" data-hovercard-type="user" data-hovercard-url="/users/atiorh/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" > <img src="https://avatars.githubusercontent.com/u/64497909?s=64&amp;v=4" alt="@atiorh" size="32" height="32" width="32" data-view-component="true" class="avatar circle" /> </a> </li> <li class="mb-2 mr-2" > <a href="https://github.com/TobyRoseman" class="" data-hovercard-type="user" data-hovercard-url="/users/TobyRoseman/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" > <img src="https://avatars.githubusercontent.com/u/5420744?s=64&amp;v=4" alt="@TobyRoseman" size="32" height="32" width="32" data-view-component="true" class="avatar circle" /> </a> </li> <li class="mb-2 mr-2" > <a href="https://github.com/pcuenca" class="" data-hovercard-type="user" data-hovercard-url="/users/pcuenca/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" > <img src="https://avatars.githubusercontent.com/u/1177582?s=64&amp;v=4" alt="@pcuenca" size="32" height="32" width="32" data-view-component="true" class="avatar circle" /> </a> </li> <li class="mb-2 mr-2" > <a href="https://github.com/msiracusa" class="" data-hovercard-type="user" data-hovercard-url="/users/msiracusa/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" > <img src="https://avatars.githubusercontent.com/u/6166296?s=64&amp;v=4" alt="@msiracusa" size="32" height="32" width="32" data-view-component="true" class="avatar circle" /> </a> </li> <li class="mb-2 mr-2" > <a href="https://github.com/ZachNagengast" class="" data-hovercard-type="user" data-hovercard-url="/users/ZachNagengast/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" > <img src="https://avatars.githubusercontent.com/u/1981179?s=64&amp;v=4" alt="@ZachNagengast" size="32" height="32" width="32" data-view-component="true" class="avatar circle" /> </a> </li> <li class="mb-2 mr-2" > <a href="https://github.com/alejandro-isaza" class="" data-hovercard-type="user" data-hovercard-url="/users/alejandro-isaza/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" > <img src="https://avatars.githubusercontent.com/u/167236?s=64&amp;v=4" alt="@alejandro-isaza" size="32" height="32" width="32" data-view-component="true" class="avatar circle" /> </a> </li> <li class="mb-2 mr-2" > <a href="https://github.com/vzsg" class="" data-hovercard-type="user" data-hovercard-url="/users/vzsg/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" > <img src="https://avatars.githubusercontent.com/u/1783465?s=64&amp;v=4" alt="@vzsg" size="32" height="32" width="32" data-view-component="true" class="avatar circle" /> </a> </li> <li class="mb-2 mr-2" > <a href="https://github.com/liuliu" class="" data-hovercard-type="user" data-hovercard-url="/users/liuliu/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" > <img src="https://avatars.githubusercontent.com/u/127987?s=64&amp;v=4" alt="@liuliu" size="32" height="32" width="32" data-view-component="true" class="avatar circle" /> </a> </li> <li class="mb-2 mr-2" > <a href="https://github.com/Wanaldino" class="" data-hovercard-type="user" data-hovercard-url="/users/Wanaldino/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" > <img src="https://avatars.githubusercontent.com/u/14272739?s=64&amp;v=4" alt="@Wanaldino" size="32" height="32" width="32" data-view-component="true" class="avatar circle" /> </a> </li> <li class="mb-2 mr-2" > <a href="https://github.com/jakesabathia2" class="" data-hovercard-type="user" data-hovercard-url="/users/jakesabathia2/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" > <img src="https://avatars.githubusercontent.com/u/55294647?s=64&amp;v=4" alt="@jakesabathia2" size="32" height="32" width="32" data-view-component="true" class="avatar circle" /> </a> </li> <li class="mb-2 mr-2" > <a href="https://github.com/stuartjmoore" class="" data-hovercard-type="user" data-hovercard-url="/users/stuartjmoore/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" > <img src="https://avatars.githubusercontent.com/u/642708?s=64&amp;v=4" alt="@stuartjmoore" size="32" height="32" width="32" data-view-component="true" class="avatar circle" /> </a> </li> <li class="mb-2 mr-2" > <a href="https://github.com/littleowl" class="" data-hovercard-type="user" data-hovercard-url="/users/littleowl/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" > <img src="https://avatars.githubusercontent.com/u/1063337?s=64&amp;v=4" alt="@littleowl" size="32" height="32" width="32" data-view-component="true" class="avatar circle" /> </a> </li> <li class="mb-2 mr-2" > <a href="https://github.com/godly-devotion" class="" data-hovercard-type="user" data-hovercard-url="/users/godly-devotion/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" > <img src="https://avatars.githubusercontent.com/u/1341760?s=64&amp;v=4" alt="@godly-devotion" size="32" height="32" width="32" data-view-component="true" class="avatar circle" /> </a> </li> <li class="mb-2 mr-2" > <a href="https://github.com/cclauss" class="" data-hovercard-type="user" data-hovercard-url="/users/cclauss/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" > <img src="https://avatars.githubusercontent.com/u/3709715?s=64&amp;v=4" alt="@cclauss" size="32" height="32" width="32" data-view-component="true" class="avatar circle" /> </a> </li> </ul> <div data-view-component="true" class="mt-3"> <a text="small" href="/apple/ml-stable-diffusion/graphs/contributors" data-view-component="true" class="Link--inTextBlock Link">+ 28 contributors</a></div> </div> </div> <div class="BorderGrid-row"> <div class="BorderGrid-cell"> <h2 class="h4 mb-3">Languages</h2> <div class="mb-2"> <span data-view-component="true" class="Progress"> <span style="background-color:#3572A5 !important;;width: 55.3%;" itemprop="keywords" data-view-component="true" class="Progress-item color-bg-success-emphasis"></span> <span style="background-color:#F05138 !important;;width: 44.7%;" itemprop="keywords" data-view-component="true" class="Progress-item color-bg-success-emphasis"></span> </span></div> <ul class="list-style-none"> <li class="d-inline"> <a class="d-inline-flex flex-items-center flex-nowrap Link--secondary no-underline text-small mr-3" href="/apple/ml-stable-diffusion/search?l=python" data-ga-click="Repository, language stats search click, location:repo overview"> <svg style="color:#3572A5;" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-dot-fill mr-2"> <path d="M8 4a4 4 0 1 1 0 8 4 4 0 0 1 0-8Z"></path> </svg> <span class="color-fg-default text-bold mr-1">Python</span> <span>55.3%</span> </a> </li> <li class="d-inline"> <a class="d-inline-flex flex-items-center flex-nowrap Link--secondary no-underline text-small mr-3" href="/apple/ml-stable-diffusion/search?l=swift" data-ga-click="Repository, language stats search click, location:repo overview"> <svg style="color:#F05138;" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-dot-fill mr-2"> <path d="M8 4a4 4 0 1 1 0 8 4 4 0 0 1 0-8Z"></path> </svg> <span class="color-fg-default text-bold mr-1">Swift</span> <span>44.7%</span> </a> </li> </ul> </div> </div> </div> </div> </div></div> </div> </div> </turbo-frame> </main> </div> </div> <footer class="footer pt-8 pb-6 f6 color-fg-muted p-responsive" role="contentinfo" > <h2 class='sr-only'>Footer</h2> <div class="d-flex flex-justify-center flex-items-center flex-column-reverse flex-lg-row flex-wrap flex-lg-nowrap"> <div class="d-flex flex-items-center flex-shrink-0 mx-2"> <a aria-label="Homepage" title="GitHub" class="footer-octicon mr-2" href="https://github.com"> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-mark-github"> <path d="M12 1C5.9225 1 1 5.9225 1 12C1 16.8675 4.14875 20.9787 8.52125 22.4362C9.07125 22.5325 9.2775 22.2025 9.2775 21.9137C9.2775 21.6525 9.26375 20.7862 9.26375 19.865C6.5 20.3737 5.785 19.1912 5.565 18.5725C5.44125 18.2562 4.905 17.28 4.4375 17.0187C4.0525 16.8125 3.5025 16.3037 4.42375 16.29C5.29 16.2762 5.90875 17.0875 6.115 17.4175C7.105 19.0812 8.68625 18.6137 9.31875 18.325C9.415 17.61 9.70375 17.1287 10.02 16.8537C7.5725 16.5787 5.015 15.63 5.015 11.4225C5.015 10.2262 5.44125 9.23625 6.1425 8.46625C6.0325 8.19125 5.6475 7.06375 6.2525 5.55125C6.2525 5.55125 7.17375 5.2625 9.2775 6.67875C10.1575 6.43125 11.0925 6.3075 12.0275 6.3075C12.9625 6.3075 13.8975 6.43125 14.7775 6.67875C16.8813 5.24875 17.8025 5.55125 17.8025 5.55125C18.4075 7.06375 18.0225 8.19125 17.9125 8.46625C18.6138 9.23625 19.04 10.2125 19.04 11.4225C19.04 15.6437 16.4688 16.5787 14.0213 16.8537C14.42 17.1975 14.7638 17.8575 14.7638 18.8887C14.7638 20.36 14.75 21.5425 14.75 21.9137C14.75 22.2025 14.9563 22.5462 15.5063 22.4362C19.8513 20.9787 23 16.8537 23 12C23 5.9225 18.0775 1 12 1Z"></path> </svg> </a> <span> &copy; 2025 GitHub,&nbsp;Inc. </span> </div> <nav aria-label="Footer"> <h3 class="sr-only" id="sr-footer-heading">Footer navigation</h3> <ul class="list-style-none d-flex flex-justify-center flex-wrap mb-2 mb-lg-0" aria-labelledby="sr-footer-heading"> <li class="mx-2"> <a data-analytics-event="{&quot;category&quot;:&quot;Footer&quot;,&quot;action&quot;:&quot;go to Terms&quot;,&quot;label&quot;:&quot;text:terms&quot;}" href="https://docs.github.com/site-policy/github-terms/github-terms-of-service" data-view-component="true" class="Link--secondary Link">Terms</a> </li> <li class="mx-2"> <a data-analytics-event="{&quot;category&quot;:&quot;Footer&quot;,&quot;action&quot;:&quot;go to privacy&quot;,&quot;label&quot;:&quot;text:privacy&quot;}" href="https://docs.github.com/site-policy/privacy-policies/github-privacy-statement" data-view-component="true" class="Link--secondary Link">Privacy</a> </li> <li class="mx-2"> <a data-analytics-event="{&quot;category&quot;:&quot;Footer&quot;,&quot;action&quot;:&quot;go to security&quot;,&quot;label&quot;:&quot;text:security&quot;}" href="https://github.com/security" data-view-component="true" class="Link--secondary Link">Security</a> </li> <li class="mx-2"> <a data-analytics-event="{&quot;category&quot;:&quot;Footer&quot;,&quot;action&quot;:&quot;go to status&quot;,&quot;label&quot;:&quot;text:status&quot;}" href="https://www.githubstatus.com/" data-view-component="true" class="Link--secondary Link">Status</a> </li> <li class="mx-2"> <a data-analytics-event="{&quot;category&quot;:&quot;Footer&quot;,&quot;action&quot;:&quot;go to docs&quot;,&quot;label&quot;:&quot;text:docs&quot;}" href="https://docs.github.com/" data-view-component="true" class="Link--secondary Link">Docs</a> </li> <li class="mx-2"> <a data-analytics-event="{&quot;category&quot;:&quot;Footer&quot;,&quot;action&quot;:&quot;go to contact&quot;,&quot;label&quot;:&quot;text:contact&quot;}" href="https://support.github.com?tags=dotcom-footer" data-view-component="true" class="Link--secondary Link">Contact</a> </li> <li class="mx-2" > <cookie-consent-link> <button type="button" class="Link--secondary underline-on-hover border-0 p-0 color-bg-transparent" data-action="click:cookie-consent-link#showConsentManagement" data-analytics-event="{&quot;location&quot;:&quot;footer&quot;,&quot;action&quot;:&quot;cookies&quot;,&quot;context&quot;:&quot;subfooter&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;cookies_link_subfooter_footer&quot;}" > Manage cookies </button> </cookie-consent-link> </li> <li class="mx-2"> <cookie-consent-link> <button type="button" class="Link--secondary underline-on-hover border-0 p-0 color-bg-transparent" data-action="click:cookie-consent-link#showConsentManagement" data-analytics-event="{&quot;location&quot;:&quot;footer&quot;,&quot;action&quot;:&quot;dont_share_info&quot;,&quot;context&quot;:&quot;subfooter&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;dont_share_info_link_subfooter_footer&quot;}" > Do not share my personal information </button> </cookie-consent-link> </li> </ul> </nav> </div> </footer> <ghcc-consent id="ghcc" class="position-fixed bottom-0 left-0" style="z-index: 999999" data-initial-cookie-consent-allowed="" data-cookie-consent-required="false"></ghcc-consent> <div id="ajax-error-message" class="ajax-error-message flash flash-error" hidden> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert"> <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path> </svg> <button type="button" class="flash-close js-ajax-error-dismiss" aria-label="Dismiss error"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path> </svg> </button> You can’t perform that action at this time. </div> <template id="site-details-dialog"> <details class="details-reset details-overlay details-overlay-dark lh-default color-fg-default hx_rsm" open> <summary role="button" aria-label="Close dialog"></summary> <details-dialog class="Box Box--overlay d-flex flex-column anim-fade-in fast hx_rsm-dialog hx_rsm-modal"> <button class="Box-btn-octicon m-0 btn-octicon position-absolute right-0 top-0" type="button" aria-label="Close dialog" data-close-dialog> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path> </svg> </button> <div class="octocat-spinner my-6 js-details-dialog-spinner"></div> </details-dialog> </details> </template> <div class="Popover js-hovercard-content position-absolute" style="display: none; outline: none;"> <div class="Popover-message Popover-message--bottom-left Popover-message--large Box color-shadow-large" style="width:360px;"> </div> </div> <template id="snippet-clipboard-copy-button"> <div class="zeroclipboard-container position-absolute right-0 top-0"> <clipboard-copy aria-label="Copy" class="ClipboardButton btn js-clipboard-copy m-2 p-0" data-copy-feedback="Copied!" data-tooltip-direction="w"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-copy js-clipboard-copy-icon m-2"> <path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z"></path><path d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z"></path> </svg> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-check js-clipboard-check-icon color-fg-success d-none m-2"> <path d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z"></path> </svg> </clipboard-copy> </div> </template> <template id="snippet-clipboard-copy-button-unpositioned"> <div class="zeroclipboard-container"> <clipboard-copy aria-label="Copy" class="ClipboardButton btn btn-invisible js-clipboard-copy m-2 p-0 d-flex flex-justify-center flex-items-center" data-copy-feedback="Copied!" data-tooltip-direction="w"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-copy js-clipboard-copy-icon"> <path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z"></path><path d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z"></path> </svg> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-check js-clipboard-check-icon color-fg-success d-none"> <path d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z"></path> </svg> </clipboard-copy> </div> </template> </div> <div id="js-global-screen-reader-notice" class="sr-only mt-n1" aria-live="polite" aria-atomic="true" ></div> <div id="js-global-screen-reader-notice-assertive" class="sr-only mt-n1" aria-live="assertive" aria-atomic="true"></div> </body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10