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
bc3e183b
Unverified
Commit
bc3e183b
authored
Oct 10, 2022
by
alg-wiki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Textual Inversion: Preprocess and Training will only pick-up image files
parent
04c745ea
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
3 deletions
+6
-3
dataset.py
modules/textual_inversion/dataset.py
+2
-1
preprocess.py
modules/textual_inversion/preprocess.py
+2
-1
textual_inversion.py
modules/textual_inversion/textual_inversion.py
+2
-1
No files found.
modules/textual_inversion/dataset.py
View file @
bc3e183b
...
...
@@ -22,6 +22,7 @@ class PersonalizedBase(Dataset):
self
.
width
=
width
self
.
height
=
height
self
.
flip
=
transforms
.
RandomHorizontalFlip
(
p
=
flip_p
)
self
.
extns
=
[
".jpg"
,
".jpeg"
,
".png"
]
self
.
dataset
=
[]
...
...
@@ -32,7 +33,7 @@ class PersonalizedBase(Dataset):
assert
data_root
,
'dataset directory not specified'
self
.
image_paths
=
[
os
.
path
.
join
(
data_root
,
file_path
)
for
file_path
in
os
.
listdir
(
data_root
)]
self
.
image_paths
=
[
os
.
path
.
join
(
data_root
,
file_path
)
for
file_path
in
os
.
listdir
(
data_root
)
if
os
.
path
.
splitext
(
file_path
.
casefold
())[
1
]
in
self
.
extns
]
print
(
"Preparing dataset..."
)
for
path
in
tqdm
.
tqdm
(
self
.
image_paths
):
image
=
Image
.
open
(
path
)
...
...
modules/textual_inversion/preprocess.py
View file @
bc3e183b
...
...
@@ -12,12 +12,13 @@ def preprocess(process_src, process_dst, process_width, process_height, process_
height
=
process_height
src
=
os
.
path
.
abspath
(
process_src
)
dst
=
os
.
path
.
abspath
(
process_dst
)
extns
=
[
".jpg"
,
".jpeg"
,
".png"
]
assert
src
!=
dst
,
'same directory specified as source and destination'
os
.
makedirs
(
dst
,
exist_ok
=
True
)
files
=
os
.
listdir
(
src
)
files
=
[
i
for
i
in
os
.
listdir
(
src
)
if
os
.
path
.
splitext
(
i
.
casefold
())[
1
]
in
extns
]
shared
.
state
.
textinfo
=
"Preprocessing..."
shared
.
state
.
job_count
=
len
(
files
)
...
...
modules/textual_inversion/textual_inversion.py
View file @
bc3e183b
...
...
@@ -161,6 +161,7 @@ def train_embedding(embedding_name, learn_rate, data_root, log_directory, traini
shared
.
state
.
textinfo
=
"Initializing textual inversion training..."
shared
.
state
.
job_count
=
steps
extns
=
[
".jpg"
,
".jpeg"
,
".png"
]
filename
=
os
.
path
.
join
(
shared
.
cmd_opts
.
embeddings_dir
,
f
'{embedding_name}.pt'
)
...
...
@@ -200,7 +201,7 @@ def train_embedding(embedding_name, learn_rate, data_root, log_directory, traini
if
ititial_step
>
steps
:
return
embedding
,
filename
tr_img_len
=
len
([
os
.
path
.
join
(
data_root
,
file_path
)
for
file_path
in
os
.
listdir
(
data_root
)])
tr_img_len
=
len
([
os
.
path
.
join
(
data_root
,
file_path
)
for
file_path
in
os
.
listdir
(
data_root
)
if
os
.
path
.
splitext
(
file_path
.
casefold
())[
1
]
in
extns
])
epoch_len
=
(
tr_img_len
*
num_repeats
)
+
tr_img_len
pbar
=
tqdm
.
tqdm
(
enumerate
(
ds
),
total
=
steps
-
ititial_step
)
...
...
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