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
6785331e
Commit
6785331e
authored
Oct 02, 2022
by
AUTOMATIC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
keep textual inversion dataset latents in CPU memory to save a bit of VRAM
parent
c7543d49
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
2 deletions
+7
-2
modules/textual_inversion/dataset.py
modules/textual_inversion/dataset.py
+2
-0
modules/textual_inversion/textual_inversion.py
modules/textual_inversion/textual_inversion.py
+3
-0
modules/ui.py
modules/ui.py
+2
-2
No files found.
modules/textual_inversion/dataset.py
View file @
6785331e
...
...
@@ -8,6 +8,7 @@ from torchvision import transforms
import
random
import
tqdm
from
modules
import
devices
class
PersonalizedBase
(
Dataset
):
...
...
@@ -47,6 +48,7 @@ class PersonalizedBase(Dataset):
torchdata
=
torch
.
moveaxis
(
torchdata
,
2
,
0
)
init_latent
=
model
.
get_first_stage_encoding
(
model
.
encode_first_stage
(
torchdata
.
unsqueeze
(
dim
=
0
)))
.
squeeze
()
init_latent
=
init_latent
.
to
(
devices
.
cpu
)
self
.
dataset
.
append
((
init_latent
,
filename_tokens
))
...
...
modules/textual_inversion/textual_inversion.py
View file @
6785331e
...
...
@@ -212,7 +212,10 @@ def train_embedding(embedding_name, learn_rate, data_root, log_directory, steps,
with
torch
.
autocast
(
"cuda"
):
c
=
cond_model
([
text
])
x
=
x
.
to
(
devices
.
device
)
loss
=
shared
.
sd_model
(
x
.
unsqueeze
(
0
),
c
)[
0
]
del
x
losses
[
embedding
.
step
%
losses
.
shape
[
0
]]
=
loss
.
item
()
...
...
modules/ui.py
View file @
6785331e
...
...
@@ -1002,8 +1002,8 @@ def create_ui(wrap_gradio_gpu_call):
log_directory
=
gr
.
Textbox
(
label
=
'Log directory'
,
placeholder
=
"Path to directory where to write outputs"
,
value
=
"textual_inversion"
)
template_file
=
gr
.
Textbox
(
label
=
'Prompt template file'
,
value
=
os
.
path
.
join
(
script_path
,
"textual_inversion_templates"
,
"style_filewords.txt"
))
steps
=
gr
.
Number
(
label
=
'Max steps'
,
value
=
100000
,
precision
=
0
)
create_image_every
=
gr
.
Number
(
label
=
'Save an image to log directory every N steps, 0 to disable'
,
value
=
10
00
,
precision
=
0
)
save_embedding_every
=
gr
.
Number
(
label
=
'Save a copy of embedding to log directory every N steps, 0 to disable'
,
value
=
10
00
,
precision
=
0
)
create_image_every
=
gr
.
Number
(
label
=
'Save an image to log directory every N steps, 0 to disable'
,
value
=
5
00
,
precision
=
0
)
save_embedding_every
=
gr
.
Number
(
label
=
'Save a copy of embedding to log directory every N steps, 0 to disable'
,
value
=
5
00
,
precision
=
0
)
with
gr
.
Row
():
with
gr
.
Column
(
scale
=
2
):
...
...
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