support sys.argv --listen --share --port
This commit is contained in:
lllyasviel 2023-08-14 06:56:23 -07:00 committed by GitHub
parent 50708f3d22
commit 7900480360
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 4 deletions

View File

@ -1 +1 @@
version = '1.0.24'
version = '1.0.25'

View File

@ -72,9 +72,16 @@ def download_models():
return
def cuda_malloc():
argv = sys.argv
sys.argv = [sys.argv[0]]
import cuda_malloc
sys.argv = argv
prepare_environment()
import cuda_malloc
cuda_malloc()
download_models()

View File

@ -21,7 +21,10 @@ def worker():
try:
async_gradio_app = shared.gradio_root
print(f'''App started successful. Use the app with {str(async_gradio_app.local_url)} or {str(async_gradio_app.server_name)}:{str(async_gradio_app.server_port)}''')
flag = f'''App started successful. Use the app with {str(async_gradio_app.local_url)} or {str(async_gradio_app.server_name)}:{str(async_gradio_app.server_port)}'''
if async_gradio_app.share:
flag += f''' or {async_gradio_app.share_url}'''
print(flag)
except Exception as e:
print(e)

View File

@ -1,3 +1,7 @@
### 1.0.25
* support sys.argv --listen --share --port
### 1.0.24
* Taller input textbox.

View File

@ -2,6 +2,7 @@ import gradio as gr
import sys
import time
import shared
import argparse
import modules.path
import fooocus_version
import modules.html
@ -94,4 +95,10 @@ with shared.gradio_root:
ctrls += [base_model, refiner_model] + lora_ctrls
run_button.click(fn=generate_clicked, inputs=ctrls, outputs=[run_button, progress_html, progress_window, gallery])
shared.gradio_root.launch(inbrowser=True, server_name='0.0.0.0' if '--listen' in sys.argv else None)
parser = argparse.ArgumentParser()
parser.add_argument("--listen", action='store_true', help="Listen remote port.")
parser.add_argument("--port", type=int, default=None, help="Set the listen port.")
parser.add_argument("--share", action='store_true', help="Set whether to share on Gradio.")
args = parser.parse_args()
shared.gradio_root.launch(inbrowser=True, server_name='0.0.0.0' if args.listen else None, server_port=args.port, share=args.share)