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
fcd75bd8
Unverified
Commit
fcd75bd8
authored
Nov 24, 2022
by
Sena
Committed by
GitHub
Nov 24, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix other apis
parent
75b67eeb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
9 deletions
+7
-9
api.py
modules/api/api.py
+7
-9
No files found.
modules/api/api.py
View file @
fcd75bd8
...
...
@@ -4,7 +4,7 @@ import time
import
uvicorn
from
threading
import
Lock
from
io
import
BytesIO
from
gradio.processing_utils
import
encode_pil_to_base64
,
decode_base64_to_file
,
decode_base64_to_imag
e
from
gradio.processing_utils
import
decode_base64_to_fil
e
from
fastapi
import
APIRouter
,
Depends
,
FastAPI
,
HTTPException
from
fastapi.security
import
HTTPBasic
,
HTTPBasicCredentials
from
secrets
import
compare_digest
...
...
@@ -41,6 +41,10 @@ def setUpscalers(req: dict):
reqDict
.
pop
(
'upscaler_2'
)
return
reqDict
def
decode_base64_to_image
(
encoding
):
if
encoding
.
startswith
(
"data:image/"
):
encoding
=
encoding
.
split
(
";"
)[
1
]
.
split
(
","
)[
1
]
return
Image
.
open
(
BytesIO
(
base64
.
b64decode
(
encoding
)))
def
encode_pil_to_base64
(
image
):
with
io
.
BytesIO
()
as
output_bytes
:
...
...
@@ -134,10 +138,7 @@ class Api:
mask
=
img2imgreq
.
mask
if
mask
:
if
mask
.
startswith
(
"data:image/"
):
mask
=
decode_base64_to_image
(
mask
)
else
:
mask
=
Image
.
open
(
BytesIO
(
base64
.
b64decode
(
mask
)))
mask
=
decode_base64_to_image
(
mask
)
populate
=
img2imgreq
.
copy
(
update
=
{
# Override __init__ params
"sd_model"
:
shared
.
sd_model
,
...
...
@@ -151,10 +152,7 @@ class Api:
imgs
=
[]
for
img
in
init_images
:
if
img
.
startswith
(
"data:image/"
):
img
=
decode_base64_to_image
(
img
)
else
:
img
=
Image
.
open
(
BytesIO
(
base64
.
b64decode
(
img
)))
img
=
decode_base64_to_image
(
img
)
imgs
=
[
img
]
*
p
.
batch_size
p
.
init_images
=
imgs
...
...
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