{"id":625,"date":"2024-01-16T11:24:36","date_gmt":"2024-01-16T02:24:36","guid":{"rendered":"https:\/\/rebron.net\/blog\/?p=625"},"modified":"2024-01-16T11:24:37","modified_gmt":"2024-01-16T02:24:37","slug":"%e3%80%90%e6%9c%80%e6%96%b0%e7%89%88%e3%80%91stablediffusion%e3%82%92%e7%84%a1%e6%96%99%e3%81%aegoogle-colab%e3%81%a7%e5%8b%95%e3%81%8b%e3%81%99%e6%96%b9%e6%b3%95%e3%80%90%e7%94%9f%e6%88%90ai%e3%80%91","status":"publish","type":"post","link":"https:\/\/rebron.net\/blog\/%e3%80%90%e6%9c%80%e6%96%b0%e7%89%88%e3%80%91stablediffusion%e3%82%92%e7%84%a1%e6%96%99%e3%81%aegoogle-colab%e3%81%a7%e5%8b%95%e3%81%8b%e3%81%99%e6%96%b9%e6%b3%95%e3%80%90%e7%94%9f%e6%88%90ai%e3%80%91\/","title":{"rendered":"\u3010\u6700\u65b0\u7248\u3011StableDiffusion\u3092\u7121\u6599\u306eGoogle Colab\u3067\u52d5\u304b\u3059\u65b9\u6cd5\u3010\u751f\u6210AI\u3011"},"content":{"rendered":"\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u65b0\u898f\u30ce\u30fc\u30c8\u30d6\u30c3\u30af\u306e\u4f5c\u6210<\/h2>\n\n\n\n<p><a href=\"http:\/\/colab.research.google.com\">Googlecolab<\/a>\u306b\u30a2\u30af\u30bb\u30b9\u3057\u307e\u3059\u3002\u4ee5\u4e0b\u306e\u300c\u30ce\u30fc\u30c8\u30d6\u30c3\u30af\u3092\u65b0\u898f\u4f5c\u6210\u300d\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"570\" height=\"134\" src=\"https:\/\/rebron.net\/blog\/wp-content\/uploads\/2024\/01\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2024-01-16-9.43.56.png\" alt=\"\" class=\"wp-image-626\" style=\"width:404px;height:auto\" srcset=\"https:\/\/rebron.net\/blog\/wp-content\/uploads\/2024\/01\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2024-01-16-9.43.56.png 570w, https:\/\/rebron.net\/blog\/wp-content\/uploads\/2024\/01\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2024-01-16-9.43.56-300x71.png 300w\" sizes=\"auto, (max-width: 570px) 100vw, 570px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">GPU\u306b\u5909\u66f4<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"782\" src=\"https:\/\/rebron.net\/blog\/wp-content\/uploads\/2024\/01\/zu1-1024x782.png\" alt=\"\" class=\"wp-image-628\" style=\"width:477px;height:auto\" srcset=\"https:\/\/rebron.net\/blog\/wp-content\/uploads\/2024\/01\/zu1-1024x782.png 1024w, https:\/\/rebron.net\/blog\/wp-content\/uploads\/2024\/01\/zu1-300x229.png 300w, https:\/\/rebron.net\/blog\/wp-content\/uploads\/2024\/01\/zu1-768x587.png 768w, https:\/\/rebron.net\/blog\/wp-content\/uploads\/2024\/01\/zu1.png 1398w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u4ee5\u4e0b\u306e\u753b\u50cf\u306e\u3088\u3046\u306b\u3001\u300cGPU\u300d\u3068\u66f8\u3044\u3066\u3042\u308b\u9805\u76ee\u3092\u9078\u629e\u3057\u307e\u3059\u3002<br>\u9078\u629e\u3067\u304d\u308b\u9805\u76ee\u306f\u6642\u9593\u306b\u3088\u3063\u3066\u7570\u306a\u308b\u5834\u5408\u304c\u3042\u308a\u307e\u3059\u3002<br>\u4eca\u56de\u306f\u300cT4 GPU\u300d\u3092\u9078\u3073\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"744\" src=\"https:\/\/rebron.net\/blog\/wp-content\/uploads\/2024\/01\/zu2-1024x744.png\" alt=\"\" class=\"wp-image-629\" style=\"width:527px;height:auto\" srcset=\"https:\/\/rebron.net\/blog\/wp-content\/uploads\/2024\/01\/zu2-1024x744.png 1024w, https:\/\/rebron.net\/blog\/wp-content\/uploads\/2024\/01\/zu2-300x218.png 300w, https:\/\/rebron.net\/blog\/wp-content\/uploads\/2024\/01\/zu2-768x558.png 768w, https:\/\/rebron.net\/blog\/wp-content\/uploads\/2024\/01\/zu2.png 1134w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>GPU\u306b\u5909\u66f4\u3055\u308c\u305f\u3053\u3068\u306e\u78ba\u8a8d\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u6253\u3061\u3001\u300c\u518d\u751f\u30dc\u30bf\u30f3\u300d\u304b\u300cShift+Enter\u300d\u3067\u5b9f\u884c\u3057\u307e\u3059\u3002<br>\u300c!nvidia-smi\u300d\u306fGPU\u306e\u30e2\u30cb\u30bf\u30ea\u30f3\u30b0\u3092\u884c\u3046\u30b3\u30de\u30f3\u30c9\u3067\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>!nvidia-smi<\/code><\/pre>\n\n\n\n<p>\u4ee5\u4e0b\u306e\u753b\u50cf\u306e\u3088\u3046\u306b\u300cNVIDIA-SMI \u6570\u5b57\u300d\u3068\u8868\u793a\u3055\u308c\u3066\u3044\u308c\u3070\u5927\u4e08\u592b\u3067\u3059\u3002<br>\u300cNVIDIA-SMI has failed\u300d\u3068\u8868\u793a\u3055\u308c\u308b\u969b\u306f\u3001\u518d\u5ea6GPU\u306b\u306a\u3063\u3066\u3044\u308b\u304b\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"406\" src=\"https:\/\/rebron.net\/blog\/wp-content\/uploads\/2024\/01\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2024-01-16-9.48.39-1024x406.png\" alt=\"\" class=\"wp-image-627\" srcset=\"https:\/\/rebron.net\/blog\/wp-content\/uploads\/2024\/01\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2024-01-16-9.48.39-1024x406.png 1024w, https:\/\/rebron.net\/blog\/wp-content\/uploads\/2024\/01\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2024-01-16-9.48.39-300x119.png 300w, https:\/\/rebron.net\/blog\/wp-content\/uploads\/2024\/01\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2024-01-16-9.48.39-768x305.png 768w, https:\/\/rebron.net\/blog\/wp-content\/uploads\/2024\/01\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2024-01-16-9.48.39-1536x609.png 1536w, https:\/\/rebron.net\/blog\/wp-content\/uploads\/2024\/01\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2024-01-16-9.48.39.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u5fc5\u8981\u306a\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067Python\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u7ba1\u7406\u30c4\u30fc\u30eb\u3067\u3042\u308bpip\u3092\u4f7f\u3063\u3066\u5fc5\u8981\u306a\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002\u30b3\u30de\u30f3\u30c9\u306f\u300c!nvidia-smi\u300d\u306e\u6b21\u306e\u5165\u529b\u67a0\u306b\u5165\u529b\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>diffusers<\/strong>: Diffusers\u306f\u3001\u4e3b\u306b\u81ea\u7136\u8a00\u8a9e\u51e6\u7406\u306b\u95a2\u9023\u3059\u308b\u69d8\u3005\u306a\u30c7\u30a3\u30fc\u30d7\u30e9\u30fc\u30cb\u30f3\u30b0\u30e2\u30c7\u30eb\u306e\u62e1\u6563\u30d7\u30ed\u30bb\u30b9\u3092\u6271\u3046\u305f\u3081\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u3059\u3002\u62e1\u6563\u30e2\u30c7\u30eb\u306f\u3001\u751f\u6210\u30e2\u30c7\u30eb\u306e\u4e00\u7a2e\u3067\u3042\u308a\u3001\u7279\u306b\u30c6\u30ad\u30b9\u30c8\u3001\u753b\u50cf\u3001\u97f3\u58f0\u306a\u3069\u306e\u751f\u6210\u306b\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>transformers<\/strong>: Transformers\u306f\u3001\u81ea\u7136\u8a00\u8a9e\u51e6\u7406\u306b\u304a\u3051\u308b\u6700\u5148\u7aef\u306e\u30e2\u30c7\u30eb\u3092\u7c21\u5358\u306b\u5229\u7528\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b\u305f\u3081\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u3059\u3002\u3053\u308c\u3089\u306e\u30e2\u30c7\u30eb\u306f\u30c6\u30ad\u30b9\u30c8\u306e\u5206\u985e\u3001\u751f\u6210\u3001\u7ffb\u8a33\u3001\u8981\u7d04\u306a\u3069\u69d8\u3005\u306a\u30bf\u30b9\u30af\u306b\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>ftfy<\/strong>: FTFY\uff08Fix Text For You\uff09\u306f\u3001\u58ca\u308c\u305f\u30c6\u30ad\u30b9\u30c8\u3092\u4fee\u6b63\u3059\u308b\u305f\u3081\u306e\u30c4\u30fc\u30eb\u3067\u3059\u3002\u3053\u308c\u306f\u3001\u6587\u5b57\u30a8\u30f3\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u306e\u554f\u984c\u3092\u81ea\u52d5\u7684\u306b\u4fee\u6b63\u3057\u3001\u30c6\u30ad\u30b9\u30c8\u30c7\u30fc\u30bf\u3092\u3088\u308a\u30af\u30ea\u30fc\u30f3\u3067\u8aad\u307f\u3084\u3059\u3044\u5f62\u306b\u5909\u63db\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>accelerate<\/strong>: Accelerate\u306f\u3001\u30c7\u30a3\u30fc\u30d7\u30e9\u30fc\u30cb\u30f3\u30b0\u30e2\u30c7\u30eb\u306e\u30c8\u30ec\u30fc\u30cb\u30f3\u30b0\u3084\u63a8\u8ad6\u3092\u7c21\u5358\u306b\u304b\u3064\u52b9\u7387\u7684\u306b\u3059\u308b\u305f\u3081\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u3059\u3002\u7279\u306b\u3001GPU\u3084TPU\u306a\u3069\u306e\u30cf\u30fc\u30c9\u30a6\u30a7\u30a2\u30a2\u30af\u30bb\u30e9\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u6d3b\u7528\u3059\u308b\u969b\u306b\u6709\u7528\u3067\u3059\u3002<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>!pip install diffusers transformers ftfy accelerate<\/code><\/pre>\n\n\n\n<p>\u4eca\u56de\u306f\u6700\u65b0\u306e\u4ee5\u4e0b\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p>diffusers\uff1a0.25.0 transformers\uff1a4.35.2  ftfy\uff1a6.1.3 accelerate\uff1a0.26.1<br>\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u8a18\u4e8b\u3068\u5408\u308f\u305b\u308b\u5834\u5408\u306f\u3001\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u6307\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>!pip install diffusers==0.25.0 transformers==4.35.2 ftfy==6.1.3 accelerate==0.26.1<\/code><\/pre>\n\n\n\n<p>\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u753b\u9762\u306b\u8868\u793a\u3055\u308c\u3066\u3044\u308b\u305f\u3081\u3001transformers\u306f\u3059\u3067\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u6e08\u307f\u3067\u3057\u305f\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Requirement already satisfied: transformers in \/usr\/local\/lib\/python3.10\/dist-packages (4.35.2)<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"628\" src=\"https:\/\/rebron.net\/blog\/wp-content\/uploads\/2024\/01\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2024-01-16-10.07.34-1024x628.png\" alt=\"\" class=\"wp-image-630\" style=\"width:633px;height:auto\" srcset=\"https:\/\/rebron.net\/blog\/wp-content\/uploads\/2024\/01\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2024-01-16-10.07.34-1024x628.png 1024w, https:\/\/rebron.net\/blog\/wp-content\/uploads\/2024\/01\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2024-01-16-10.07.34-300x184.png 300w, https:\/\/rebron.net\/blog\/wp-content\/uploads\/2024\/01\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2024-01-16-10.07.34-768x471.png 768w, https:\/\/rebron.net\/blog\/wp-content\/uploads\/2024\/01\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2024-01-16-10.07.34-1536x943.png 1536w, https:\/\/rebron.net\/blog\/wp-content\/uploads\/2024\/01\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2024-01-16-10.07.34-2048x1257.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<div class=\"wp-block-cocoon-blocks-icon-box common-icon-box block-box information-box\">\n<p>\u5165\u529b\u67a0\u304c\u8868\u793a\u3055\u308c\u306a\u3044\u5834\u5408\u306f\u3001\u4ee5\u4e0b\u306e\u753b\u50cf\u306e\u3088\u3046\u306b\u300c+\u30b3\u30fc\u30c9\u300d\u3092\u30af\u30ea\u30c3\u30af\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<\/div>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"906\" height=\"222\" src=\"https:\/\/rebron.net\/blog\/wp-content\/uploads\/2024\/01\/zu3.png\" alt=\"\" class=\"wp-image-631\" style=\"width:592px;height:auto\" srcset=\"https:\/\/rebron.net\/blog\/wp-content\/uploads\/2024\/01\/zu3.png 906w, https:\/\/rebron.net\/blog\/wp-content\/uploads\/2024\/01\/zu3-300x74.png 300w, https:\/\/rebron.net\/blog\/wp-content\/uploads\/2024\/01\/zu3-768x188.png 768w\" sizes=\"auto, (max-width: 906px) 100vw, 906px\" \/><\/figure>\n\n\n\n<p>\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3092\u5165\u529b\u3057\u3066\u5b9f\u884c\u3057\u307e\u3059\u3002\u30b3\u30fc\u30c9\u306fStable Diffusion\u3092\u4f7f\u7528\u3057\u3066\u3001\u7279\u5b9a\u306e\u30c6\u30ad\u30b9\u30c8\u30d7\u30ed\u30f3\u30d7\u30c8\u306b\u57fa\u3065\u3044\u3066\u753b\u50cf\u3092\u751f\u6210\u3057\u3001\u305d\u306e\u753b\u50cf\u3092\u4fdd\u5b58\u3059\u308b\u305f\u3081\u306e\u3082\u306e\u3067\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\" data-show-lang=\"1\"><code>import torch\nfrom diffusers import StableDiffusionPipeline\n\nmodel_id = &quot;CompVis\/stable-diffusion-v1-4&quot;\nprompt = &quot;best quality,dog&quot;\ndevice = &quot;cuda&quot;\nseed=30\n\n\npipeline = StableDiffusionPipeline.from_pretrained(model_id).to(device)\n\ngenerator = torch.Generator(device).manual_seed(seed) \nwith torch.autocast(device):\n    image = pipeline(prompt, guidance_scale=7.5, generator=generator).images[0]  \n\nimage.save(&quot;test1.png&quot;)<\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">\u30b3\u30fc\u30c9\u306e\u89e3\u8aac<\/h3>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>import torch\nfrom diffusers import StableDiffusionPipeline<\/code><\/pre><\/div>\n\n\n\n<p>PyTorch\uff08<code>torch<\/code>\uff09\u3068\u3001Diffusers\u30e9\u30a4\u30d6\u30e9\u30ea\u304b\u3089StableDiffusionPipeline\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u3066\u3044\u307e\u3059\u3002PyTorch\u306f\u6a5f\u68b0\u5b66\u7fd2\u30e2\u30c7\u30eb\u306e\u69cb\u7bc9\u3068\u8a13\u7df4\u306b\u5e83\u304f\u4f7f\u7528\u3055\u308c\u308b\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3067\u3001Diffusers\u306f\u4e3b\u306b\u6df1\u5c64\u5b66\u7fd2\u306b\u57fa\u3065\u304f\u753b\u50cf\u751f\u6210\u306e\u305f\u3081\u306e\u30c4\u30fc\u30eb\u3092\u63d0\u4f9b\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\" data-start=\"4\"><code>model_id = &quot;CompVis\/stable-diffusion-v1-4&quot;\nprompt = &quot;best quality,dog&quot;\ndevice = &quot;cuda&quot;\nseed=30<\/code><\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>model_id<\/code>\u306f\u4f7f\u7528\u3059\u308bStable Diffusion\u30e2\u30c7\u30eb\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><code>prompt<\/code>\u306f\u753b\u50cf\u751f\u6210\u306e\u305f\u3081\u306e\u30c6\u30ad\u30b9\u30c8\u6307\u793a\u3067\u3001\u3053\u3053\u3067\u306f\u54c1\u8cea\u304c\u826f\u3044\u72ac\u306e\u753b\u50cf\u3092\u8981\u6c42\u3057\u3066\u3044\u307e\u3059\u3002<\/li>\n\n\n\n<li><code>device<\/code>\u306f\u8a08\u7b97\u3092\u884c\u3046\u30c7\u30d0\u30a4\u30b9\u3092\u6307\u5b9a\u3057\u3066\u304a\u308a\u3001<code>\"cuda\"<\/code>\u306fNVIDIA\u306eGPU\u3092\u4f7f\u3046\u3053\u3068\u3092\u610f\u5473\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><code>seed<\/code>\u306f\u4e71\u6570\u751f\u6210\u5668\u306e\u305f\u3081\u306e\u30b7\u30fc\u30c9\u5024\u3067\u3001\u753b\u50cf\u751f\u6210\u306e\u518d\u73fe\u6027\u3092\u4fdd\u8a3c\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002<\/li>\n<\/ul>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\" data-start=\"10\"><code>pipeline = StableDiffusionPipeline.from_pretrained(model_id).to(device)<\/code><\/pre><\/div>\n\n\n\n<p>\u4e8b\u524d\u8a13\u7df4\u6e08\u307f\u306eStable Diffusion\u30e2\u30c7\u30eb\u3092\u30ed\u30fc\u30c9\u3057\u3001\u6307\u5b9a\u3055\u308c\u305f\u30c7\u30d0\u30a4\u30b9\uff08\u3053\u306e\u5834\u5408\u306fGPU\uff09\u306b\u79fb\u52d5\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\" data-start=\"12\"><code>generator = torch.Generator(device).manual_seed(seed) \nwith torch.autocast(device):\n    image = pipeline(prompt, guidance_scale=7.5, generator=generator).images[0]  \n\nimage.save(&quot;test1.png&quot;)<\/code><\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\">\n<li>12\u884c\u76ee\u306f\u3001\u753b\u50cf\u751f\u6210\u306e\u969b\u306b\u4f7f\u7528\u3055\u308c\u308b\u4e71\u6570\u751f\u6210\u5668\u3092\u521d\u671f\u5316\u3057\u3001\u6307\u5b9a\u3055\u308c\u305f\u30b7\u30fc\u30c9\u5024\uff08\u3053\u306e\u5834\u5408\u306f30\uff09\u3092\u4f7f\u3063\u3066\u518d\u73fe\u6027\u3092\u78ba\u4fdd\u3057\u3066\u3044\u307e\u3059\u3002<\/li>\n\n\n\n<li>13\u884c\u76ee\u306f\u3001\u30c7\u30d0\u30a4\u30b9\uff08\u3053\u3053\u3067\u306fGPU\uff09\u4e0a\u3067\u306e\u8a08\u7b97\u3092\u52b9\u7387\u5316\u3059\u308b\u305f\u3081\u306b\u81ea\u52d5\u7684\u306b\u30c7\u30fc\u30bf\u578b\u306e\u30ad\u30e3\u30b9\u30c8\u3092\u884c\u3063\u3066\u3044\u307e\u3059\u3002\u3053\u308c\u306f\u8a08\u7b97\u901f\u5ea6\u3092\u5411\u4e0a\u3055\u305b\u3001\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u3092\u6e1b\u3089\u3059\u306e\u306b\u5f79\u7acb\u3061\u307e\u3059\u3002<\/li>\n\n\n\n<li><code>14\u884c\u76ee<\/code> \u306f\u3001\u6307\u5b9a\u3055\u308c\u305f\u30d7\u30ed\u30f3\u30d7\u30c8\u306b\u57fa\u3065\u3044\u3066\u753b\u50cf\u3092\u751f\u6210\u3057\u307e\u3059\u3002<code>guidance_scale<\/code>\u30d1\u30e9\u30e1\u30fc\u30bf\u306f\u3001\u751f\u6210\u3055\u308c\u308b\u753b\u50cf\u304c\u30d7\u30ed\u30f3\u30d7\u30c8\u306b\u3069\u308c\u3060\u3051\u5bc6\u63a5\u306b\u5f93\u3046\u304b\u3092\u5236\u5fa1\u3057\u307e\u3059\uff08\u6570\u5024\u304c\u5927\u304d\u3044\u307b\u3069\u3001\u3088\u308a\u30d7\u30ed\u30f3\u30d7\u30c8\u306b\u5fe0\u5b9f\u306a\u753b\u50cf\u304c\u751f\u6210\u3055\u308c\u307e\u3059\uff09\u3002\u751f\u6210\u3055\u308c\u305f\u753b\u50cf\u306f\u30ea\u30b9\u30c8\u5f62\u5f0f\u3067\u8fd4\u3055\u308c\u308b\u305f\u3081\u3001\u6700\u521d\u306e\u8981\u7d20\uff08<code>[0]<\/code>\uff09\u3092\u53d6\u5f97\u3057\u3066\u3044\u307e\u3059\u3002<\/li>\n\n\n\n<li>\u6700\u5f8c\u306b\u3001\u751f\u6210\u3055\u308c\u305f\u753b\u50cf\u3092<code>\"test1.png\"<\/code>\u3068\u3044\u3046\u540d\u524d\u3067\u4fdd\u5b58\u3057\u307e\u3059\u3002<\/li>\n<\/ul>\n\n\n\n<div class=\"wp-block-cocoon-blocks-icon-box common-icon-box block-box information-box\">\n<p>\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u300cNo module named &#8216;diffusers&#8217;\u300d\u306e\u30a8\u30e9\u30fc\u304c\u3067\u305f\u3089\u3001\u5fc5\u8981\u306a\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u30b3\u30de\u30f3\u30c9\u3092\u518d\u5ea6\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<\/div>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1000\" height=\"426\" src=\"https:\/\/rebron.net\/blog\/wp-content\/uploads\/2024\/01\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2024-01-16-10.36.00.png\" alt=\"\" class=\"wp-image-632\" style=\"width:540px;height:auto\" srcset=\"https:\/\/rebron.net\/blog\/wp-content\/uploads\/2024\/01\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2024-01-16-10.36.00.png 1000w, https:\/\/rebron.net\/blog\/wp-content\/uploads\/2024\/01\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2024-01-16-10.36.00-300x128.png 300w, https:\/\/rebron.net\/blog\/wp-content\/uploads\/2024\/01\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2024-01-16-10.36.00-768x327.png 768w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u753b\u50cf\u306e\u78ba\u8a8d<\/h2>\n\n\n\n<p>\u5b9f\u884c\u304c\u7d42\u4e86\u3057\u305f\u3089\u3001\u753b\u50cf\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002\u753b\u50cf\u306f\u5de6\u5074\u30e1\u30cb\u30e5\u30fc\u306e\u30d5\u30a9\u30eb\u30c0\u30a2\u30a4\u30b3\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u3001\u300ctest1.png\u300d\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u753b\u9762\u53f3\u306b\u8868\u793a\u3055\u308c\u307e\u3059\u3002<br>\u4eca\u56de\u306f\u30d7\u30ed\u30f3\u30d7\u30c8\u3067&#8221;best quality,dog&#8221;\u3092\u6307\u5b9a\u3057\u305f\u305f\u3081\u3001\u72ac\u306e\u753b\u50cf\u304c\u751f\u6210\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"399\" src=\"https:\/\/rebron.net\/blog\/wp-content\/uploads\/2024\/01\/zu4-1024x399.png\" alt=\"\" class=\"wp-image-633\" srcset=\"https:\/\/rebron.net\/blog\/wp-content\/uploads\/2024\/01\/zu4-1024x399.png 1024w, https:\/\/rebron.net\/blog\/wp-content\/uploads\/2024\/01\/zu4-300x117.png 300w, https:\/\/rebron.net\/blog\/wp-content\/uploads\/2024\/01\/zu4-768x299.png 768w, https:\/\/rebron.net\/blog\/wp-content\/uploads\/2024\/01\/zu4-1536x598.png 1536w, https:\/\/rebron.net\/blog\/wp-content\/uploads\/2024\/01\/zu4-2048x798.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\u65b0\u898f\u30ce\u30fc\u30c8\u30d6\u30c3\u30af\u306e\u4f5c\u6210 Googlecolab\u306b\u30a2\u30af\u30bb\u30b9\u3057\u307e\u3059\u3002\u4ee5\u4e0b\u306e\u300c\u30ce\u30fc\u30c8\u30d6\u30c3\u30af\u3092\u65b0\u898f\u4f5c\u6210\u300d\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u307e\u3059\u3002 GPU\u306b\u5909\u66f4 \u4ee5\u4e0b\u306e\u753b\u50cf\u306e\u3088\u3046\u306b\u3001\u300cGPU\u300d\u3068\u66f8\u3044\u3066\u3042\u308b\u9805\u76ee\u3092\u9078\u629e\u3057\u307e\u3059\u3002\u9078\u629e\u3067\u304d\u308b\u9805\u76ee\u306f\u6642\u9593\u306b\u3088 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":637,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jinr_url_youtube":"","_jinr_pip_youtube":false,"_jinr_time_youtube":"","_jinr_thumb_youtube":"","_jinr_media_youtube":"","_jinr_category_edit":false,"_jinr_category":"","_jinr_title_display":false,"_jinr_snsbutton_display":false,"_jinr_ads_display":false,"_jinr_thumbnail_display":false,"_jinr_profile_display":false,"_jinr_representations_display":false,"_jinr_relatedpost_display":false,"_jinr_sidebar1col_display":false,"_jinr_sidebar2col_display":false,"_jinr_seotitle_display":"","_jinr_description_display":"","_jinr_keyword_display":"","_jinr_hastag_display":"","_jinr_canonical_display":"","_jinr_noindex_display":false,"_jinr_paidpost":false,"_jinr_paidpost_product_id":"","_jinr_headtag_article":"","footnotes":""},"categories":[45],"tags":[],"class_list":["post-625","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ai"],"views":"37","_links":{"self":[{"href":"https:\/\/rebron.net\/blog\/wp-json\/wp\/v2\/posts\/625","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rebron.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rebron.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rebron.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rebron.net\/blog\/wp-json\/wp\/v2\/comments?post=625"}],"version-history":[{"count":4,"href":"https:\/\/rebron.net\/blog\/wp-json\/wp\/v2\/posts\/625\/revisions"}],"predecessor-version":[{"id":638,"href":"https:\/\/rebron.net\/blog\/wp-json\/wp\/v2\/posts\/625\/revisions\/638"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/rebron.net\/blog\/wp-json\/wp\/v2\/media\/637"}],"wp:attachment":[{"href":"https:\/\/rebron.net\/blog\/wp-json\/wp\/v2\/media?parent=625"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rebron.net\/blog\/wp-json\/wp\/v2\/categories?post=625"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rebron.net\/blog\/wp-json\/wp\/v2\/tags?post=625"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}