Workaround of Gradio --share UI hang with ngrok
diff --git a/launch.py b/launch.py
index e1000f55951..16627a032db 100644
--- a/launch.py
+++ b/launch.py
@@ -104,6 +104,7 @@ def prepare_enviroment():
     args, skip_torch_cuda_test = extract_arg(args, '--skip-torch-cuda-test')
     xformers = '--xformers' in args
     deepdanbooru = '--deepdanbooru' in args
+    ngrok = '--ngrok' in args
 
     try:
         commit = run(f"{git} rev-parse HEAD").strip()
@@ -134,6 +135,9 @@ def prepare_enviroment():
     if not is_installed("deepdanbooru") and deepdanbooru:
         run_pip("install git+https://github.com/KichangKim/DeepDanbooru.git@edf73df4cdaeea2cf00e9ac08bd8a9026b7a7b26#egg=deepdanbooru[tensorflow] tensorflow==2.10.0 tensorflow-io==0.27.0", "deepdanbooru")
 
+    if not is_installed("pyngrok") and ngrok:
+        run_pip("install pyngrok", "ngrok")
+
     os.makedirs(dir_repos, exist_ok=True)
 
     git_clone("https://github.com/CompVis/stable-diffusion.git", repo_dir('stable-diffusion'), "Stable Diffusion", stable_diffusion_commit_hash)
diff --git a/modules/ngrok.py b/modules/ngrok.py
new file mode 100644
index 00000000000..7d03a6df59e
--- /dev/null
+++ b/modules/ngrok.py
@@ -0,0 +1,15 @@
+from pyngrok import ngrok, conf, exception
+
+
+def connect(token, port):
+    if token == None:
+        token = 'None'
+    conf.get_default().auth_token = token
+    try:
+        public_url = ngrok.connect(port).public_url
+    except exception.PyngrokNgrokError:
+        print(f'Invalid ngrok authtoken, ngrok connection aborted.\n'
+              f'Your token: {token}, get the right one on https://dashboard.ngrok.com/get-started/your-authtoken')
+    else:
+        print(f'ngrok connected to localhost:{port}! URL: {public_url}\n'
+               'You can use this link after the launch is complete.')
diff --git a/modules/shared.py b/modules/shared.py
index 14b40d70d5a..f1d3086a926 100644
--- a/modules/shared.py
+++ b/modules/shared.py
@@ -36,6 +36,7 @@
 parser.add_argument("--unload-gfpgan", action='store_true', help="does not do anything.")
 parser.add_argument("--precision", type=str, help="evaluate at this precision", choices=["full", "autocast"], default="autocast")
 parser.add_argument("--share", action='store_true', help="use share=True for gradio and make the UI accessible through their site (doesn't work for me but you might have better luck)")
+parser.add_argument("--ngrok", type=str, help="ngrok authtoken, alternative to gradio --share", default=None)
 parser.add_argument("--codeformer-models-path", type=str, help="Path to directory with codeformer model file(s).", default=os.path.join(models_path, 'Codeformer'))
 parser.add_argument("--gfpgan-models-path", type=str, help="Path to directory with GFPGAN model file(s).", default=os.path.join(models_path, 'GFPGAN'))
 parser.add_argument("--esrgan-models-path", type=str, help="Path to directory with ESRGAN model file(s).", default=os.path.join(models_path, 'ESRGAN'))
diff --git a/modules/ui.py b/modules/ui.py
index ca3151c474c..acac15b4b3b 100644
--- a/modules/ui.py
+++ b/modules/ui.py
@@ -50,6 +50,11 @@
     gradio.utils.version_check = lambda: None
     gradio.utils.get_local_ip_address = lambda: '127.0.0.1'
 
+if cmd_opts.ngrok != None:
+    import modules.ngrok as ngrok
+    print('ngrok authtoken detected, trying to connect...')
+    ngrok.connect(cmd_opts.ngrok, cmd_opts.port if cmd_opts.port != None else 7860)
+
 
 def gr_show(visible=True):
     return {"visible": visible, "__type__": "update"}

Gradio share feature hangs WebUI after generating first batch of more than one images. When using UI in local, though, everything seems normal.
So I implemented ngrok functionality that can be used to create public link to the WebUI while not using gradio.app.
First, you need to sign up on ngrok website, and get an authtoken. Then you can use it with command-line argument `--ngrok <authtoken>`.
I also [edited the first colab notebook](https://colab.research.google.com/drive/1kiWnIFYbq4mk2JtVNfxwlo3NuVUpiFzb?usp=sharing) from ReadMe: I fixed double download of a standard SD model, added a link to waifu-diffusion one and explanation of `--ngrok` argument. This notebook is temporary, as it'll be useless after merging.

P.S. Apparently, PaperSpace locks your account if you launch ngrok proxy in it, so you shouldn't use ngrok with it. Also, please be careful in other cloud solutions. The only one that I can confirm working fine with ngrok is Google Colab.