prediction function
(self, inputs)
| 38 | return {m.name: m.result() for m in self.metrics} |
| 39 | |
| 40 | def predict_step(self, inputs): |
| 41 | """ |
| 42 | prediction function |
| 43 | """ |
| 44 | # Adding dummy dimension using tf.expand_dims and converting to float32 using tf.cast |
| 45 | out = tf.cast(tf.expand_dims(inputs, axis=0), tf.float32) |
| 46 | # Passing low resolution image to model |
| 47 | super_resolution_img = self(out, training=False) |
| 48 | # Clips the tensor from min(0) to max(255) |
| 49 | super_resolution_img = tf.clip_by_value(super_resolution_img, 0, 255) |
| 50 | # Rounds the values of a tensor to the nearest integer |
| 51 | super_resolution_img = tf.round(super_resolution_img) |
| 52 | # Removes dimensions of size 1 from the shape of a tensor and converting to uint8 |
| 53 | super_resolution_img = tf.squeeze( |
| 54 | tf.cast(super_resolution_img, tf.uint8), axis=0 |
| 55 | ) |
| 56 | return super_resolution_img |
| 57 | |
| 58 | # Residual Block |
| 59 | def resblock(inputs): |