File size: 793 Bytes
2d875a7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
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)
|