Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
Stable Diffusion Webui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
novelai-storage
Stable Diffusion Webui
Commits
8d5d863a
Commit
8d5d863a
authored
Oct 18, 2022
by
arcticfaded
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gradio and FastAPI
parent
1df3ff25
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
14 deletions
+15
-14
modules/api/api.py
modules/api/api.py
+8
-5
webui.py
webui.py
+7
-9
No files found.
modules/api/api.py
View file @
8d5d863a
...
@@ -16,9 +16,11 @@ class TextToImageResponse(BaseModel):
...
@@ -16,9 +16,11 @@ class TextToImageResponse(BaseModel):
class
Api
:
class
Api
:
def
__init__
(
self
,
app
):
def
__init__
(
self
,
app
,
queue_lock
):
self
.
router
=
APIRouter
()
self
.
router
=
APIRouter
()
app
.
add_api_route
(
"/sdapi/v1/txt2img"
,
self
.
text2imgapi
,
methods
=
[
"POST"
])
self
.
app
=
app
self
.
queue_lock
=
queue_lock
self
.
app
.
add_api_route
(
"/sdapi/v1/txt2img"
,
self
.
text2imgapi
,
methods
=
[
"POST"
])
def
text2imgapi
(
self
,
txt2imgreq
:
StableDiffusionProcessingAPI
):
def
text2imgapi
(
self
,
txt2imgreq
:
StableDiffusionProcessingAPI
):
populate
=
txt2imgreq
.
copy
(
update
=
{
# Override __init__ params
populate
=
txt2imgreq
.
copy
(
update
=
{
# Override __init__ params
...
@@ -30,6 +32,7 @@ class Api:
...
@@ -30,6 +32,7 @@ class Api:
)
)
p
=
StableDiffusionProcessingTxt2Img
(
**
vars
(
populate
))
p
=
StableDiffusionProcessingTxt2Img
(
**
vars
(
populate
))
# Override object param
# Override object param
with
self
.
queue_lock
:
processed
=
process_images
(
p
)
processed
=
process_images
(
p
)
b64images
=
[]
b64images
=
[]
...
@@ -52,5 +55,5 @@ class Api:
...
@@ -52,5 +55,5 @@ class Api:
raise
NotImplementedError
raise
NotImplementedError
def
launch
(
self
,
server_name
,
port
):
def
launch
(
self
,
server_name
,
port
):
app
.
include_router
(
self
.
router
)
self
.
app
.
include_router
(
self
.
router
)
uvicorn
.
run
(
app
,
host
=
server_name
,
port
=
port
)
uvicorn
.
run
(
self
.
app
,
host
=
server_name
,
port
=
port
)
webui.py
View file @
8d5d863a
...
@@ -4,7 +4,7 @@ import time
...
@@ -4,7 +4,7 @@ import time
import
importlib
import
importlib
import
signal
import
signal
import
threading
import
threading
from
fastapi
import
FastAPI
from
fastapi.middleware.gzip
import
GZipMiddleware
from
fastapi.middleware.gzip
import
GZipMiddleware
from
modules.paths
import
script_path
from
modules.paths
import
script_path
...
@@ -31,7 +31,6 @@ from modules.paths import script_path
...
@@ -31,7 +31,6 @@ from modules.paths import script_path
from
modules.shared
import
cmd_opts
from
modules.shared
import
cmd_opts
import
modules.hypernetworks.hypernetwork
import
modules.hypernetworks.hypernetwork
queue_lock
=
threading
.
Lock
()
queue_lock
=
threading
.
Lock
()
...
@@ -97,7 +96,7 @@ def initialize():
...
@@ -97,7 +96,7 @@ def initialize():
def
create_api
(
app
):
def
create_api
(
app
):
from
modules.api.api
import
Api
from
modules.api.api
import
Api
api
=
Api
(
app
)
api
=
Api
(
app
,
queue_lock
)
return
api
return
api
def
wait_on_server
(
demo
=
None
):
def
wait_on_server
(
demo
=
None
):
...
@@ -153,11 +152,10 @@ def webui(launch_api=False):
...
@@ -153,11 +152,10 @@ def webui(launch_api=False):
print
(
'Restarting Gradio'
)
print
(
'Restarting Gradio'
)
task
=
[]
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
if
not
cmd_opts
.
nowebui
:
if
cmd_opts
.
nowebui
:
api_only
()
api_only
()
if
cmd_opts
.
api
:
webui
(
True
)
else
:
else
:
webui
(
False
)
webui
(
cmd_opts
.
api
)
\ No newline at end of file
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