Bugfix: Preview fail on input size > output size

This commit is contained in:
torzdf
2023-02-16 19:18:52 +00:00
parent 0c1d1e3253
commit 74f4b6f9c4

View File

@@ -696,7 +696,7 @@ class PreviewDataGenerator(DataGenerator):
Returns
-------
feed: :class:`numpy.ndarray`
List of 4-dimensional :class:`numpy.ndarray` objects at model input size for feeding
List of 4-dimensional :class:`numpy.ndarray` objects at model output size for feeding
the model's predict function. The first 3 channels are (rgb/bgr). The 4th channel is
the face mask.
samples: list
@@ -718,6 +718,13 @@ class PreviewDataGenerator(DataGenerator):
feed = self._to_float32(batch[..., :4]) # Don't resize here: we want masks at output res.
# If user sets model input size as larger than output size, the preview will error, so
# resize in these rare instances
out_size = max(self._output_sizes)
if self._process_size > out_size:
feed = np.array([cv2.resize(img, (out_size, out_size), interpolation=cv2.INTER_AREA)
for img in feed])
samples = self._create_samples(images, detected_faces)
return feed, samples