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
db71290d
Commit
db71290d
authored
Oct 11, 2022
by
DepFA
Committed by
GitHub
Oct 11, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove old caption method
parent
61788c05
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
37 deletions
+2
-37
modules/textual_inversion/image_embedding.py
modules/textual_inversion/image_embedding.py
+2
-37
No files found.
modules/textual_inversion/image_embedding.py
View file @
db71290d
...
...
@@ -117,37 +117,6 @@ def extract_image_data_embed(image):
data
=
zlib
.
decompress
(
data_block
)
return
json
.
loads
(
data
,
cls
=
EmbeddingDecoder
)
def
addCaptionLines
(
lines
,
image
,
initialx
,
textfont
):
draw
=
ImageDraw
.
Draw
(
image
)
hstart
=
initialx
for
fill
,
line
in
lines
:
fontsize
=
32
font
=
ImageFont
.
truetype
(
textfont
,
fontsize
)
_
,
_
,
w
,
h
=
draw
.
textbbox
((
0
,
0
),
line
,
font
=
font
)
fontsize
=
min
(
int
(
fontsize
*
((
image
.
size
[
0
]
-
35
)
/
w
)
),
28
)
font
=
ImageFont
.
truetype
(
textfont
,
fontsize
)
_
,
_
,
w
,
h
=
draw
.
textbbox
((
0
,
0
),
line
,
font
=
font
)
draw
.
text
(((
image
.
size
[
0
]
-
w
)
/
2
,
hstart
),
line
,
font
=
font
,
fill
=
fill
)
hstart
+=
h
return
hstart
def
caption_image
(
image
,
prelines
,
postlines
,
background
=
(
51
,
51
,
51
),
font
=
None
):
if
font
is
None
:
try
:
font
=
ImageFont
.
truetype
(
opts
.
font
or
Roboto
,
fontsize
)
font
=
opts
.
font
or
Roboto
except
Exception
:
font
=
Roboto
sample_image
=
image
background
=
Image
.
new
(
"RGBA"
,
(
sample_image
.
size
[
0
],
sample_image
.
size
[
1
]
+
1024
),
background
)
hoffset
=
addCaptionLines
(
prelines
,
background
,
5
,
font
)
+
16
background
.
paste
(
sample_image
,(
0
,
hoffset
))
hoffset
=
hoffset
+
sample_image
.
size
[
1
]
+
8
hoffset
=
addCaptionLines
(
postlines
,
background
,
hoffset
,
font
)
background
=
background
.
crop
((
0
,
0
,
sample_image
.
size
[
0
],
hoffset
+
8
))
return
background
def
caption_image_overlay
(
srcimage
,
title
,
footerLeft
,
footerMid
,
footerRight
,
textfont
=
None
):
from
math
import
cos
...
...
@@ -195,11 +164,7 @@ def caption_image_overlay(srcimage,title,footerLeft,footerMid,footerRight,textfo
return
image
if
__name__
==
'__main__'
:
image
=
Image
.
new
(
'RGBA'
,(
512
,
512
),(
255
,
255
,
200
,
255
))
caption_image
(
image
,[((
255
,
255
,
255
),
'line a'
),((
255
,
255
,
255
),
'line b'
)],
[((
255
,
255
,
255
),
'line c'
),((
255
,
255
,
255
),
'line d'
)])
image
=
Image
.
new
(
'RGBA'
,(
512
,
512
),(
255
,
255
,
200
,
255
))
cap_image
=
caption_image_overlay
(
image
,
'title'
,
'footerLeft'
,
'footerMid'
,
'footerRight'
)
...
...
@@ -231,4 +196,4 @@ if __name__ == '__main__':
hunna_kay_random_sum
=
sum
(
np
.
array
([
next
(
g
)
for
_
in
range
(
100000
)])
.
astype
(
np
.
uint8
)
.
tolist
())
assert
12731374
==
hunna_kay_random_sum
\ No newline at end of file
assert
12731374
==
hunna_kay_random_sum
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