feat: add googleusercontent

--no-gradio-queue need
main
Bingsu 2023-05-10 20:40:09 +09:00
parent 3470a136ea
commit bbc0e33f34
3 changed files with 36 additions and 0 deletions

View File

@ -32,6 +32,12 @@ add `--bore` to commandline options.
add `--bore_url "URL"` for custom bore url. url without 'http://' and (optional) port. example: myboreserver.com or myboreserver.com:12345
### googleusercontent
add `--googleusercontent` to commandline options. It must be used with `--no-gradio-queue`, otherwise it will not work.
If not in google colab, it will be ignored.
-----
### Discord webhook

View File

@ -38,6 +38,12 @@ def preload(parser: argparse.ArgumentParser):
help="custom bore url. url without 'http://' and (optional) port. example: myboreserver.com or myboreserver.com:12345",
)
parser.add_argument(
"--googleusercontent",
action="store_true",
help="use googleusercontent, only available in the google colab. must be used with --no-gradio-queue",
)
parser.add_argument(
"--tunnel-webhook", type=str, help="discord webhook to send tunnel url to"
)

View File

@ -0,0 +1,24 @@
import os
from discord_webhook import send_to_discord
from modules.shared import cmd_opts
is_colab = "COLAB_RELEASE_TAG" in os.environ or "COLAB_BACKEND_VERSION" in os.environ
if is_colab and cmd_opts.googleusercontent:
print("googleusercontent detected, trying to connect...")
if not getattr(cmd_opts, "no_gradio_queue", True):
msg = " * If without `--no-gradio-queue` option, it will not work on google colab."
print(msg)
from google.colab.output import eval_js
port = cmd_opts.port if cmd_opts.port else 7860
js = "google.colab.kernel.proxyPort(" + str(port) + ", {'cache': false})"
tunnel_url = eval_js(js)
print(f" * Running on {tunnel_url}")
if cmd_opts.tunnel_webhook:
send_to_discord(tunnel_url, cmd_opts.tunnel_webhook)