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
7e02a00c
Commit
7e02a00c
authored
May 09, 2023
by
AUTOMATIC1111
Committed by
GitHub
May 09, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #10194 from DumoeDss/dev
Add api method to get LoRA models with prompt
parents
11ae5399
f9abe4cd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
1 deletion
+37
-1
extensions-builtin/Lora/lora.py
extensions-builtin/Lora/lora.py
+6
-1
extensions-builtin/Lora/scripts/api.py
extensions-builtin/Lora/scripts/api.py
+31
-0
No files found.
extensions-builtin/Lora/lora.py
View file @
7e02a00c
...
...
@@ -3,6 +3,7 @@ import os
import
re
import
torch
from
typing
import
Union
import
scripts.api
as
api
from
modules
import
shared
,
devices
,
sd_models
,
errors
,
scripts
...
...
@@ -443,9 +444,13 @@ def infotext_pasted(infotext, params):
if
added
:
params
[
"Prompt"
]
+=
"
\n
"
+
""
.
join
(
added
)
available_loras
=
{}
available_lora_aliases
=
{}
loaded_loras
=
[]
list_available_loras
()
try
:
import
modules.script_callbacks
as
script_callbacks
script_callbacks
.
on_app_started
(
api
.
api
)
except
:
pass
\ No newline at end of file
extensions-builtin/Lora/scripts/api.py
0 → 100644
View file @
7e02a00c
from
fastapi
import
FastAPI
import
gradio
as
gr
import
json
import
os
import
lora
def
get_lora_prompts
(
path
):
directory
,
filename
=
os
.
path
.
split
(
path
)
name_without_ext
=
os
.
path
.
splitext
(
filename
)[
0
]
new_filename
=
name_without_ext
+
'.civitai.info'
try
:
new_path
=
os
.
path
.
join
(
directory
,
new_filename
)
if
os
.
path
.
exists
(
new_path
):
with
open
(
new_path
,
'r'
)
as
f
:
data
=
json
.
load
(
f
)
trained_words
=
data
.
get
(
'trainedWords'
,
[])
if
len
(
trained_words
)
>
0
:
result
=
','
.
join
(
trained_words
)
return
result
else
:
return
''
else
:
return
''
except
Exception
as
e
:
return
''
def
api
(
_
:
gr
.
Blocks
,
app
:
FastAPI
):
@
app
.
get
(
"/sdapi/v1/loras"
)
async
def
get_loras
():
return
[{
"name"
:
name
,
"path"
:
lora
.
available_loras
[
name
]
.
filename
,
"prompt"
:
get_lora_prompts
(
lora
.
available_loras
[
name
]
.
filename
)}
for
name
in
lora
.
available_loras
]
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