Skip to content

Commit

Permalink
only encode text once at start
Browse files Browse the repository at this point in the history
  • Loading branch information
lucidrains committed Feb 14, 2021
1 parent 16e4b3d commit ae0fec6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions deep_daze/deep_daze.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def __init__(

self.generate_size_schedule()

def forward(self, text, return_loss=True, dry_run=False):
def forward(self, text_embed, return_loss=True, dry_run=False):
out = self.model()
out = norm_siren_output(out)

Expand All @@ -151,7 +151,6 @@ def forward(self, text, return_loss=True, dry_run=False):

with autocast(enabled=False):
image_embed = perceptor.encode_image(image)
text_embed = perceptor.encode_text(text)

if not dry_run:
self.num_batches_processed += self.batch_size
Expand Down Expand Up @@ -262,7 +261,9 @@ def __init__(
self.text = text
self.textpath = text.replace(" ", "_")
self.filename = self.image_output_path()
self.encoded_text = tokenize(text).cuda()

tokenized_text = tokenize(text).cuda()
self.encoded_text = perceptor.encode_text(tokenized_text).detach()

self.start_image = None
self.start_image_train_iters = start_image_train_iters
Expand Down
2 changes: 1 addition & 1 deletion deep_daze/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.4.9'
__version__ = '0.5.0'

0 comments on commit ae0fec6

Please sign in to comment.