Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow web UI to be ran fully offline #10324

Merged
merged 4 commits into from
May 13, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions modules/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,13 +666,19 @@ def reload_gradio_theme(theme_name=None):
theme_name = opts.gradio_theme

if theme_name == "Default":
gradio_theme = gr.themes.Default()
gradio_theme = gr.themes.Default(
font=['Helvetica', 'ui-sans-serif', 'system-ui', 'sans-serif'],
font_mono=['IBM Plex Mono', 'ui-monospace', 'Consolas', 'monospace'],
)
else:
try:
gradio_theme = gr.themes.ThemeClass.from_hub(theme_name)
except Exception as e:
errors.display(e, "changing gradio theme")
gradio_theme = gr.themes.Default()
gradio_theme = gr.themes.Default(
font=['Helvetica', 'ui-sans-serif', 'system-ui', 'sans-serif'],
font_mono=['IBM Plex Mono', 'ui-monospace', 'Consolas', 'monospace'],
)



Expand Down
9 changes: 9 additions & 0 deletions webui.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,16 @@

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
requests.get = original_get
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As an aside, this could probably be implemented as something like

Suggested change
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
requests.get = original_get
import requests
from unittest.mock import patch
with patch("requests.request", side_effect=requests.ConnectionError()):
import gradio


startup_timer.record("import gradio")

import ldm.modules.encoders.modules # noqa: F401
Expand Down