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
75b67eeb
Unverified
Commit
75b67eeb
authored
Nov 23, 2022
by
Sena
Committed by
GitHub
Nov 23, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bare base64 not accept
parent
828438b4
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
3 deletions
+10
-3
api.py
modules/api/api.py
+10
-3
No files found.
modules/api/api.py
View file @
75b67eeb
...
@@ -3,6 +3,7 @@ import io
...
@@ -3,6 +3,7 @@ import io
import
time
import
time
import
uvicorn
import
uvicorn
from
threading
import
Lock
from
threading
import
Lock
from
io
import
BytesIO
from
gradio.processing_utils
import
encode_pil_to_base64
,
decode_base64_to_file
,
decode_base64_to_image
from
gradio.processing_utils
import
encode_pil_to_base64
,
decode_base64_to_file
,
decode_base64_to_image
from
fastapi
import
APIRouter
,
Depends
,
FastAPI
,
HTTPException
from
fastapi
import
APIRouter
,
Depends
,
FastAPI
,
HTTPException
from
fastapi.security
import
HTTPBasic
,
HTTPBasicCredentials
from
fastapi.security
import
HTTPBasic
,
HTTPBasicCredentials
...
@@ -13,7 +14,7 @@ from modules import sd_samplers, deepbooru
...
@@ -13,7 +14,7 @@ from modules import sd_samplers, deepbooru
from
modules.api.models
import
*
from
modules.api.models
import
*
from
modules.processing
import
StableDiffusionProcessingTxt2Img
,
StableDiffusionProcessingImg2Img
,
process_images
from
modules.processing
import
StableDiffusionProcessingTxt2Img
,
StableDiffusionProcessingImg2Img
,
process_images
from
modules.extras
import
run_extras
,
run_pnginfo
from
modules.extras
import
run_extras
,
run_pnginfo
from
PIL
import
PngImagePlugin
from
PIL
import
PngImagePlugin
,
Image
from
modules.sd_models
import
checkpoints_list
from
modules.sd_models
import
checkpoints_list
from
modules.realesrgan_model
import
get_realesrgan_models
from
modules.realesrgan_model
import
get_realesrgan_models
from
typing
import
List
from
typing
import
List
...
@@ -133,7 +134,10 @@ class Api:
...
@@ -133,7 +134,10 @@ class Api:
mask
=
img2imgreq
.
mask
mask
=
img2imgreq
.
mask
if
mask
:
if
mask
:
if
mask
.
startswith
(
"data:image/"
):
mask
=
decode_base64_to_image
(
mask
)
mask
=
decode_base64_to_image
(
mask
)
else
:
mask
=
Image
.
open
(
BytesIO
(
base64
.
b64decode
(
mask
)))
populate
=
img2imgreq
.
copy
(
update
=
{
# Override __init__ params
populate
=
img2imgreq
.
copy
(
update
=
{
# Override __init__ params
"sd_model"
:
shared
.
sd_model
,
"sd_model"
:
shared
.
sd_model
,
...
@@ -147,7 +151,10 @@ class Api:
...
@@ -147,7 +151,10 @@ class Api:
imgs
=
[]
imgs
=
[]
for
img
in
init_images
:
for
img
in
init_images
:
if
img
.
startswith
(
"data:image/"
):
img
=
decode_base64_to_image
(
img
)
img
=
decode_base64_to_image
(
img
)
else
:
img
=
Image
.
open
(
BytesIO
(
base64
.
b64decode
(
img
)))
imgs
=
[
img
]
*
p
.
batch_size
imgs
=
[
img
]
*
p
.
batch_size
p
.
init_images
=
imgs
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