### 実現したいこと
Stable Diffusion(Google colab環境)でのimg2img及びControlNet使用時のエラー解決
前提
Stable Diffusion Web UIをGoogle colab環境で使用しています。
txt2imgは問題なく動作しているのですが、img2img及びControlNetの場合以下のエラーメッセージが発生して画像生成ができません。
発生している問題・エラーメッセージ
エラーメッセージ AttributeError: 'NoneType' object has no attribute 'to'
該当のソースコード
Python
1#@markdown # Start Stable-Diffusion 2from IPython.utils import capture 3import time 4import sys 5import fileinput 6from pyngrok import ngrok, conf 7 8Use_Cloudflare_Tunnel = False #@param {type:"boolean"} 9#@markdown - Offers better gradio responsivity 10 11Ngrok_token = "" #@param {type:"string"} 12 13#@markdown - Input your ngrok token if you want to use ngrok server 14 15User = "" #@param {type:"string"} 16Password= "" #@param {type:"string"} 17#@markdown - Add credentials to your Gradio interface (optional) 18 19auth=f"--gradio-auth {User}:{Password}" 20if User =="" or Password=="": 21 auth="" 22 23 24with capture.capture_output() as cap: 25 %cd /content/gdrive/$mainpth/sd/stable-diffusion-$blasphemy/modules/ 26 27 if Use_Latest_Working_Commit: 28 !wget -q -O paths.py https://github.com/TheLastBen/fast-stable-diffusion/raw/5632d2ef7fffd940976538d270854ec4faf26855/AUTOMATIC1111_files/paths.py 29 !wget -q -O extras.py https://github.com/AUTOMATIC1111/stable-diffusion-$blasphemy/raw/a9eab236d7e8afa4d6205127904a385b2c43bb24/modules/extras.py 30 !wget -q -O sd_models.py https://github.com/AUTOMATIC1111/stable-diffusion-$blasphemy/raw/a9eab236d7e8afa4d6205127904a385b2c43bb24/modules/sd_models.py 31 !wget -q -O /usr/local/lib/python3.10/dist-packages/gradio/blocks.py https://github.com/TheLastBen/fast-stable-diffusion/raw/7ff88eaa1fb4997bacd9845bd487f9a14335d625/AUTOMATIC1111_files/blocks.py 32 else: 33 !wget -q -O paths.py https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/AUTOMATIC1111_files/paths.py 34 !wget -q -O extras.py https://raw.githubusercontent.com/AUTOMATIC1111/stable-diffusion-$blasphemy/master/modules/extras.py 35 !wget -q -O sd_models.py https://raw.githubusercontent.com/AUTOMATIC1111/stable-diffusion-$blasphemy/master/modules/sd_models.py 36 !wget -q -O /usr/local/lib/python3.10/dist-packages/gradio/blocks.py https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/AUTOMATIC1111_files/blocks.py 37 %cd /content/gdrive/$mainpth/sd/stable-diffusion-$blasphemy/ 38 39 !sed -i "s@os.path.splitext(checkpoint_file)@os.path.splitext(checkpoint_file); map_location='cuda'@" /content/gdrive/$mainpth/sd/stable-diffusion-$blasphemy/modules/sd_models.py 40 !sed -i 's@ui.create_ui().*@ui.create_ui();shared.demo.queue(concurrency_count=999999,status_update_rate=0.1)@' /content/gdrive/$mainpth/sd/stable-diffusion-$blasphemy/webui.py 41 !sed -i "s@map_location='cpu'@map_location='cuda'@" /content/gdrive/$mainpth/sd/stable-diffusion-$blasphemy/modules/extras.py 42 !sed -i 's@/content/gdrive/MyDrive/sd/stablediffusion@/content/gdrive/{mainpth}/sd/stablediffusion@' /content/gdrive/$mainpth/sd/stable-diffusion-$blasphemy/modules/paths.py 43 !sed -i 's@print(\"No module.*@@' /content/gdrive/$mainpth/sd/stablediffusion/ldm/modules/diffusionmodules/model.py 44 !sed -i 's@\"quicksettings\": OptionInfo(.*@"quicksettings": OptionInfo("sd_model_checkpoint, sd_vae, CLIP_stop_at_last_layers, inpainting_mask_weight, initial_noise_multiplier", "Quicksettings list"),@' /content/gdrive/$mainpth/sd/stable-diffusion-$blasphemy/modules/shared.py 45 46share='' 47if Ngrok_token!="": 48 ngrok.kill() 49 srv=ngrok.connect(7860, pyngrok_config=conf.PyngrokConfig(auth_token=Ngrok_token) , bind_tls=True).public_url 50 51 for line in fileinput.input('/usr/local/lib/python3.10/dist-packages/gradio/blocks.py', inplace=True): 52 if line.strip().startswith('self.server_name ='): 53 line = f' self.server_name = "{srv[8:]}"\n' 54 if line.strip().startswith('self.protocol = "https"'): 55 line = ' self.protocol = "https"\n' 56 if line.strip().startswith('if self.loc 57 al_url.startswith("https") or self.is_colab'): 58 line = '' 59 if line.strip().startswith('else "http"'): 60 line = '' 61 sys.stdout.write(line) 62 63elif Use_Cloudflare_Tunnel: 64 with capture.capture_output() as cap: 65 !pkill cloudflared 66 time.sleep(4) 67 !nohup cloudflared tunnel --url http://localhost:7860 > /content/srv.txt 2>&1 & 68 time.sleep(4) 69 !grep -o 'https[^[:space:]]*\.trycloudflare.com' /content/srv.txt >/content/srvr.txt 70 time.sleep(2) 71 srv= getoutput('cat /content/srvr.txt') 72 73 for line in fileinput.input('/usr/local/lib/python3.10/dist-packages/gradio/blocks.py', inplace=True): 74 if line.strip().startswith('self.server_name ='): 75 line = f' self.server_name = "{srv[8:]}"\n' 76 if line.strip().startswith('self.protocol = "https"'): 77 line = ' self.protocol = "https"\n' 78 if line.strip().startswith('if self.local_url.startswith("https") or self.is_colab'): 79 line = '' 80 if line.strip().startswith('else "http"'): 81 line = '' 82 sys.stdout.write(line) 83 84 !rm /content/srv.txt /content/srvr.txt 85 86else: 87 share='--share' 88 89try: 90 model 91 if os.path.isfile(model): 92 !python /content/gdrive/$mainpth/sd/stable-diffusion-$blasphemy/webui.py $share --api --disable-safe-unpickle --enable-insecure-extension-access --no-download-sd-model --no-half-vae --ckpt "$model" --opt-sdp-attention $auth --disable-console-progressbars 93 else: 94 !python /content/gdrive/$mainpth/sd/stable-diffusion-$blasphemy/webui.py $share --api --disable-safe-unpickle --enable-insecure-extension-access --no-download-sd-model --no-half-vae --ckpt-dir "$model" --opt-sdp-attention $auth --disable-console-progressbars 95except: 96 !python /content/gdrive/$mainpth/sd/stable-diffusion-$blasphemy/webui.py $share --api --disable-safe-unpickle --enable-insecure-extension-access --no-download-sd-model --no-half-vae --opt-sdp-attention $auth --disable-console-progressbars
試したこと
補足情報(FW/ツールのバージョンなど)
非エンジニアでYoutube動画を見ながら設定したので具体的なコードの中身がわかりませんが、多少のプログラミング知識はあります。
> エラーメッセージ
> AttributeError: 'NoneType' object has no attribute 'to'
上記エラーはどの箇所で発生したものでしょうか?
生成された画像が表示される部分の下にあるフォルダアイコンや"SAVE"ボタンなどがある列の下の部分になります。
追記:「Traceback」とは書かれておらず"AttributeError: 'NoneType' object has no attribute 'to'"が表示されています。
質問に記載のエラーメッセージよりも上に「Traceback」と書かれてたら、そこから下をできるだけ省略せずに質問に記載してください
(ここに書くのではなく、質問を編集して追記する)
> img2img及びControlNetの場合以下のエラーメッセージが発生して画像生成ができません。
Stable Diffusion Web UIをGoogle colabで試しても質問のエラーは発生しないようです。質問のコードは使っていないので、その「非エンジニアでYoutube動画を見ながら設定した」の動画の作成者に質問するのが良いかもですね。
Stable Diffusion Web UIをGoogle colabで実行しています。
実際のエラーがでているスクリーンショットを添付しました。
そうですよね。ありがとうございます。
日本語化されたバージョンなんですね。
画像を入力していないからではないですか?
スクショでは画像は消していますが入力していても同様のエラーとなります。
> スクショでは画像は消していますが入力していても同様のエラーとなります。
そうなんですね。
とりあえず日本語されていない元のを利用するのが回避策でしょうか?
ところでコード引用元を明記するべきかと思います。コードにも著作権があります。(転載禁止の場合はそもそもNGになりますが)
またそのYouTube動画のコメント欄では他の方はエラーなく使えている様子でしょうか?
>ところでコード引用元を明記するべきかと思います。コードにも著作権があります。
大変失礼しました。知識不足で申し訳ないです。
>またそのYouTube動画のコメント欄では他の方はエラーなく使えている様子でしょうか?
同様のエラー報告はありませんでした。
>とりあえず日本語されていない元のを利用するのが回避策でしょうか?
日本語化パッチを削除しましたが、変化はありませんでした。
