{"id":3070,"date":"2023-01-10T12:00:38","date_gmt":"2023-01-10T03:00:38","guid":{"rendered":"https:\/\/blog.since2020.jp\/?p=3070"},"modified":"2023-08-09T11:43:55","modified_gmt":"2023-08-09T02:43:55","slug":"generate_environment","status":"publish","type":"post","link":"https:\/\/since2020.jp\/media\/generate_environment\/","title":{"rendered":"\u81ea\u793e\u306e\u5e74\u8cc0\u72b6\u7528\u753b\u50cf\u3092\u3001\u753b\u50cf\u751f\u6210AI\u300cStable Diffusion\u300d\u3067\u4f5c\u3063\u3066\u307f\u305f\uff5e\u74b0\u5883\u69cb\u7bc9\u7de8"},"content":{"rendered":"\n<p>\u81ea\u793e\u306e\u5e74\u8cc0\u72b6\u7528\u753b\u50cf\u3092\u3001\u753b\u50cf\u751f\u6210AI\u300cStable Diffusion\u300d\u3067\u4f5c\u3063\u3066\u307f\u305f\uff5e\u74b0\u5883\u69cb\u7bc9\u7de8<\/p>\n\n\n<h2>\u5b9f\u306f\u74b0\u5883\u69cb\u7bc9\u307e\u3067\u306b\u6642\u9593\u304c\u639b\u304b\u308a\u307e\u3057\u305f<\/h2>\n<p>\u6628\u5e74\u672b\u306b\u516c\u958b\u3057\u305f\u3001<a href=\"https:\/\/blog.since2020.jp\/ai\/ai_newyearscard\/\">\u753b\u50cf\u751f\u6210AI\u300cStable Diffusion\u300d\u3092\u4f7f\u3063\u305f\u5e74\u8cc0\u72b6\u753b\u50cf\u306e\u751f\u6210<\/a>\u8a18\u4e8b\u306f\u3001\u3054\u89a7\u306b\u306a\u3063\u3066\u3044\u305f\u3060\u3051\u307e\u3057\u305f\u3067\u3057\u3087\u3046\u304b\uff1f<\/p>\n<p>\u3042\u306e\u8a18\u4e8b\u3067\u306f\u751f\u6210\u3055\u308c\u305f\u753b\u50cf\u3092\u541f\u5473\u30fb\u691c\u8a0e\u3059\u308b\u5207\u308a\u53e3\u306b\u5fb9\u5e95\u3057\u305f\u3082\u306e\u306b\u3057\u307e\u3057\u305f\u304c\u3001\u5b9f\u306f\u300cStable Diffusion\u300d\u3092\u52d5\u4f5c\u3055\u305b\u308b\u74b0\u5883\u3092\u69cb\u7bc9\u3059\u308b\u307e\u3067\u306b\u300110\u6642\u9593\u307b\u3069\u306e\u6642\u9593\u304c\u304b\u304b\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u4eca\u56de\u306f\u3001\u74b0\u5883\u3092\u69cb\u7bc9\u3059\u308b\u307e\u3067\u306e\u7d4c\u7def\u306b\u3064\u3044\u3066\u304a\u8a71\u3055\u305b\u3066\u9802\u3051\u308c\u3070\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n\n<h2>\u300cDeepLearning VM + Cloud Shell\u300d\u304b\u3089\u300cVertex AI Workbench\u300d\u3078<\/h2>\n<p>\u5f53\u521d\u306e\u4e88\u5b9a\u3067\u306f\u3001GCP\u4e0a\u306eDeepLearning VM + Cloud Shell\u3092\u4f7f\u3046\u60f3\u5b9a\u3067\u3057\u305f\u3002\u3068\u3053\u308d\u304c\u3001\u3053\u306e\u5834\u5408\u306f\u7279\u5b9a\u306ePython\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u304c\u5229\u7528\u3067\u304d\u306a\u3044\u3053\u3068\u3002\u3055\u3089\u306b\u3001GPU\u3092\u7a4d\u3093\u3060\u4eee\u60f3\u74b0\u5883\u3067\u3059\u3068\u672a\u4f7f\u7528\u6642\u306b\u3082\u30b5\u30fc\u30d0\u30fc\u3092\u4e00\u6642\u505c\u6b62\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u305a\u3001\u8cbb\u7528\u304c\u5d69\u3093\u3067\u3057\u307e\u3046\u3068\u3044\u3046\u8981\u56e0\u3002\u3055\u3089\u306b\u3001\u8d77\u52d5\u6642\u306b\u30ea\u30fc\u30b8\u30e7\u30f3\u3092\u9078\u629e\u3059\u308b\u306e\u3067\u3059\u304c\u3001\u5229\u7528\u3057\u305f\u3044\u4eee\u60f3\u74b0\u5883\u306e\u69cb\u6210\u304c\u3042\u308b\u30ea\u30fc\u30b8\u30e7\u30f3\u304c\u9650\u3089\u308c\u3066\u3044\u308b\u3053\u3068\u3068\u3001\u53ef\u80fd\u306a\u30ea\u30fc\u30b8\u30e7\u30f3\u3067\u7acb\u3061\u4e0a\u3052\u3066\u3082\u30a8\u30e9\u30fc\u3067\u5229\u7528\u3067\u304d\u306a\u304f\u306a\u308b\u3053\u3068\u304c\u591a\u767a\u3057\u3001\u56f0\u308a\u679c\u3066\u3066\u3044\u307e\u3057\u305f\u3002\u3053\u3053\u307e\u30677\uff5e8\u6642\u9593\u307b\u3069\u639b\u304b\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u3053\u3067\u5f0a\u793e\u30fb\u5c71\u7aaa\u3055\u3093\u306b\u76f8\u8ac7\u3057\u305f\u3068\u3053\u308d\u3001\u300cVertex AI Workbench\u300d\u3068\u547c\u3070\u308c\u308b\u4eee\u60f3\u74b0\u5883\u3092\u5229\u7528\u3059\u308b\u3053\u3068\u306b\u5909\u66f4\u3057\u3001Jupyter Notebook\u4e0a\u304b\u3089\u5229\u7528\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u306e\u3067\u3059\u3002<\/p>\n<p>\u3053\u306e\u74b0\u5883\u306b\u5fc5\u8981\u306a\u30e9\u30a4\u30d6\u30e9\u30ea\u306a\u3069\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u5b9f\u884c\u3059\u308b\u3068\u3001\u30e1\u30e2\u30ea\u4e0d\u8db3\u306a\u3069\u306b\u3088\u308b\u30a8\u30e9\u30fc\u306f\u3042\u3063\u305f\u3082\u306e\u306e\u3001\u6570\u6642\u9593\u3067\u69cb\u7bc9\u307e\u3067\u6f15\u304e\u7740\u3051\u307e\u3057\u305f\u3002<\/p>\n\n<h2>\u300cStable Diffusion\u300d\u306f2\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u5229\u7528\u3059\u308b\u3053\u3068\u306b<\/h2>\n<p>\u6b21\u306b\u300cStable Diffusion\u300d\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3067\u3059\u3002\u3053\u306e\u30bd\u30d5\u30c8\u306b\u306f\u8907\u6570\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u304c\u5b58\u5728\u3057\u307e\u3059\u304c\u3001\u4eca\u56de\u306fv1.4\u3068v2.0\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u30c6\u30b9\u30c8\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>\u3069\u3061\u3089\u3082\u540c\u3058\u30d7\u30ed\u30f3\u30d7\u30c8\u3067\u6bd4\u8f03\u3059\u308b\u3068\u3001v2.0\u306f\u3001\u660e\u3089\u304b\u306b\u751f\u6210\u753b\u50cf\u306e\u8cea\u304c\u9ad8\u304b\u3063\u305f\u3067\u3059\u304c\u3001\u305d\u306e\u3076\u3093\u751f\u6210\u306b\u8981\u3059\u308b\u6642\u9593\u304c\u304b\u304b\u308b\u3053\u3068\u304c\u308f\u304b\u308a\u307e\u3057\u305f\u3002v1.4\u3067\u306f13\u79d2\u3060\u3063\u305f\u306e\u306b\u5bfe\u3057\u3066\u3001v2.0\u3067\u306f2\u500d\u4ee5\u4e0a\u3068\u306a\u308b26\uff5e28\u79d2\u304b\u304b\u308a\u307e\u3057\u305f\u3002<\/p>\n\n<h2>\u74b0\u5883\u30b9\u30da\u30c3\u30af\u3068Python\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9<\/h2>\n<p><strong>\u4eee\u60f3\u30de\u30b7\u30f3\u30b9\u30da\u30c3\u30af<\/strong><br \/>GPU\uff1aNVIDIA Tesla T4<br \/>RAM\uff1a30GB<br \/>vCPUs\uff1a8<br \/>ROM\uff1a100GB<\/p>\n<p><strong>Kernel<\/strong><br \/>Pytorch(local)<\/p>\n<p>&nbsp;<\/p>\n<p><strong>\u30b3\u30fc\u30c9\uff08Python\uff09<\/strong><br \/>!pip install &#8211;upgrade git+https:\/\/github.com\/huggingface\/diffusers.git transformers accelerate scipy<\/p>\n<p>&nbsp;<\/p>\n<p><strong>\u30b3\u30fc\u30c9\uff08Python\uff09<br \/><\/strong>import torch<br \/>from diffusers import StableDiffusionPipeline<\/p>\n<p>model_id = &#8216;stabilityai\/stable-diffusion-2&#8217;<\/p>\n<p>pipe = StableDiffusionPipeline.from_pretrained(model_id, revision=&#8217;fp16&#8242;, torch_dtype=torch.float16)<br \/>pipe = pipe.to(&#8216;cuda&#8217;)<\/p>\n<p>prompt = &#8216;a photo of an astronaut riding a horse on mars&#8217;<br \/>image = pipe(prompt).images[0]<\/p>\n<p>\uff0d\uff0d\uff0d<\/p>\n<p>\u3053\u3053\u307e\u3067\u3067\u753b\u50cf\u304c\u751f\u6210\u3055\u308c\u305f\u3089\u69cb\u7bc9\u5b8c\u4e86\u3002<\/p>\n<p>\u306a\u304a\u3001\u5b9f\u969b\u306e\u751f\u6210\u3067\u306f\u4e0b\u8a18\u3092\u4f7f\u7528\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>for num in range(300):<br \/>generator = torch.Generator(&#8216;cuda&#8217;).manual_seed(num)<br \/>prompt = &#8220;white rabbit mt.fuji,sun rise\u3000Korin Ogata perfect lighting kabuki Landscap&#8221;<br \/>image = pipe(prompt).images[0]<br \/># \u751f\u6210\u3057\u305f\u753b\u50cf\u306e\u4fdd\u5b58<br \/>image.save(&#8220;rabbit_V&#8221;+str(num)+&#8221;seed=&#8221;+str(num)+&#8221;prompt=&#8221;+prompt+&#8221;.png&#8221;<\/p>","protected":false},"excerpt":{"rendered":"<p>\u81ea\u793e\u306e\u5e74\u8cc0\u72b6\u7528\u753b\u50cf\u3092\u3001\u753b\u50cf\u751f\u6210AI\u300cStable Diffusion\u300d\u3067\u4f5c\u3063\u3066\u307f\u305f\uff5e\u74b0\u5883\u69cb\u7bc9\u7de8 \u5b9f\u306f\u74b0\u5883\u69cb\u7bc9\u307e\u3067\u306b\u6642\u9593\u304c\u639b\u304b\u308a\u307e\u3057\u305f \u6628\u5e74\u672b\u306b\u516c\u958b\u3057\u305f\u3001\u753b\u50cf\u751f\u6210AI\u300cStable Diffusion\u300d\u3092\u4f7f\u3063\u305f\u5e74\u8cc0\u72b6\u753b\u50cf\u306e [&hellip;]<\/p>\n","protected":false},"author":75,"featured_media":2991,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"content-type":"","swell_btn_cv_data":"","footnotes":"","_wp_rev_ctl_limit":""},"categories":[1249],"tags":[96,330,329,143,332,331,308,282,309],"class_list":["post-3070","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-knowledge","tag-ai","tag-cloud-shell","tag-deeplearning-vm","tag-gcp","tag-jupyter-notebook","tag-python","tag-stable-diffusion","tag-282"],"_links":{"self":[{"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/posts\/3070","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/users\/75"}],"replies":[{"embeddable":true,"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/comments?post=3070"}],"version-history":[{"count":1,"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/posts\/3070\/revisions"}],"predecessor-version":[{"id":3071,"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/posts\/3070\/revisions\/3071"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/media\/2991"}],"wp:attachment":[{"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/media?parent=3070"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/categories?post=3070"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/tags?post=3070"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}