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

[Bug]: Gradio not starting offline, needs external CSS to start webUI #10024

Closed
1 task done
neojam opened this issue May 2, 2023 · 12 comments · Fixed by #10324
Closed
1 task done

[Bug]: Gradio not starting offline, needs external CSS to start webUI #10024

neojam opened this issue May 2, 2023 · 12 comments · Fixed by #10324
Labels
bug-report Report of a bug, yet to be confirmed

Comments

@neojam
Copy link

neojam commented May 2, 2023

Is there an existing issue for this?

  • I have searched the existing issues and checked the recent builds/commits

What happened?

I cant use WebUI offline anymore after the last big Update from a few days ago.
Gradio hangs, showing only rotating squares when you open WebUI-URL.

Its looks like it tries to access following css indefinitely and doesnt work without an access to those:
https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;600&display=swap
https://fonts.googleapis.com/css2?family=Source+Sans+Pro:wght@400;600&display=swap

Steps to reproduce the problem

  1. Go offline
  2. start "webui-user.bat" and wait until "Running on local URL: http://127.0.0.1:7860" shows up
  3. start browser, go to above URL
  4. look at the rotating squares in browser indefinitely

What should have happened?

  1. WebUI Interface should have opened

Commit where the problem happens

somewhere after 22bcc7b

What platforms do you use to access the UI ?

Windows

What browsers do you use to access the UI ?

Mozilla Firefox

Command Line Arguments

set PYTHON=
set GIT=
set VENV_DIR=

set COMMANDLINE_ARGS= --no-half-vae --opt-sdp-no-mem-attention --opt-channelslast --theme dark ^
--ckpt-dir         "D:\SD_STUFF\Models\_active" ^
--embeddings-dir   "D:\SD_STUFF\embeddings\_active" ^
--hypernetwork-dir "D:\SD_STUFF\hypernetworks\_active" ^
--lora-dir         "D:\SD_STUFF\LoRA\_active"

List of extensions

None. I cleared the "extensions" DIR for the test

Console logs

no errors shown

Additional information

I was able to reproduce the problem when I was online by blocking access to "fonts.googleapis.com" with umatrix.
Only after unblocking the above url i was able to load webui interface.

1
2
3

@neojam neojam added the bug-report Report of a bug, yet to be confirmed label May 2, 2023
@dilectiogames
Copy link

same here. how do we fix this?

@HenryAhnburger
Copy link

I've run into this same issue on Ubuntu 22.04

@organiclogic
Copy link

It has been a long running issue with gradio based on my reads. I performed a git pull yesterday and ended up with the same results. Gradio was updated to 3.16 and would no longer load frontend without internet.

I fell back on an older backup where my venv was running Gradio 3.8 and it works fine. Oddly enough the same font.googleapi's references are present in both, so there may have been a change in timeouts (or lack thereof) in the Gradio logic. Pure speculation on my part as I haven't dug very deep on it, but there are other SD/TI bug reports on the same issue. So it seems it is not specific to 1111's repo.

I know that Gradio 3.8 works offline =but= it is also running an older commit of automatic1111. I tried to downgrade gradio on the latest automatic1111 code base and there are a bunch of UI errors that result.

I'll link to other non-automatic1111 reports of the same issue:

gradio-app/gradio#1450

That was my first landing regarding the issue. You can read up on it there as well as the "mentions" at the bottom being linked from other repos. Seems to be a common problem and most of them (outside of the link shown above) seem to be very recent, so some switch probably got thrown recently.

I dont upate often as my use-case is primarily seamless textures, but I do like to check out new features/extentions from time to time (just chose a bad time to try). Will have to pass on it until offline or some sane work around returns, however.

This is and has been a truly incredible project and many many thanks to all involved.

@dilectiogames
Copy link

I fell back on an older backup where my venv was running Gradio 3.8

how do you do that!??!

@neojam
Copy link
Author

neojam commented May 3, 2023

same here. how do we fix this?

In your \stable-diffusion-webui\modules\shared.py

add somewhere at top:

import urllib.request

and replace (at line 632):

