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
b5819d9b
Commit
b5819d9b
authored
Jan 01, 2023
by
Philpax
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(api): add /sdapi/v1/embeddings
parent
311354c0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
0 deletions
+11
-0
api.py
modules/api/api.py
+8
-0
models.py
modules/api/models.py
+3
-0
No files found.
modules/api/api.py
View file @
b5819d9b
...
...
@@ -100,6 +100,7 @@ class Api:
self
.
add_api_route
(
"/sdapi/v1/prompt-styles"
,
self
.
get_prompt_styles
,
methods
=
[
"GET"
],
response_model
=
List
[
PromptStyleItem
])
self
.
add_api_route
(
"/sdapi/v1/artist-categories"
,
self
.
get_artists_categories
,
methods
=
[
"GET"
],
response_model
=
List
[
str
])
self
.
add_api_route
(
"/sdapi/v1/artists"
,
self
.
get_artists
,
methods
=
[
"GET"
],
response_model
=
List
[
ArtistItem
])
self
.
add_api_route
(
"/sdapi/v1/embeddings"
,
self
.
get_embeddings
,
methods
=
[
"GET"
],
response_model
=
EmbeddingsResponse
)
self
.
add_api_route
(
"/sdapi/v1/refresh-checkpoints"
,
self
.
refresh_checkpoints
,
methods
=
[
"POST"
])
self
.
add_api_route
(
"/sdapi/v1/create/embedding"
,
self
.
create_embedding
,
methods
=
[
"POST"
],
response_model
=
CreateResponse
)
self
.
add_api_route
(
"/sdapi/v1/create/hypernetwork"
,
self
.
create_hypernetwork
,
methods
=
[
"POST"
],
response_model
=
CreateResponse
)
...
...
@@ -327,6 +328,13 @@ class Api:
def
get_artists
(
self
):
return
[{
"name"
:
x
[
0
],
"score"
:
x
[
1
],
"category"
:
x
[
2
]}
for
x
in
shared
.
artist_db
.
artists
]
def
get_embeddings
(
self
):
db
=
sd_hijack
.
model_hijack
.
embedding_db
return
{
"loaded"
:
sorted
(
db
.
word_embeddings
.
keys
()),
"skipped"
:
sorted
(
db
.
skipped_embeddings
),
}
def
refresh_checkpoints
(
self
):
shared
.
refresh_checkpoints
()
...
...
modules/api/models.py
View file @
b5819d9b
...
...
@@ -249,3 +249,6 @@ class ArtistItem(BaseModel):
score
:
float
=
Field
(
title
=
"Score"
)
category
:
str
=
Field
(
title
=
"Category"
)
class
EmbeddingsResponse
(
BaseModel
):
loaded
:
List
[
str
]
=
Field
(
title
=
"Loaded"
,
description
=
"Embeddings loaded for the current model"
)
skipped
:
List
[
str
]
=
Field
(
title
=
"Skipped"
,
description
=
"Embeddings skipped for the current model (likely due to architecture incompatibility)"
)
\ 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