Skip to content

Commit

Permalink
Do image clipping in numpy space (outputs are already numpy arrays af…
Browse files Browse the repository at this point in the history
…ter `predict()`, no need to go back to TF then to numpy again) (#838)
  • Loading branch information
fchollet authored Sep 25, 2022
1 parent c39df7c commit b4dd786
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import math

import numpy as np
import tensorflow as tf
from tensorflow import keras

Expand Down Expand Up @@ -168,7 +169,7 @@ def text_to_image(
# Decoding stage
decoded = self.decoder.predict_on_batch(latent)
decoded = ((decoded + 1) / 2) * 255
return tf.cast(tf.clip_by_value(decoded, 0, 255), dtype=tf.uint8)
return np.clip(decoded, 0, 255).astype("uint8")

def _get_timestep_embedding(self, timestep, batch_size, dim=320, max_period=10000):
half = dim // 2
Expand Down

0 comments on commit b4dd786

Please sign in to comment.