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
18a09c7e
Commit
18a09c7e
authored
Jan 19, 2023
by
dan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplification and bugfix
parent
4688bfff
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
7 deletions
+5
-7
preprocess.py
modules/textual_inversion/preprocess.py
+5
-7
No files found.
modules/textual_inversion/preprocess.py
View file @
18a09c7e
...
@@ -124,13 +124,11 @@ def center_crop(image: Image, w: int, h: int):
...
@@ -124,13 +124,11 @@ def center_crop(image: Image, w: int, h: int):
def
multicrop_pic
(
image
:
Image
,
mindim
,
maxdim
,
minarea
,
maxarea
,
objective
,
threshold
):
def
multicrop_pic
(
image
:
Image
,
mindim
,
maxdim
,
minarea
,
maxarea
,
objective
,
threshold
):
iw
,
ih
=
image
.
size
iw
,
ih
=
image
.
size
err
=
lambda
w
,
h
:
1
-
(
lambda
x
:
x
if
x
<
1
else
1
/
x
)(
iw
/
ih
/
(
w
/
h
))
err
=
lambda
w
,
h
:
1
-
(
lambda
x
:
x
if
x
<
1
else
1
/
x
)(
iw
/
ih
/
(
w
/
h
))
try
:
w
,
h
=
max
(((
w
,
h
)
for
w
in
range
(
mindim
,
maxdim
+
1
,
64
)
for
h
in
range
(
mindim
,
maxdim
+
1
,
64
)
w
,
h
=
max
(((
w
,
h
)
for
w
in
range
(
mindim
,
maxdim
+
1
,
64
)
for
h
in
range
(
mindim
,
maxdim
+
1
,
64
)
if
minarea
<=
w
*
h
<=
maxarea
and
err
(
w
,
h
)
<=
threshold
),
if
minarea
<=
w
*
h
<=
maxarea
and
err
(
w
,
h
)
<=
threshold
),
key
=
lambda
wh
:
(
wh
[
0
]
*
wh
[
1
],
-
err
(
*
wh
))[::
1
if
objective
==
'Maximize area'
else
-
1
],
key
=
lambda
wh
:
((
objective
==
'Maximize area'
)
*
wh
[
0
]
*
wh
[
1
],
-
err
(
*
wh
))
default
=
None
)
)
except
ValueError
:
return
return
center_crop
(
image
,
w
,
h
)
return
center_crop
(
image
,
w
,
h
)
...
...
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