(self, images)
| 67 | return captions |
| 68 | |
| 69 | def transform(self, images): |
| 70 | if self._aug_flag: |
| 71 | transformed_images =\ |
| 72 | np.zeros([images.shape[0], self._imsize, self._imsize, 3]) |
| 73 | ori_size = images.shape[1] |
| 74 | for i in range(images.shape[0]): |
| 75 | h1 = np.floor((ori_size - self._imsize) * np.random.random()) |
| 76 | w1 = np.floor((ori_size - self._imsize) * np.random.random()) |
| 77 | cropped_image =\ |
| 78 | images[i][w1: w1 + self._imsize, h1: h1 + self._imsize, :] |
| 79 | if random.random() > 0.5: |
| 80 | transformed_images[i] = np.fliplr(cropped_image) |
| 81 | else: |
| 82 | transformed_images[i] = cropped_image |
| 83 | return transformed_images |
| 84 | else: |
| 85 | return images |
| 86 | |
| 87 | def sample_embeddings(self, embeddings, filenames, class_id, sample_num): |
| 88 | if len(embeddings.shape) == 2 or embeddings.shape[1] == 1: |
no outgoing calls
no test coverage detected