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
095830e1
Commit
095830e1
authored
Sep 12, 2022
by
AUTOMATIC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prompts from file. How to? #248
parent
482a6ce8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
0 deletions
+42
-0
scripts/prompts_from_file.py
scripts/prompts_from_file.py
+42
-0
No files found.
scripts/prompts_from_file.py
0 → 100644
View file @
095830e1
import
math
import
os
import
sys
import
traceback
import
modules.scripts
as
scripts
import
gradio
as
gr
from
modules.processing
import
Processed
,
process_images
from
PIL
import
Image
from
modules.shared
import
opts
,
cmd_opts
,
state
class
Script
(
scripts
.
Script
):
def
title
(
self
):
return
"Prompts from file"
def
ui
(
self
,
is_img2img
):
file
=
gr
.
File
(
label
=
"File with inputs"
,
type
=
'bytes'
)
return
[
file
]
def
run
(
self
,
p
,
data
:
bytes
):
lines
=
[
x
.
strip
()
for
x
in
data
.
decode
(
'utf8'
,
errors
=
'ignore'
)
.
split
(
"
\n
"
)]
lines
=
[
x
for
x
in
lines
if
len
(
x
)
>
0
]
batch_count
=
math
.
ceil
(
len
(
lines
)
/
p
.
batch_size
)
print
(
f
"Will process {len(lines)} images in {batch_count} batches."
)
p
.
batch_count
=
1
p
.
do_not_save_grid
=
True
state
.
job_count
=
batch_count
images
=
[]
for
batch_no
in
range
(
batch_count
):
state
.
job
=
f
"{batch_no} out of {batch_count}"
p
.
prompt
=
lines
[
batch_no
*
p
.
batch_size
:(
batch_no
+
1
)
*
p
.
batch_size
]
proc
=
process_images
(
p
)
images
+=
proc
.
images
return
Processed
(
p
,
images
,
p
.
seed
,
""
)
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