{"id":6194,"date":"2023-01-18T19:04:09","date_gmt":"2023-01-18T10:04:09","guid":{"rendered":"https:\/\/www.con3.com\/rinlab\/?p=6194"},"modified":"2023-11-10T20:51:07","modified_gmt":"2023-11-10T11:51:07","slug":"%e7%94%bb%e5%83%8f%e7%94%9f%e6%88%90ai%e3%82%92%e8%a9%a6%e3%81%99","status":"publish","type":"post","link":"https:\/\/www.con3.com\/rinlab\/?p=6194","title":{"rendered":"\u753b\u50cf\u751f\u6210AI\u3092\u8a66\u3059"},"content":{"rendered":"\n<p>\u3053\u306e\u5e74\u672b\u5e74\u59cb\u306f\u5e30\u7701\u3092\u3057\u3064\u3064\uff0c\u539f\u7a3f\u57f7\u7b46\u3092\u3057\u3066\u3044\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p>\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u4f53\u9a13\u30fb\u5b66\u7fd2\u306b\u95a2\u3059\u308b\u539f\u7a3f\u3067\u3057\u305f\u304c\uff0c\u4ed6\u3068\u9055\u3063\u305f\u89d2\u5ea6\u304b\u3089\u7167\u3089\u3057\u305f\u3082\u306e\u306b\u3057\u3088\u3046\u3068\u60aa\u6226\u82e6\u95d8\u3057\u3066\u307e\u3057\u305f\u3002\u8a73\u3057\u304f\u306f\u307e\u305f\u6a5f\u4f1a\u3092\u3042\u3089\u305f\u3081\u3066\u66f8\u3053\u3046\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>&#8212;<\/p>\n\n\n\n<p>\u7de0\u5207\u4ed5\u4e8b\u304b\u3089\u89e3\u653e\u3055\u308c\u3066\uff0c\u3088\u3046\u3084\u304f\u753b\u50cf\u751f\u6210\u7cfb\u306eAI\u3092\u81ea\u5206\u306e\u30d1\u30bd\u30b3\u30f3\u74b0\u5883\u306b\u5c0e\u5165\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p>\u3053\u306e\u8a18\u4e8b\u306e\u30a2\u30a4\u30ad\u30e3\u30c3\u30c1\u753b\u50cf\u306f\u305d\u306e\u753b\u50cf\u751f\u6210AI\u30e2\u30c7\u30eb\u306e\u4e00\u3064\u3067\u3042\u308b\u300c<a rel=\"noreferrer noopener\" href=\"https:\/\/huggingface.co\/andite\/anything-v4.0\" target=\"_blank\">Anything-v4.0<\/a>\u300d\u3092\u5c0e\u5165\u3057\u3066\u63cf\u753b\u3055\u305b\u305f\u3082\u306e\u3067\u3059\u3002<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.con3.com\/rinlab\/wp-content\/uploads\/2023\/01\/1a7a96bb941572753c85e5c454233a2e-1024x771.png\" alt=\"\" class=\"wp-image-6196\" width=\"512\" height=\"386\" srcset=\"https:\/\/www.con3.com\/rinlab\/wp-content\/uploads\/2023\/01\/1a7a96bb941572753c85e5c454233a2e-1024x771.png 1024w, https:\/\/www.con3.com\/rinlab\/wp-content\/uploads\/2023\/01\/1a7a96bb941572753c85e5c454233a2e-300x226.png 300w, https:\/\/www.con3.com\/rinlab\/wp-content\/uploads\/2023\/01\/1a7a96bb941572753c85e5c454233a2e-768x578.png 768w, https:\/\/www.con3.com\/rinlab\/wp-content\/uploads\/2023\/01\/1a7a96bb941572753c85e5c454233a2e-1536x1157.png 1536w, https:\/\/www.con3.com\/rinlab\/wp-content\/uploads\/2023\/01\/1a7a96bb941572753c85e5c454233a2e-2048x1542.png 2048w, https:\/\/www.con3.com\/rinlab\/wp-content\/uploads\/2023\/01\/1a7a96bb941572753c85e5c454233a2e-150x113.png 150w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/figure>\n<\/div>\n\n\n<p>\u3053\u308c\u306f\u300c1boy, computer, typing, looking screen, indoor, casual\u300d\u3068\u3044\u3046\u30d7\u30ed\u30f3\u30d7\u30c8\uff08\u753b\u50cf\u63cf\u753b\u3055\u305b\u308b\u305f\u3081\u306e\u30ad\u30fc\u30ef\u30fc\u30c9\u7fa4\uff09\u3092\u6307\u5b9a\u3057\u3066\uff0c\u6a2a\u9577\u30b5\u30a4\u30ba\u306b\u6307\u5b9a\u3057\u305f\u7d50\u679c\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u540c\u3058\u6761\u4ef6\u3067\u3082\u63cf\u753b\u3055\u305b\u308b\u5ea6\u306b\u753b\u50cf\u304c\u5909\u308f\u308b\u306e\u3067\uff0c\u4eca\u56de\u30823\u56de\u76ee\u306b\u63cf\u753b\u3055\u305b\u305f\u7d50\u679c\u3092\u63a1\u7528\u3057\u305f\u3082\u306e\u3067\u3059\u3002\u3053\u306e\u8fba\u306f\u5c0e\u5165\u306e\u4ed5\u65b9\u306b\u3088\u3063\u3066\u751f\u6210\u306e\u624b\u9806\u306f\u7570\u306a\u3063\u3066\u304f\u308b\u306e\u3067\uff0c1\u679a1\u679a\u63cf\u304b\u305b\u308b\u30d1\u30bf\u30fc\u30f3\u3082\u3042\u308c\u3070\uff0c\u81ea\u52d5\u7684\u306b\u8907\u6570\u679a\u306e\u753b\u50cf\u3092\u751f\u6210\u3055\u305b\u308b\u3084\u308a\u65b9\u3082\u3042\u308a\u307e\u3059\u3002\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u3067\u6e08\u307e\u3059\u4eba\u3082\u3044\u308c\u3070\uff0cWebUI\u3092\u5229\u7528\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>&#8212;<\/p>\n\n\n\n<p>\u5c0e\u5165\u624b\u9806\u306f\u7c21\u5358\u3067\uff0c\u305f\u3068\u3048\u3070WebUI\u3067\u4f7f\u3044\u305f\u3051\u308c\u3070\u2026<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Python<\/li>\n\n\n\n<li>python\u30e9\u30a4\u30d6\u30e9\u30ea\n<ul class=\"wp-block-list\">\n<li>torch<\/li>\n\n\n\n<li>diffusers<\/li>\n\n\n\n<li>gradio<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>\u5b66\u7fd2\u30e2\u30c7\u30eb\n<ul class=\"wp-block-list\">\n<li>Stable Diffusion v2-1<\/li>\n\n\n\n<li>Anything-v4.0<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p>\u3068\u3044\u3063\u305f\u3082\u306e\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\uff0cpython\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u8d77\u52d5\u3059\u308b\u3068\u30ed\u30fc\u30ab\u30eb\u3067Web\u753b\u9762\u3092\u958b\u304f\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u305d\u308c\u3089\u306f\u3044\u308d\u3093\u306a\u65b9\u3005\u304c\u30cd\u30c3\u30c8\u3067\u3084\u308a\u65b9\u3092\u30b7\u30a7\u30a2\u3057\u3066\u304f\u3060\u3055\u3063\u3066\u3044\u308b\u306e\u3067\u53c2\u8003\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p>\u3061\u3087\u3063\u3068\u96d1\u306b\u306a\u308a\u307e\u3059\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u624b\u9806\u306f\u304a\u304a\u3080\u306d\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u611f\u3058\u3067\u3059\u3002<\/p>\n\n\n\n<p>\uff08\u5404\u81ea\u306e\u74b0\u5883\u306b\u3088\u3063\u3066\u30b3\u30de\u30f3\u30c9\u306f\u5909\u308f\u3063\u3066\u304d\u307e\u3059\u306e\u3067\uff0c\u305d\u306e\u8fba\u306e\u8aac\u660e\u306f\u3054\u3081\u3093\u306a\u3055\u3044\u3057\u307e\u3059\u3002\uff09<\/p>\n\n\n\n<p>Mac\u3067\u3042\u308c\u3070\uff0c\u3082\u3057Python\u304c\u672a\u5c0e\u5165\u306a\u3089<a href=\"https:\/\/brew.sh\/index_ja\" target=\"_blank\" rel=\"noreferrer noopener\">Homebrew<\/a>\u3092\u4f7f\u3063\u3066Python\u5165\u308c\u3066\u3082\u3044\u3044\u3067\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>brew install python@3.10<\/code><\/pre>\n\n\n\n<p>\u3042\u3068\u306fpip\u3082\u3057\u304f\u306fpip3\u3067\u30e9\u30a4\u30d6\u30e9\u30ea\u5c0e\u5165\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip3 install torch<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>pip3 install --upgrade diffusers transformers accelerate<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>pip3 install gradio<\/code><\/pre>\n\n\n\n<p>\u305d\u308c\u304b\u3089\u5c0e\u5165\u30c4\u30fc\u30eb\u306e\u5c0e\u5165\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>brew install git-lfs<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>git lfs install<\/code><\/pre>\n\n\n\n<p>\uff08git LFS\u306b\u3064\u3044\u3066\u306f<a rel=\"noreferrer noopener\" href=\"https:\/\/docs.github.com\/ja\/repositories\/working-with-files\/managing-large-files\/installing-git-large-file-storage\" target=\"_blank\">\u3053\u3061\u3089<\/a>\uff09<\/p>\n\n\n\n<p>\u305d\u3057\u3066\u5b66\u7fd2\u30e2\u30c7\u30eb\u306e\u5c0e\u5165\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git clone <a href=\"https:\/\/huggingface.co\/stabilityai\/stable-diffusion-2-1\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/huggingface.co\/stabilityai\/stable-diffusion-2-1<\/a><\/code><\/pre>\n\n\n\n<p>\u3042\u308b\u3044\u306f<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git clone&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/huggingface.co\/andite\/anything-v4.0\" target=\"_blank\">https:\/\/huggingface.co\/andite\/anything-v4.0<\/a><\/code><\/pre>\n\n\n\n<p>\u305d\u3057\u305f\u3089\u6b21\u306epython\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u30d5\u30a1\u30a4\u30eb\u306b\u4fdd\u5b58\u3057\u3066\u52d5\u304b\u3057\u307e\u3059\u3002\uff08\u30d5\u30a1\u30a4\u30eb\u540d\u306f\u4efb\u610f\u3067\u53ef\uff09<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import gradio as gr\nimport torch\nimport click\nimport datetime\nimport random\nfrom diffusers import StableDiffusionPipeline\nimport numpy as np\n\n# \u5b66\u7fd2\u30e2\u30c7\u30eb\u3092\u9078\u3076\nai_model = \".\/stable-diffusion-2-1\"\n# ai_model = \".\/anything-v4.0\"\n\ndef generate(prompt, nega_prom, height, width, steps, cfg, seed):\n    pipe = StableDiffusionPipeline.from_pretrained(\n      ai_model,\n    )\n\n    pipe.safety_checker = lambda images, **kwargs: (images, &#91;False] * len(images))\n    if seed == \"\":\n      seed = int(random.randrange(4294967294))\n    else:\n      seed = int(seed)\n    print(f\"Seed value : {seed}\")\n    latents = torch.tensor(get_latents_from_seed(seed, width, height))\n\n    gen_img = pipe(prompt=prompt, negative_prompt=nega_prom, height=height, width=width, num_inference_steps=steps, guidance_scale=cfg, latents=latents).images&#91;0]\n    gen_img.save(f\".\/any3_step{steps}-cfg{cfg}-{seed}.png\")\n    return gen_img\n\ndef get_latents_from_seed(seed: int, width: int, height:int) -> np.ndarray:\n    # 1 is batch size\n    latents_shape = (1, 4, height \/\/ 8, width \/\/ 8)\n    # Gotta use numpy instead of torch, because torch's randn() doesn't support DML\n    rng = np.random.default_rng(seed)\n    image_latents = rng.standard_normal(latents_shape).astype(np.float32)\n    return image_latents\n\n\nwebui = gr.Interface(fn=generate,\n                     inputs=&#91;\n                     gr.Textbox(label = 'Prompt text', value=\"\", lines=2, elem_id=\"prompt\"),\n                     gr.Textbox(label = 'Negative Prompt text', value=\"\", lines=2, elem_id=\"nega_prom\"),\n                     gr.Slider(minimum=64, maximum=1024, step=64, label=\"\u7e26\u30b5\u30a4\u30ba(px)\", value=768, elem_id=\"height\"),\n                     gr.Slider(minimum=64, maximum=1024, step=64, label=\"\u6a2a\u30b5\u30a4\u30ba(px)\", value=512, elem_id=\"width\"),\n                     gr.Slider(minimum=10, maximum=150, step=1, label=\"\u30b9\u30c6\u30c3\u30d7\u6570\", value=25, elem_id=\"steps\"),\n                     gr.Slider(minimum=1, maximum=10, step=0.5, label='CFG', value=7.5, elem_id=\"cfg\"),\n                     gr.Textbox(label = 'seed', value=None, placeholder=\"0 - 4294967294. Blank is random.\", elem_id=\"seed\"),\n                     ],\n                     outputs=gr.Image().style(height=768)\n                     )\nwebui.launch()<\/code><\/pre>\n\n\n\n<p>Python\u30b9\u30af\u30ea\u30d7\u30c8\u306b\u3064\u3044\u3066\u53c2\u8003\u306b\u3057\u305fWeb\u30da\u30fc\u30b8\u306f<a href=\"https:\/\/dolls.tokyo\/howto_amd_anything_webui\/\" target=\"_blank\" rel=\"noreferrer noopener\">\u3053\u3061\u3089<\/a>\uff08\u611f\u8b1d\u611f\u8b1d\uff09\u3002<\/p>\n\n\n\n<p>&#8212;<\/p>\n\n\n\n<p>\u672c\u6765\u3067\u3042\u308c\u3070\uff0c\u753b\u50cf\u751f\u6210\u7cfbAI\u306b\u3064\u3044\u3066\u6574\u7406\u3057\u3066\u304b\u3089\u66f8\u304d\u305f\u3044\u3068\u3053\u308d\u3067\u3059\u304c\uff0c\u305d\u308c\u3082\u307e\u305f\u5225\u306e\u6a5f\u4f1a\u306b\u3002<\/p>\n\n\n\n<p>\u79c1\u81ea\u8eab\u306f\u307e\u3060\u751f\u6210\u7cfbAI\u3092\u3069\u306e\u3088\u3046\u306b\u81ea\u5206\u306e\u751f\u7523\u6d3b\u52d5\u306b\u6d3b\u304b\u3059\u3068\u3088\u3044\u306e\u304b\u6a21\u7d22\u4e2d\u3067\u3059\u304c\uff0c\u53ef\u80fd\u6027\u304c\u3042\u308b\u3053\u3068\u306f\u5acc\u3068\u3044\u3046\u307b\u3069\u611f\u3058\u3066\u3044\u308b\u306e\u3067\uff0c\u4f55\u304b\u3057\u3089\u81ea\u5206\u3067\u53d6\u308a\u7d44\u3080\u7cf8\u53e3\u3092\u898b\u3064\u3051\u51fa\u3057\u3066\u307f\u3088\u3046\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3067\u3082\u751f\u6210\u3057\u305f\u753b\u50cf\u3092\u30d6\u30ed\u30b0\u8a18\u4e8b\u306e\u30a2\u30a4\u30ad\u30e3\u30c3\u30c1\u753b\u50cf\u306b\u3059\u308b\u306e\u306f\uff0c\u5730\u5473\u306b\u5b9f\u7528\u7684\u304b\u3082\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u306e\u5e74\u672b\u5e74\u59cb\u306f\u5e30\u7701\u3092\u3057\u3064\u3064\uff0c\u539f\u7a3f\u57f7\u7b46\u3092\u3057\u3066\u3044\u307e\u3057\u305f\u3002 \u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u4f53\u9a13\u30fb\u5b66\u7fd2\u306b\u95a2\u3059\u308b\u539f\u7a3f\u3067\u3057\u305f\u304c\uff0c\u4ed6\u3068\u9055\u3063\u305f\u89d2\u5ea6\u304b\u3089\u7167\u3089\u3057\u305f\u3082\u306e\u306b\u3057\u3088\u3046\u3068\u60aa\u6226\u82e6\u95d8\u3057\u3066\u307e\u3057\u305f\u3002\u8a73\u3057\u304f\u306f\u307e\u305f\u6a5f\u4f1a\u3092\u3042\u3089\u305f\u3081\u3066\u66f8\u3053\u3046\u3068\u601d\u3044\u307e\u3059\u3002 &#038;#8212 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":6195,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4],"tags":[184],"class_list":["post-6194","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-activity","tag-ai"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.con3.com\/rinlab\/wp-content\/uploads\/2023\/01\/tmp8fi9d0ma.png","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p4WGyZ-1BU","jetpack_likes_enabled":false,"_links":{"self":[{"href":"https:\/\/www.con3.com\/rinlab\/index.php?rest_route=\/wp\/v2\/posts\/6194","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.con3.com\/rinlab\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.con3.com\/rinlab\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.con3.com\/rinlab\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.con3.com\/rinlab\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6194"}],"version-history":[{"count":17,"href":"https:\/\/www.con3.com\/rinlab\/index.php?rest_route=\/wp\/v2\/posts\/6194\/revisions"}],"predecessor-version":[{"id":6221,"href":"https:\/\/www.con3.com\/rinlab\/index.php?rest_route=\/wp\/v2\/posts\/6194\/revisions\/6221"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.con3.com\/rinlab\/index.php?rest_route=\/wp\/v2\/media\/6195"}],"wp:attachment":[{"href":"https:\/\/www.con3.com\/rinlab\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6194"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.con3.com\/rinlab\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6194"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.con3.com\/rinlab\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6194"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}