{"id":377162,"date":"2024-05-26T21:00:33","date_gmt":"2024-05-26T21:00:33","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=377162"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=377162","title":{"rendered":"<span>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c StableDiffusionXl \u043d\u0430 Nvidia \u0432\u0438\u0434\u0435\u043e\u043a\u0430\u0440\u0442\u0430\u0445 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e python<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u043e\u0441\u0442\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438 StableDiffusion, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0442\u044b\u0441\u044f\u0447\u0438 \u0438\u0445 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u0445 \u0441 <a href=\"https:\/\/civitai.com\/\" rel=\"noopener noreferrer nofollow\">civitai.com<\/a><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/ebe\/6b2\/11c\/ebe6b211c6288885aa97256a662186e1.jpeg\" alt=\"\u0420\u0430\u0431\u043e\u0442\u0430 SDXL\" title=\"\u0420\u0430\u0431\u043e\u0442\u0430 SDXL\" width=\"1600\" height=\"1067\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ebe\/6b2\/11c\/ebe6b211c6288885aa97256a662186e1.jpeg\" data-blurred=\"true\"\/><\/p>\n<div><figcaption>\u0420\u0430\u0431\u043e\u0442\u0430 SDXL<\/figcaption><\/div>\n<\/figure>\n<h2>\u041f\u0440\u0435\u0434\u0438\u0441\u043b\u043e\u0432\u0438\u0435<\/h2>\n<p>\u0412 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u0435\u0441\u0442\u044c \u0443\u0436\u0435 \u043c\u043d\u043e\u0433\u043e \u0433\u0430\u0439\u0434\u043e\u0432, \u043f\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0443 \u043c\u043e\u0434\u0435\u043b\u0435\u0439. \u041f\u043e\u0447\u0435\u043c\u0443 \u0435\u0449\u0435 \u043e\u0434\u043d\u0430 \u0441\u0442\u0430\u0442\u044c\u044f?<\/p>\n<p>\u0422\u0443\u0442, \u044f \u0431\u044b \u0445\u043e\u0442\u0435\u043b \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a \u043c\u043e\u0434\u0435\u043b\u0435\u0439, \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0434 Nvidia \u0432\u0438\u0434\u0435\u043e\u043a\u0430\u0440\u0442\u044b, \u0447\u0442\u043e \u0434\u0430\u0441\u0442 \u0432\u0430\u043c \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u0431\u0443\u0441\u0442 \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u044f \u0445\u043e\u0447\u0443 \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043f\u043e\u0441\u043e\u0431, \u043a\u0430\u043a \u0441\u043a\u0430\u0440\u043c\u043b\u0438\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u043f\u0440\u043e\u043c\u043f\u0442\u044b \u0432\u0430\u0448\u0438\u043c \u043c\u043e\u0434\u0435\u043b\u044f\u043c. \u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u043f\u0440\u043e\u043c\u043f\u0442 \u0434\u043b\u044f SD \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c 75 \u0442\u043e\u043a\u0435\u043d\u043e\u0432.<\/p>\n<p>\u041f\u0435\u0440\u0435\u0434 \u0441\u0442\u0430\u0440\u0442\u043e\u043c, \u0432\u0430\u0436\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u0443 \u0432\u0430\u0441 \u0441\u0442\u043e\u044f\u043b \u043d\u0430 \u0440\u0430\u0431\u043e\u0447\u0435\u0439 \u0441\u0442\u0430\u043d\u0446\u0438\u0438 <a href=\"https:\/\/www.docker.com\/products\/docker-desktop\/\" rel=\"noopener noreferrer nofollow\">Docker<\/a> \u0432\u044b\u0448\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 19.03, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u043e\u0442 Nvidia \u0434\u043b\u044f \u0432\u0430\u0448\u0435\u0439 \u0432\u0438\u0434\u0435\u043e\u043a\u0430\u0440\u0442\u044b. Cuda \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0448\u0442\u0443\u043a\u0438 \u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e.<\/p>\n<p><strong>\u041f\u043e\u0447\u0435\u043c\u0443 Docker?<\/strong> <\/p>\n<p>\u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0437 \u043e\u0442 Nvidia \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0438\u0442\u043e\u043d\u0430, pytorch \u0438 jupyter, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u0438 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u0438\u0434\u0435\u043e\u043a\u0430\u0440\u0442, \u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 \u0431\u044d\u043a\u0435\u043d\u0434\u043e\u0432, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0445 Nvidia. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u043e\u043a, \u043d\u043e \u0438 \u043d\u0435 \u0437\u0430\u0441\u043e\u0440\u044f\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u043c\u0438 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430\u043c\u0438 \u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438, \u043f\u043e \u0442\u0438\u043f\u0443 CUDA.<\/p>\n<h2>\u041d\u0430\u0447\u043d\u0435\u043c<\/h2>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u0439\u0442\u0438 \u043d\u0430 <a href=\"https:\/\/catalog.ngc.nvidia.com\/orgs\/nvidia\/containers\/pytorch\/tags\" rel=\"noopener noreferrer nofollow\">\u0441\u0430\u0439\u0442 \u0441 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u043e\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u0432 nvidia \u0434\u043b\u044f pytorch<\/a>.<\/p>\n<p>\u041d\u0430\u0445\u043e\u0434\u0438\u043c \u0442\u0430\u043c \u0441\u0430\u043c\u044b\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043e\u0431\u0440\u0430\u0437 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0438\u043c\u0435\u043d\u043d\u043e \u0435\u0433\u043e. \u041d\u0430 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0441\u0430\u043c\u044b\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043e\u0431\u0440\u0430\u0437 &#8212; \u044d\u0442\u043e <a href=\"http:\/\/nvcr.io\/nvidia\/pytorch:24.05-py3\" rel=\"noopener noreferrer nofollow\">nvcr.io\/nvidia\/pytorch:24.05-py3<\/a>. \u044f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u0435\u0433\u043e.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0430\u043f\u043a\u0443, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c\u0441\u044f jupyter, \u0432 \u044d\u0442\u043e\u0439 \u043f\u0430\u043f\u043a\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438, lora, \u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043d\u0430\u0448\u0438\u0445 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0439, \u0435\u0441\u043b\u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u043b\u0438? \u0412 \u043c\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u044f \u0441\u043e\u0437\u0434\u0430\u043b \u043f\u0430\u043f\u043a\u0443 jupyter \u043d\u0430 \u0434\u0438\u0441\u043a\u0435 D. \u0423 \u0432\u0430\u0441 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u0443\u0442\u044c, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u041e\u0421 \u0438 \u0432\u043e\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0437\u0430\u043f\u0443\u0441\u043a\u0443 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430:<\/p>\n<pre><code class=\"bash\">docker run --gpus all -it --name=pytorch -p 8888:8888 -v D:\\jupyter:\/jupyter-data --ipc=host nvcr.io\/nvidia\/pytorch:24.05-py3 jupyter notebook --ip 0.0.0.0 --notebook-dir=\"\/jupyter-data\"<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0438\u043c \u043d\u0435\u0445\u0438\u0442\u0440\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c, \u043c\u044b \u043f\u043e\u0434\u043d\u044f\u043b\u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0441 jupyter, \u0432\u043a\u043b\u044e\u0447\u0438\u043b\u0438 \u0442\u0430\u043c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 gpu \u0438 \u043f\u0440\u043e\u0431\u0440\u043e\u0441\u0438\u043b\u0438 \u043f\u043e\u0440\u0442 8888 \u043d\u0430\u0440\u0443\u0436\u0443, \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0446\u0435\u043f\u043b\u044f\u0442\u044c\u0441\u044f \u043a \u043d\u0435\u043c\u0443 \u0447\u0435\u0440\u0435\u0437 IDE \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435. \u0422\u043e\u043a\u0435\u043d \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0432 jupyter \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0437 stdout \u0432\u0430\u0448\u0435\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430. \u041d\u0430\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0435\u0433\u043e \u043d\u0430 \u043f\u0430\u0440\u043e\u043b\u044c, \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0438. \u041d\u043e \u044d\u0442\u043e \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e.<\/p>\n<h2>\u0421\u0442\u0430\u0432\u0438\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438<\/h2>\n<p>\u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0432\u0435\u0431 \u0432\u0435\u0440\u0441\u0438\u044e Jupyter \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 127.0.0.1:8888, \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0443\u0435\u043c\u0441\u044f \u0438 \u0432\u0438\u0434\u0438\u043c \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0445\u043e\u0436\u0435\u0435 \u043d\u0430 \u044d\u0442\u043e\u0442 \u044d\u043a\u0440\u0430\u043d:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/333\/1c0\/686\/3331c06860f04b0011ad1f5c94827f2d.png\" alt=\"\u0421\u0442\u0430\u0440\u0442\u043e\u0432\u044b\u0439 \u044d\u043a\u0440\u0430\u043d Jupyter. \u0415\u0441\u043b\u0438 \u0432\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0447\u0430\u043b\u0438, \u0442\u043e \u0432\u0430\u0448 \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0443\u0441\u0442.\" title=\"\u0421\u0442\u0430\u0440\u0442\u043e\u0432\u044b\u0439 \u044d\u043a\u0440\u0430\u043d Jupyter. \u0415\u0441\u043b\u0438 \u0432\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0447\u0430\u043b\u0438, \u0442\u043e \u0432\u0430\u0448 \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0443\u0441\u0442.\" width=\"2382\" height=\"832\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/333\/1c0\/686\/3331c06860f04b0011ad1f5c94827f2d.png\"\/><\/p>\n<div><figcaption>\u0421\u0442\u0430\u0440\u0442\u043e\u0432\u044b\u0439 \u044d\u043a\u0440\u0430\u043d Jupyter. \u0415\u0441\u043b\u0438 \u0432\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0447\u0430\u043b\u0438, \u0442\u043e \u0432\u0430\u0448 \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0443\u0441\u0442.<\/figcaption><\/div>\n<\/figure>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0430\u043f\u043a\u0443 lora, \u0447\u0435\u0440\u0435\u0437 \u043a\u043d\u043e\u043f\u043a\u0443 New. \u0418\u043b\u0438 \u0436\u0435 \u043d\u0430\u0437\u043e\u0432\u0438\u0442\u0435 \u043a\u0430\u043a \u0445\u043e\u0442\u0438\u0442\u0435. \u0412\u043d\u0443\u0442\u0440\u0438 \u044d\u0442\u043e\u0439 \u043f\u0430\u043f\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u0431\u043b\u043e\u043a\u043d\u043e\u0442. <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d71\/81e\/af6\/d7181eaf668df1c342c232f8e889a3b3.png\" alt=\"\u0411\u043b\u043e\u043a\u043d\u043e\u0442 ipykernel\" title=\"\u0411\u043b\u043e\u043a\u043d\u043e\u0442 ipykernel\" width=\"726\" height=\"436\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d71\/81e\/af6\/d7181eaf668df1c342c232f8e889a3b3.png\"\/><\/p>\n<div><figcaption>\u0411\u043b\u043e\u043a\u043d\u043e\u0442 ipykernel<\/figcaption><\/div>\n<\/figure>\n<p>\u041e\u0442\u043a\u0440\u043e\u0435\u043c \u043d\u0430\u0448 \u0431\u043b\u043e\u043a\u043d\u043e\u0442 \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438<\/p>\n<pre><code class=\"python\">!pip install diffusers transformers accelerate safetensors ipywidgets compel peft --upgrade<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u044f\u0447\u0435\u0439\u043a\u0438 \u043d\u0430\u0434\u043e \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u044f\u0434\u0440\u043e.<\/p>\n<h2>\u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c<\/h2>\n<pre><code class=\"python\">from diffusers import (     StableDiffusionXLPipeline,     EulerAncestralDiscreteScheduler,     AutoencoderKL ) import torch  CHECKPOINT_NAME = 'stabilityai\/stable-diffusion-xl-base-1.0'  torch.backends.cuda.matmul.allow_tf32 = True  # Load VAE component  vae = vae = AutoencoderKL.from_pretrained(\"stabilityai\/sdxl-vae\", torch_dtype=torch.float16)  # Configure the pipeline pipe = StableDiffusionXLPipeline.from_pretrained(     CHECKPOINT_NAME,     vae=vae,     torch_dtype=torch.float16, ) pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(     pipe.scheduler.config, ) pipe.to('cuda')  # \u041e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0446\u0435\u043d\u0437\u0443\u0440\u044b pipe.safety_checker = None pipe.requires_safety_checker = False<\/code><\/pre>\n<p>\u0418\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u044f\u0447\u0435\u0439\u043a\u0443 \u0438 \u0436\u0434\u0435\u043c, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0448\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u0441\u044f. <\/p>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<p>\u041d\u0435 \u0442\u0430\u043a \u0434\u0430\u0432\u043d\u043e, huggingface <a href=\"https:\/\/github.com\/huggingface\/peft\/issues\/1199\" rel=\"noopener noreferrer nofollow\">\u0441\u043b\u043e\u043c\u0430\u043b\u0438<\/a> torch \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044e \u043c\u043e\u0434\u0435\u043b\u0438. \u041a\u043e\u0433\u0434\u0430 \u043f\u043e\u0447\u0438\u043d\u044f\u0442, \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u0443 \u0441\u0442\u0440\u043e\u0447\u043a\u0443 \u0434\u043b\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<pre><code class=\"python\">pipe.unet = torch.compile(pipe.unet, mode=\"reduce-overhead\", fullgraph=True)<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<h2>\u0413\u043e\u0442\u043e\u0432\u0438\u043c Compel<\/h2>\n<p>Compel &#8212; \u044d\u0442\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 &#171;\u043f\u0435\u0440\u0435\u0432\u0437\u0432\u0435\u0441\u0438\u0442\u044c&#187; \u0432\u0435\u0441\u0430 \u0438\u0437 \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u043c\u043f\u0442\u0430, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0447\u0435\u043c\u0443, \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0441\u0443\u043d\u0443\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0442\u0435\u043a\u0441\u0442 \u0432 \u043f\u0440\u043e\u043c\u043f\u0442 \u0432\u0430\u0448\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u0438, \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u044f \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0432 75 \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u0443 SD \u043c\u043e\u0434\u0435\u043b\u0435\u0439.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043d\u043e\u0432\u0443\u044e \u044f\u0447\u0435\u0439\u043a\u0443:<\/p>\n<pre><code class=\"python\">from compel import Compel, ReturnedEmbeddingsType  compel = Compel(tokenizer=[pipe.tokenizer, pipe.tokenizer_2], text_encoder=[pipe.text_encoder, pipe.text_encoder_2],                 returned_embeddings_type=ReturnedEmbeddingsType.PENULTIMATE_HIDDEN_STATES_NON_NORMALIZED,                 requires_pooled=[False, True])<\/code><\/pre>\n<h2>\u0413\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443<\/h2>\n<p>\u0412 \u043d\u043e\u0432\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0435 \u043f\u0438\u0448\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043a\u043e\u0434 \u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0435\u0433\u043e.<\/p>\n<pre><code class=\"python\">from IPython.display import display  pos = '' # \u043f\u043e\u0437\u0438\u0442\u0438\u0432\u043d\u044b\u0439 \u043f\u0440\u043e\u043c\u043f\u0442 neg = '' # \u043d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u043f\u0440\u043e\u043c\u043f\u0442  conditioning, pooled = compel(pos) negative_embed, negative_pooled = compel(neg) [conditioning, negative_embed] = compel.pad_conditioning_tensors_to_same_length([conditioning, negative_embed])  img = pipe(     prompt_embeds=conditioning,     pooled_prompt_embeds=pooled,     negative_prompt_embeds=negative_embed,     negative_pooled_prompt_embeds=negative_pooled,     num_inference_steps=40,     guidance_scale=7, #     num_images_per_prompt=10 # \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0430\u0440\u0442\u0438\u043d\u043e\u043a \u0437\u0430 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e )  for image in img[0]:     display(image)<\/code><\/pre>\n<p>\u0413\u043e\u0442\u043e\u0432\u043e, \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u043e\u043a \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e StableDiffusionXL. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u0430\u043c\u044b\u0435 \u0440\u0430\u0437\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <code>CHECKPOINT_NAME<\/code> \u0438 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u0421\u043f\u0438\u0441\u043e\u043a \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043d\u0430 <a href=\"https:\/\/huggingface.co\/\" rel=\"noopener noreferrer nofollow\">https:\/\/huggingface.co\/<\/a> <\/p>\n<h2>\u0413\u0440\u0443\u0437\u0438\u043c \u043c\u043e\u0434\u0435\u043b\u0438 \u0441 CivitAi<\/h2>\n<p>\u041d\u0430 <a href=\"https:\/\/civitai.com\/\" rel=\"noopener noreferrer nofollow\">\u0434\u0430\u043d\u043d\u043e\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u0435<\/a> \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0442\u044b\u0441\u044f\u0447\u0438 fine tune SD \u043c\u043e\u0434\u0435\u043b\u0435\u0439, \u043d\u0430 \u043b\u044e\u0431\u043e\u0439 \u0432\u043a\u0443\u0441 \u0438 \u0446\u0432\u0435\u0442. \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0441 huggingface \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e.<\/p>\n<p><strong>Checkpoints<\/strong><\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u043e\u0434\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u0438\u0437 \u0447\u0435\u043a\u043f\u043e\u0438\u043d\u0442\u0430, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u043d\u0430\u0448\u0443 \u043b\u043e\u0433\u0438\u043a\u0443 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043c\u043e\u0434\u0435\u043b\u0438, \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c <code>StableDiffusionXLPipeline.from_pretrained<\/code> \u043d\u0430 <code>StableDiffusionXLPipeline.from_single_file<\/code><\/p>\n<pre><code class=\"python\">CHECKPOINT_NAME = 'my_sdxl_model.safetensors' pipe = StableDiffusionXLPipeline.from_single_file(     CHECKPOINT_NAME,     vae=vae,     torch_dtype=torch.float16, )<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u044d\u0442\u043e\u043c <code>CHECKPOINT_NAME<\/code> \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c \u043d\u0430 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u0441\u043a\u0430\u0447\u0430\u043b\u0438 \u0441 civitai.<\/p>\n<p><strong>Lora<\/strong><\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c lora \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0435\u0435 \u0438 \u0432 \u043d\u043e\u0432\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u043a \u043d\u0430\u0448\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u0438<\/p>\n<pre><code class=\"python\">pipe.load_lora_weights('.\/', weight_name='lora_name.safetensors')<\/code><\/pre>\n<h2>\u0427\u0442\u043e \u0434\u0430\u043b\u044c\u0448\u0435?<\/h2>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043d\u0430\u0443\u0447\u0438\u043b\u0438\u0441\u044c \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438, \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u043a \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u043c. \u0418\u0433\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u043c\u043e\u0434\u0435\u043b\u044f\u043c\u0438, lora, \u043c\u0435\u043d\u044f\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b <code>num_inference_steps<\/code> \u0438 <code>guidance_scale<\/code>, \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0439 <code>pipe.scheduler<\/code>. \u0418 \u043c\u043d\u043e\u0433\u043e \u0447\u0435\u0433\u043e \u0435\u0449\u0435.<\/p>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u0432\u0441\u0435. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0434\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u043e\u0439\u0442\u0438 \u0432\u0430\u043c \u0442\u0435 \u0433\u0440\u0430\u0431\u043b\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u043f\u043e \u043f\u0443\u0442\u0438.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/817175\/\"> https:\/\/habr.com\/ru\/articles\/817175\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u043e\u0441\u0442\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438 StableDiffusion, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0442\u044b\u0441\u044f\u0447\u0438 \u0438\u0445 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u0445 \u0441 <a href=\"https:\/\/civitai.com\/\" rel=\"noopener noreferrer nofollow\">civitai.com<\/a><\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0420\u0430\u0431\u043e\u0442\u0430 SDXL<\/figcaption><\/div>\n<\/figure>\n<h2>\u041f\u0440\u0435\u0434\u0438\u0441\u043b\u043e\u0432\u0438\u0435<\/h2>\n<p>\u0412 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u0435\u0441\u0442\u044c \u0443\u0436\u0435 \u043c\u043d\u043e\u0433\u043e \u0433\u0430\u0439\u0434\u043e\u0432, \u043f\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0443 \u043c\u043e\u0434\u0435\u043b\u0435\u0439. \u041f\u043e\u0447\u0435\u043c\u0443 \u0435\u0449\u0435 \u043e\u0434\u043d\u0430 \u0441\u0442\u0430\u0442\u044c\u044f?<\/p>\n<p>\u0422\u0443\u0442, \u044f \u0431\u044b \u0445\u043e\u0442\u0435\u043b \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a \u043c\u043e\u0434\u0435\u043b\u0435\u0439, \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0434 Nvidia \u0432\u0438\u0434\u0435\u043e\u043a\u0430\u0440\u0442\u044b, \u0447\u0442\u043e \u0434\u0430\u0441\u0442 \u0432\u0430\u043c \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u0431\u0443\u0441\u0442 \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u044f \u0445\u043e\u0447\u0443 \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043f\u043e\u0441\u043e\u0431, \u043a\u0430\u043a \u0441\u043a\u0430\u0440\u043c\u043b\u0438\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u043f\u0440\u043e\u043c\u043f\u0442\u044b \u0432\u0430\u0448\u0438\u043c \u043c\u043e\u0434\u0435\u043b\u044f\u043c. \u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u043f\u0440\u043e\u043c\u043f\u0442 \u0434\u043b\u044f SD \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c 75 \u0442\u043e\u043a\u0435\u043d\u043e\u0432.<\/p>\n<p>\u041f\u0435\u0440\u0435\u0434 \u0441\u0442\u0430\u0440\u0442\u043e\u043c, \u0432\u0430\u0436\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u0443 \u0432\u0430\u0441 \u0441\u0442\u043e\u044f\u043b \u043d\u0430 \u0440\u0430\u0431\u043e\u0447\u0435\u0439 \u0441\u0442\u0430\u043d\u0446\u0438\u0438 <a href=\"https:\/\/www.docker.com\/products\/docker-desktop\/\" rel=\"noopener noreferrer nofollow\">Docker<\/a> \u0432\u044b\u0448\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 19.03, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u043e\u0442 Nvidia \u0434\u043b\u044f \u0432\u0430\u0448\u0435\u0439 \u0432\u0438\u0434\u0435\u043e\u043a\u0430\u0440\u0442\u044b. Cuda \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0448\u0442\u0443\u043a\u0438 \u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e.<\/p>\n<p><strong>\u041f\u043e\u0447\u0435\u043c\u0443 Docker?<\/strong> <\/p>\n<p>\u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0437 \u043e\u0442 Nvidia \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0438\u0442\u043e\u043d\u0430, pytorch \u0438 jupyter, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u0438 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u0438\u0434\u0435\u043e\u043a\u0430\u0440\u0442, \u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 \u0431\u044d\u043a\u0435\u043d\u0434\u043e\u0432, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0445 Nvidia. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u043e\u043a, \u043d\u043e \u0438 \u043d\u0435 \u0437\u0430\u0441\u043e\u0440\u044f\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u043c\u0438 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430\u043c\u0438 \u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438, \u043f\u043e \u0442\u0438\u043f\u0443 CUDA.<\/p>\n<h2>\u041d\u0430\u0447\u043d\u0435\u043c<\/h2>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u0439\u0442\u0438 \u043d\u0430 <a href=\"https:\/\/catalog.ngc.nvidia.com\/orgs\/nvidia\/containers\/pytorch\/tags\" rel=\"noopener noreferrer nofollow\">\u0441\u0430\u0439\u0442 \u0441 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u043e\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u0432 nvidia \u0434\u043b\u044f pytorch<\/a>.<\/p>\n<p>\u041d\u0430\u0445\u043e\u0434\u0438\u043c \u0442\u0430\u043c \u0441\u0430\u043c\u044b\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043e\u0431\u0440\u0430\u0437 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0438\u043c\u0435\u043d\u043d\u043e \u0435\u0433\u043e. \u041d\u0430 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0441\u0430\u043c\u044b\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043e\u0431\u0440\u0430\u0437 &#8212; \u044d\u0442\u043e <a href=\"http:\/\/nvcr.io\/nvidia\/pytorch:24.05-py3\" rel=\"noopener noreferrer nofollow\">nvcr.io\/nvidia\/pytorch:24.05-py3<\/a>. \u044f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u0435\u0433\u043e.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0430\u043f\u043a\u0443, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c\u0441\u044f jupyter, \u0432 \u044d\u0442\u043e\u0439 \u043f\u0430\u043f\u043a\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438, lora, \u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043d\u0430\u0448\u0438\u0445 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0439, \u0435\u0441\u043b\u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u043b\u0438? \u0412 \u043c\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u044f \u0441\u043e\u0437\u0434\u0430\u043b \u043f\u0430\u043f\u043a\u0443 jupyter \u043d\u0430 \u0434\u0438\u0441\u043a\u0435 D. \u0423 \u0432\u0430\u0441 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u0443\u0442\u044c, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u041e\u0421 \u0438 \u0432\u043e\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0437\u0430\u043f\u0443\u0441\u043a\u0443 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430:<\/p>\n<pre><code class=\"bash\">docker run --gpus all -it --name=pytorch -p 8888:8888 -v D:\\jupyter:\/jupyter-data --ipc=host nvcr.io\/nvidia\/pytorch:24.05-py3 jupyter notebook --ip 0.0.0.0 --notebook-dir=\"\/jupyter-data\"<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0438\u043c \u043d\u0435\u0445\u0438\u0442\u0440\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c, \u043c\u044b \u043f\u043e\u0434\u043d\u044f\u043b\u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0441 jupyter, \u0432\u043a\u043b\u044e\u0447\u0438\u043b\u0438 \u0442\u0430\u043c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 gpu \u0438 \u043f\u0440\u043e\u0431\u0440\u043e\u0441\u0438\u043b\u0438 \u043f\u043e\u0440\u0442 8888 \u043d\u0430\u0440\u0443\u0436\u0443, \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0446\u0435\u043f\u043b\u044f\u0442\u044c\u0441\u044f \u043a \u043d\u0435\u043c\u0443 \u0447\u0435\u0440\u0435\u0437 IDE \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435. \u0422\u043e\u043a\u0435\u043d \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0432 jupyter \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0437 stdout \u0432\u0430\u0448\u0435\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430. \u041d\u0430\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0435\u0433\u043e \u043d\u0430 \u043f\u0430\u0440\u043e\u043b\u044c, \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0438. \u041d\u043e \u044d\u0442\u043e \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e.<\/p>\n<h2>\u0421\u0442\u0430\u0432\u0438\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438<\/h2>\n<p>\u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0432\u0435\u0431 \u0432\u0435\u0440\u0441\u0438\u044e Jupyter \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 127.0.0.1:8888, \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0443\u0435\u043c\u0441\u044f \u0438 \u0432\u0438\u0434\u0438\u043c \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0445\u043e\u0436\u0435\u0435 \u043d\u0430 \u044d\u0442\u043e\u0442 \u044d\u043a\u0440\u0430\u043d:<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0421\u0442\u0430\u0440\u0442\u043e\u0432\u044b\u0439 \u044d\u043a\u0440\u0430\u043d Jupyter. \u0415\u0441\u043b\u0438 \u0432\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0447\u0430\u043b\u0438, \u0442\u043e \u0432\u0430\u0448 \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0443\u0441\u0442.<\/figcaption><\/div>\n<\/figure>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0430\u043f\u043a\u0443 lora, \u0447\u0435\u0440\u0435\u0437 \u043a\u043d\u043e\u043f\u043a\u0443 New. \u0418\u043b\u0438 \u0436\u0435 \u043d\u0430\u0437\u043e\u0432\u0438\u0442\u0435 \u043a\u0430\u043a \u0445\u043e\u0442\u0438\u0442\u0435. \u0412\u043d\u0443\u0442\u0440\u0438 \u044d\u0442\u043e\u0439 \u043f\u0430\u043f\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u0431\u043b\u043e\u043a\u043d\u043e\u0442. <\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0411\u043b\u043e\u043a\u043d\u043e\u0442 ipykernel<\/figcaption><\/div>\n<\/figure>\n<p>\u041e\u0442\u043a\u0440\u043e\u0435\u043c \u043d\u0430\u0448 \u0431\u043b\u043e\u043a\u043d\u043e\u0442 \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438<\/p>\n<pre><code class=\"python\">!pip install diffusers transformers accelerate safetensors ipywidgets compel peft --upgrade<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u044f\u0447\u0435\u0439\u043a\u0438 \u043d\u0430\u0434\u043e \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u044f\u0434\u0440\u043e.<\/p>\n<h2>\u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c<\/h2>\n<pre><code class=\"python\">from diffusers import (     StableDiffusionXLPipeline,     EulerAncestralDiscreteScheduler,     AutoencoderKL ) import torch  CHECKPOINT_NAME = 'stabilityai\/stable-diffusion-xl-base-1.0'  torch.backends.cuda.matmul.allow_tf32 = True  # Load VAE component  vae = vae = AutoencoderKL.from_pretrained(\"stabilityai\/sdxl-vae\", torch_dtype=torch.float16)  # Configure the pipeline pipe = StableDiffusionXLPipeline.from_pretrained(     CHECKPOINT_NAME,     vae=vae,     torch_dtype=torch.float16, ) pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(     pipe.scheduler.config, ) pipe.to('cuda')  # \u041e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0446\u0435\u043d\u0437\u0443\u0440\u044b pipe.safety_checker = None pipe.requires_safety_checker = False<\/code><\/pre>\n<p>\u0418\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u044f\u0447\u0435\u0439\u043a\u0443 \u0438 \u0436\u0434\u0435\u043c, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0448\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u0441\u044f. <\/p>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<p>\u041d\u0435 \u0442\u0430\u043a \u0434\u0430\u0432\u043d\u043e, huggingface <a href=\"https:\/\/github.com\/huggingface\/peft\/issues\/1199\" rel=\"noopener noreferrer nofollow\">\u0441\u043b\u043e\u043c\u0430\u043b\u0438<\/a> torch \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044e \u043c\u043e\u0434\u0435\u043b\u0438. \u041a\u043e\u0433\u0434\u0430 \u043f\u043e\u0447\u0438\u043d\u044f\u0442, \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u0443 \u0441\u0442\u0440\u043e\u0447\u043a\u0443 \u0434\u043b\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<pre><code class=\"python\">pipe.unet = torch.compile(pipe.unet, mode=\"reduce-overhead\", fullgraph=True)<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<h2>\u0413\u043e\u0442\u043e\u0432\u0438\u043c Compel<\/h2>\n<p>Compel &#8212; \u044d\u0442\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 &#171;\u043f\u0435\u0440\u0435\u0432\u0437\u0432\u0435\u0441\u0438\u0442\u044c&#187; \u0432\u0435\u0441\u0430 \u0438\u0437 \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u043c\u043f\u0442\u0430, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0447\u0435\u043c\u0443, \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0441\u0443\u043d\u0443\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0442\u0435\u043a\u0441\u0442 \u0432 \u043f\u0440\u043e\u043c\u043f\u0442 \u0432\u0430\u0448\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u0438, \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u044f \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0432 75 \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u0443 SD \u043c\u043e\u0434\u0435\u043b\u0435\u0439.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043d\u043e\u0432\u0443\u044e \u044f\u0447\u0435\u0439\u043a\u0443:<\/p>\n<pre><code class=\"python\">from compel import Compel, ReturnedEmbeddingsType  compel = Compel(tokenizer=[pipe.tokenizer, pipe.tokenizer_2], text_encoder=[pipe.text_encoder, pipe.text_encoder_2],                 returned_embeddings_type=ReturnedEmbeddingsType.PENULTIMATE_HIDDEN_STATES_NON_NORMALIZED,                 requires_pooled=[False, True])<\/code><\/pre>\n<h2>\u0413\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443<\/h2>\n<p>\u0412 \u043d\u043e\u0432\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0435 \u043f\u0438\u0448\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043a\u043e\u0434 \u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0435\u0433\u043e.<\/p>\n<pre><code class=\"python\">from IPython.display import display  pos = '' # \u043f\u043e\u0437\u0438\u0442\u0438\u0432\u043d\u044b\u0439 \u043f\u0440\u043e\u043c\u043f\u0442 neg = '' # \u043d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u043f\u0440\u043e\u043c\u043f\u0442  conditioning, pooled = compel(pos) negative_embed, negative_pooled = compel(neg) [conditioning, negative_embed] = compel.pad_conditioning_tensors_to_same_length([conditioning, negative_embed])  img = pipe(     prompt_embeds=conditioning,     pooled_prompt_embeds=pooled,     negative_prompt_embeds=negative_embed,     negative_pooled_prompt_embeds=negative_pooled,     num_inference_steps=40,     guidance_scale=7, #     num_images_per_prompt=10 # \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0430\u0440\u0442\u0438\u043d\u043e\u043a \u0437\u0430 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e )  for image in img[0]:     display(image)<\/code><\/pre>\n<p>\u0413\u043e\u0442\u043e\u0432\u043e, \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u043e\u043a \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e StableDiffusionXL. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u0430\u043c\u044b\u0435 \u0440\u0430\u0437\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <code>CHECKPOINT_NAME<\/code> \u0438 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u0421\u043f\u0438\u0441\u043e\u043a \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043d\u0430 <a href=\"https:\/\/huggingface.co\/\" rel=\"noopener noreferrer nofollow\">https:\/\/huggingface.co\/<\/a> <\/p>\n<h2>\u0413\u0440\u0443\u0437\u0438\u043c \u043c\u043e\u0434\u0435\u043b\u0438 \u0441 CivitAi<\/h2>\n<p>\u041d\u0430 <a href=\"https:\/\/civitai.com\/\" rel=\"noopener noreferrer nofollow\">\u0434\u0430\u043d\u043d\u043e\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u0435<\/a> \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0442\u044b\u0441\u044f\u0447\u0438 fine tune SD \u043c\u043e\u0434\u0435\u043b\u0435\u0439, \u043d\u0430 \u043b\u044e\u0431\u043e\u0439 \u0432\u043a\u0443\u0441 \u0438 \u0446\u0432\u0435\u0442. \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0441 huggingface \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e.<\/p>\n<p><strong>Checkpoints<\/strong><\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u043e\u0434\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u0438\u0437 \u0447\u0435\u043a\u043f\u043e\u0438\u043d\u0442\u0430, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u043d\u0430\u0448\u0443 \u043b\u043e\u0433\u0438\u043a\u0443 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043c\u043e\u0434\u0435\u043b\u0438, \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c <code>StableDiffusionXLPipeline.from_pretrained<\/code> \u043d\u0430 <code>StableDiffusionXLPipeline.from_single_file<\/code><\/p>\n<pre><code class=\"python\">CHECKPOINT_NAME = 'my_sdxl_model.safetensors' pipe = StableDiffusionXLPipeline.from_single_file(     CHECKPOINT_NAME,     vae=vae,     torch_dtype=torch.float16, )<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u044d\u0442\u043e\u043c <code>CHECKPOINT_NAME<\/code> \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c \u043d\u0430 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u0441\u043a\u0430\u0447\u0430\u043b\u0438 \u0441 civitai.<\/p>\n<p><strong>Lora<\/strong><\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c lora \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0435\u0435 \u0438 \u0432 \u043d\u043e\u0432\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u043a \u043d\u0430\u0448\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u0438<\/p>\n<pre><code class=\"python\">pipe.load_lora_weights('.\/', weight_name='lora_name.safetensors')<\/code><\/pre>\n<h2>\u0427\u0442\u043e \u0434\u0430\u043b\u044c\u0448\u0435?<\/h2>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043d\u0430\u0443\u0447\u0438\u043b\u0438\u0441\u044c \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438, \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u043a \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u043c. \u0418\u0433\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u043c\u043e\u0434\u0435\u043b\u044f\u043c\u0438, lora, \u043c\u0435\u043d\u044f\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b <code>num_inference_steps<\/code> \u0438 <code>guidance_scale<\/code>, \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0439 <code>pipe.scheduler<\/code>. \u0418 \u043c\u043d\u043e\u0433\u043e \u0447\u0435\u0433\u043e \u0435\u0449\u0435.<\/p>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u0432\u0441\u0435. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0434\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u043e\u0439\u0442\u0438 \u0432\u0430\u043c \u0442\u0435 \u0433\u0440\u0430\u0431\u043b\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u043f\u043e \u043f\u0443\u0442\u0438.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/817175\/\"> https:\/\/habr.com\/ru\/articles\/817175\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-377162","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/377162","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=377162"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/377162\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=377162"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=377162"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=377162"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}