def reload_gradio_theme(theme_name=None):
    global gradio_theme
    if not theme_name:
        theme_name = opts.gradio_theme

    if theme_name == "Default":
        gradio_theme = gr.themes.Default()
    else:
        try:
            gradio_theme = gr.themes.ThemeClass.from_hub(theme_name)
        except requests.exceptions.ConnectionError:
            print("Can't access HuggingFace Hub, falling back to default Gradio theme")
            gradio_theme = gr.themes.Default()

with

def reload_gradio_theme(theme_name=None):
    global gradio_theme
    if not theme_name:
        theme_name = opts.gradio_theme
    default_font_params = {}
    ret_code = 0
    try:
        req = urllib.request.Request("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono", method="HEAD")
        ret_code = urllib.request.urlopen(req, timeout=3.0).get_code()
    except:
        ret_code = 0
    if (ret_code != 200):
        print("No internet access detected, using default fonts")
        default_font_params = {
            'font':['Helvetica', 'ui-sans-serif', 'system-ui', 'sans-serif'],
            'font_mono':['IBM Plex Mono', 'ui-monospace', 'Consolas', 'monospace']
        }

    if theme_name == "Default":
        gradio_theme = gr.themes.Default(**default_font_params)
    else:
        try:
            gradio_theme = gr.themes.ThemeClass.from_hub(theme_name)
        except requests.exceptions.ConnectionError:
            print("Can't access HuggingFace Hub, falling back to default Gradio theme")
            gradio_theme = gr.themes.Default(**default_font_params)

works for me.

borrowed from:
vladmandic/automatic@8f236ef

@dilectiogames
Copy link

In your \stable-diffusion-webui\modules\shared.py

works here also. will see if it throws any errors in the next few days

@Isaac-the-Man
Copy link

Any chance that we get a fully offline mode for Gradio? Something like gradio my_app.py --offline would be great. A lot of corporate projects operates on a server with no external internet connection. The offline mode doesn't need any fancy CSS or interactive JS rendering, it just have to provide a simple UI interface.

@organiclogic
Copy link

organiclogic commented May 5, 2023

I fell back on an older backup where my venv was running Gradio 3.8

how do you do that!??!

I wish my solution was more profound, but I found out early on in this repo that if you have a version that does what you =need= but want to experiment, just backup the entire directory. I'm running on linux, so it may be different on other platforms, but yeah i just copy the entire stable-diffusion-web-ui folder somewhere on an external drive (usually i remove the model checkpoints first or exclude them in the copy because i back those up separately). Then i'll do my git pull and upgrade the project. If something goes sideways, i just delete the new and copy the original back (to the original folder location). Gradio is packaged nicely inside the /venv folder within the stable-diffusion-web-ui, so the gradio version comes along with it.

i'm sure there are easier/cleaner/official ways to revert, but being self contained after install makes it pretty easy to backup. I know this doesn't help the "after the fact" scenario, but its just what i started doing. The project evolves around a good amount of external dependency. I normally only keep one copy on hand and just replace it as I go through successful upgrades (that way you can revert without an internet connection too! XD ). Sorry it probably wasn't the answer you're looking for.

@dilectiogames
Copy link

Any chance that we get a fully offline mode for Gradio? Something like gradio my_app.py --offline would be great. A lot of corporate projects operates on a server with no external internet connection. The offline mode doesn't need any fancy CSS or interactive JS rendering, it just have to provide a simple UI interface.

just edit that file and change the code. it works offline with no problems

@Yankeedoody
Copy link

Oobabooga solved this problem in text-generation-webui by blocking the use of Google fonts. See oobabooga/text-generation-webui#867.

@catboxanon
Copy link
Collaborator

catboxanon commented May 12, 2023

This PR will resolve this, and also remove a phone-home request that Gradio makes, regardless of the value set for GRADIO_ANALYTICS_ENABLED.

#10324

@Sakura-Luna Sakura-Luna linked a pull request May 13, 2023 that will close this issue
@dilectiogames
Copy link

Can we find a solution to this that doesn't require me to edit shared.py file everytime I update automatic1111?

I don't care about the google tracking fonts, include comicsans as default, just let me start this offline if it happens to not have internet at that moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-report Report of a bug, yet to be confirmed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants