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
88f46a5b
Commit
88f46a5b
authored
Oct 29, 2022
by
evshiron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update progress response model
parent
e9c6c2a5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
7 deletions
+7
-7
api.py
modules/api/api.py
+3
-3
models.py
modules/api/models.py
+2
-2
shared.py
modules/shared.py
+2
-2
No files found.
modules/api/api.py
View file @
88f46a5b
...
...
@@ -61,7 +61,7 @@ class Api:
self
.
app
.
add_api_route
(
"/sdapi/v1/extra-single-image"
,
self
.
extras_single_image_api
,
methods
=
[
"POST"
],
response_model
=
ExtrasSingleImageResponse
)
self
.
app
.
add_api_route
(
"/sdapi/v1/extra-batch-images"
,
self
.
extras_batch_images_api
,
methods
=
[
"POST"
],
response_model
=
ExtrasBatchImagesResponse
)
self
.
app
.
add_api_route
(
"/sdapi/v1/png-info"
,
self
.
pnginfoapi
,
methods
=
[
"POST"
],
response_model
=
PNGInfoResponse
)
self
.
app
.
add_api_route
(
"/sdapi/v1/progress"
,
self
.
progressapi
,
methods
=
[
"GET"
])
self
.
app
.
add_api_route
(
"/sdapi/v1/progress"
,
self
.
progressapi
,
methods
=
[
"GET"
]
,
response_model
=
ProgressResponse
)
def
text2imgapi
(
self
,
txt2imgreq
:
StableDiffusionTxt2ImgProcessingAPI
):
sampler_index
=
sampler_to_index
(
txt2imgreq
.
sampler_index
)
...
...
@@ -171,7 +171,7 @@ class Api:
# copy from check_progress_call of ui.py
if
shared
.
state
.
job_count
==
0
:
return
ProgressResponse
(
progress
=
0
,
eta_relative
=
0
,
state
=
shared
.
state
.
js
())
return
ProgressResponse
(
progress
=
0
,
eta_relative
=
0
,
state
=
shared
.
state
.
dict
())
# avoid dividing zero
progress
=
0.01
...
...
@@ -187,7 +187,7 @@ class Api:
progress
=
min
(
progress
,
1
)
return
ProgressResponse
(
progress
=
progress
,
eta_relative
=
eta_relative
,
state
=
shared
.
state
.
js
())
return
ProgressResponse
(
progress
=
progress
,
eta_relative
=
eta_relative
,
state
=
shared
.
state
.
dict
())
def
launch
(
self
,
server_name
,
port
):
self
.
app
.
include_router
(
self
.
router
)
...
...
modules/api/models.py
View file @
88f46a5b
import
inspect
from
click
import
prompt
from
pydantic
import
BaseModel
,
Field
,
Json
,
create_model
from
pydantic
import
BaseModel
,
Field
,
create_model
from
typing
import
Any
,
Optional
from
typing_extensions
import
Literal
from
inflection
import
underscore
...
...
@@ -160,4 +160,4 @@ class PNGInfoResponse(BaseModel):
class
ProgressResponse
(
BaseModel
):
progress
:
float
=
Field
(
title
=
"Progress"
,
description
=
"The progress with a range of 0 to 1"
)
eta_relative
:
float
=
Field
(
title
=
"ETA in secs"
)
state
:
Json
=
Field
(
title
=
"State"
,
description
=
"The current state snapshot"
)
state
:
dict
=
Field
(
title
=
"State"
,
description
=
"The current state snapshot"
)
modules/shared.py
View file @
88f46a5b
...
...
@@ -147,7 +147,7 @@ class State:
def
get_job_timestamp
(
self
):
return
datetime
.
datetime
.
now
()
.
strftime
(
"
%
Y
%
m
%
d
%
H
%
M
%
S"
)
# shouldn't this return job_timestamp?
def
js
(
self
):
def
dict
(
self
):
obj
=
{
"skipped"
:
self
.
skipped
,
"interrupted"
:
self
.
skipped
,
...
...
@@ -158,7 +158,7 @@ class State:
"sampling_steps"
:
self
.
sampling_steps
,
}
return
json
.
dumps
(
obj
)
return
obj
state
=
State
()
...
...
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