Add --nowebui as a means of disabling the webui and run on the other port
This commit is contained in:
parent
247aeb3aaa
commit
1df3ff25e6
@ -74,7 +74,8 @@ parser.add_argument("--disable-console-progressbars", action='store_true', help=
|
|||||||
parser.add_argument("--enable-console-prompts", action='store_true', help="print prompts to console when generating with txt2img and img2img", default=False)
|
parser.add_argument("--enable-console-prompts", action='store_true', help="print prompts to console when generating with txt2img and img2img", default=False)
|
||||||
parser.add_argument('--vae-path', type=str, help='Path to Variational Autoencoders model', default=None)
|
parser.add_argument('--vae-path', type=str, help='Path to Variational Autoencoders model', default=None)
|
||||||
parser.add_argument("--disable-safe-unpickle", action='store_true', help="disable checking pytorch models for malicious code", default=False)
|
parser.add_argument("--disable-safe-unpickle", action='store_true', help="disable checking pytorch models for malicious code", default=False)
|
||||||
parser.add_argument("--api", action='store_true', help="use api=True to launch the api instead of the webui")
|
parser.add_argument("--api", action='store_true', help="use api=True to launch the api with the webui")
|
||||||
|
parser.add_argument("--nowebui", action='store_true', help="use api=True to launch the api instead of the webui")
|
||||||
|
|
||||||
cmd_opts = parser.parse_args()
|
cmd_opts = parser.parse_args()
|
||||||
restricted_opts = [
|
restricted_opts = [
|
||||||
|
35
webui.py
35
webui.py
@ -95,16 +95,34 @@ def initialize():
|
|||||||
signal.signal(signal.SIGINT, sigint_handler)
|
signal.signal(signal.SIGINT, sigint_handler)
|
||||||
|
|
||||||
|
|
||||||
def api():
|
def create_api(app):
|
||||||
from modules.api.api import Api
|
from modules.api.api import Api
|
||||||
api = Api(app)
|
api = Api(app)
|
||||||
|
return api
|
||||||
|
|
||||||
|
def wait_on_server(demo=None):
|
||||||
|
while 1:
|
||||||
|
time.sleep(0.5)
|
||||||
|
if demo and getattr(demo, 'do_restart', False):
|
||||||
|
time.sleep(0.5)
|
||||||
|
demo.close()
|
||||||
|
time.sleep(0.5)
|
||||||
|
break
|
||||||
|
|
||||||
|
def api_only():
|
||||||
|
initialize()
|
||||||
|
|
||||||
|
app = FastAPI()
|
||||||
|
app.add_middleware(GZipMiddleware, minimum_size=1000)
|
||||||
|
api = create_api(app)
|
||||||
|
|
||||||
|
api.launch(server_name="0.0.0.0" if cmd_opts.listen else "127.0.0.1", port=cmd_opts.port if cmd_opts.port else 7861)
|
||||||
|
|
||||||
|
|
||||||
def webui(launch_api=False):
|
def webui(launch_api=False):
|
||||||
initialize()
|
initialize()
|
||||||
|
|
||||||
while 1:
|
while 1:
|
||||||
|
|
||||||
demo = modules.ui.create_ui(wrap_gradio_gpu_call=wrap_gradio_gpu_call)
|
demo = modules.ui.create_ui(wrap_gradio_gpu_call=wrap_gradio_gpu_call)
|
||||||
|
|
||||||
app, local_url, share_url = demo.launch(
|
app, local_url, share_url = demo.launch(
|
||||||
@ -120,15 +138,9 @@ def webui(launch_api=False):
|
|||||||
app.add_middleware(GZipMiddleware, minimum_size=1000)
|
app.add_middleware(GZipMiddleware, minimum_size=1000)
|
||||||
|
|
||||||
if (launch_api):
|
if (launch_api):
|
||||||
api(app)
|
create_api(app)
|
||||||
|
|
||||||
while 1:
|
wait_on_server(demo)
|
||||||
time.sleep(0.5)
|
|
||||||
if getattr(demo, 'do_restart', False):
|
|
||||||
time.sleep(0.5)
|
|
||||||
demo.close()
|
|
||||||
time.sleep(0.5)
|
|
||||||
break
|
|
||||||
|
|
||||||
sd_samplers.set_samplers()
|
sd_samplers.set_samplers()
|
||||||
|
|
||||||
@ -142,6 +154,9 @@ def webui(launch_api=False):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
if not cmd_opts.nowebui:
|
||||||
|
api_only()
|
||||||
|
|
||||||
if cmd_opts.api:
|
if cmd_opts.api:
|
||||||
webui(True)
|
webui(True)
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user