mirror of
https://github.com/zebrajr/faceswap.git
synced 2026-01-15 12:15:15 +00:00
Bugfix: Preview fail on input size > output size
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user