Redirect Gradio phone home request

This request is sent regardless of Gradio analytics being
enabled or not via the env var.
Idea from text-generation-webui.
This commit is contained in:
catboxanon 2023-05-12 18:06:13 +00:00
parent b4ad31ddd4
commit b14e23529f

View File

@ -28,7 +28,16 @@ warnings.filterwarnings(action="ignore", category=UserWarning, module="torchvisi
startup_timer.record("import torch") startup_timer.record("import torch")
import requests
def gradio_get(url, **kwargs):
kwargs.setdefault('allow_redirects', True)
return requests.api.request('get', 'http://127.0.0.1/', **kwargs)
original_get = requests.get
requests.get = gradio_get
import gradio import gradio
requests.get = original_get
startup_timer.record("import gradio") startup_timer.record("import gradio")
import ldm.modules.encoders.modules # noqa: F401 import ldm.modules.encoders.modules # noqa: F401