Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
S
stable-diffusion-webui
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
stable-diffusion-webui
Commits
c3851a85
Commit
c3851a85
authored
Oct 17, 2022
by
Ryan Voots
Committed by
AUTOMATIC1111
Oct 18, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Re-use webui fastapi application rather than requiring one or the other, not both.
parent
f29b16ba
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
11 deletions
+9
-11
api.py
modules/api/api.py
+2
-4
webui.py
webui.py
+7
-7
No files found.
modules/api/api.py
View file @
c3851a85
...
...
@@ -2,15 +2,13 @@ from modules.api.processing import StableDiffusionProcessingAPI
from
modules.processing
import
StableDiffusionProcessingTxt2Img
,
process_images
import
modules.shared
as
shared
import
uvicorn
from
fastapi
import
FastAPI
,
Body
,
APIRouter
from
fastapi
import
Body
,
APIRouter
from
fastapi.responses
import
JSONResponse
from
pydantic
import
BaseModel
,
Field
,
Json
import
json
import
io
import
base64
app
=
FastAPI
()
class
TextToImageResponse
(
BaseModel
):
images
:
list
[
str
]
=
Field
(
default
=
None
,
title
=
"Image"
,
description
=
"The generated image in base64 format."
)
parameters
:
Json
...
...
@@ -18,7 +16,7 @@ class TextToImageResponse(BaseModel):
class
Api
:
def
__init__
(
self
):
def
__init__
(
self
,
app
):
self
.
router
=
APIRouter
()
app
.
add_api_route
(
"/v1/txt2img"
,
self
.
text2imgapi
,
methods
=
[
"POST"
])
...
...
webui.py
View file @
c3851a85
...
...
@@ -96,14 +96,11 @@ def initialize():
def
api
():
initialize
()
from
modules.api.api
import
Api
api
=
Api
()
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
)
api
=
Api
(
app
)
def
webui
():
def
webui
(
launch_api
=
False
):
initialize
()
while
1
:
...
...
@@ -122,6 +119,9 @@ def webui():
app
.
add_middleware
(
GZipMiddleware
,
minimum_size
=
1000
)
if
(
launch_api
):
api
(
app
)
while
1
:
time
.
sleep
(
0.5
)
if
getattr
(
demo
,
'do_restart'
,
False
):
...
...
@@ -143,6 +143,6 @@ def webui():
if
__name__
==
"__main__"
:
if
cmd_opts
.
api
:
api
(
)
webui
(
True
)
else
:
webui
()
webui
(
False
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment