From bfdeb5fed31182fd68a9728422636753a4f13caa Mon Sep 17 00:00:00 2001 From: ddPn08 <71378929+ddPn08@users.noreply.github.com> Date: Tue, 20 Dec 2022 15:48:35 +0900 Subject: [PATCH] small fix --- automatic1111.ipynb | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/automatic1111.ipynb b/automatic1111.ipynb index f09124e..add44da 100644 --- a/automatic1111.ipynb +++ b/automatic1111.ipynb @@ -190,6 +190,8 @@ "# @markdown  \n", "# @markdown ## Command line arguments\n", "\n", + "import os\n", + "\n", "no_half = False # @param {type:\"boolean\"}\n", "no_half_vae = False # @param {type:\"boolean\"}\n", "allow_code = False # @param {type:\"boolean\"}\n", @@ -239,15 +241,15 @@ "if os.path.exists(f\"{data_dir}/ngrok.txt\") and use_ngrok:\n", " with open(f\"{data_dir}/ngrok.txt\", mode=\"r\") as f:\n", " lines = f.readlines()\n", - " if not ngrok_auth_token:\n", - " ngrok_auth_token = lines[0]\n", - " if ngrok_region == \"auto\":\n", - " ngrok_region = lines[1]\n", + " if not ngrok_auth_token and len(lines) > 0:\n", + " ngrok_auth_token = lines[0].strip()\n", + " if ngrok_region == \"auto\" and len(lines) > 1:\n", + " ngrok_region = lines[1].strip()\n", "\n", "with open(f\"{data_dir}/ngrok.txt\", mode=\"w\") as f:\n", " f.write(f\"{ngrok_auth_token}\\n{ngrok_region}\")\n", "\n", - "if ngrok_region == \"auto\":\n", + "if not ngrok_region or ngrok_region == \"auto\":\n", " ngrok_region = \"us\"\n", "\n", "# @markdown  \n", @@ -274,16 +276,13 @@ "vars = \" \".join(advanced_options)\n", "if not use_ngrok:\n", " vars += \" --share\"\n", - "else:\n", + "elif ngrok_auth_token and ngrok_region:\n", " vars += f\" --ngrok {ngrok_auth_token} --ngrok-region {ngrok_region}\"\n", "\n", "if use_gradio_auth:\n", " vars += f\" --gradio-auth {gradio_auth_username}:{gradio_auth_password}\"\n", "\n", - "\n", - "import os\n", - "\n", - "os.environ['COMMANDLINE_ARGS'] = f\"{vars} {custom_arguments}\"\n" + "os.environ['COMMANDLINE_ARGS'] = f\"{vars} {custom_arguments}\"" ] }, {