mirror of
https://github.com/iperov/DeepFaceLab.git
synced 2025-07-06 21:12:07 -07:00
fix extractor error on load grayscale images
This commit is contained in:
parent
bc0b25cdda
commit
faa14c4e59
1 changed files with 4 additions and 13 deletions
|
@ -118,19 +118,9 @@ class ExtractSubprocessor(Subprocessor):
|
||||||
self.log_err ( 'Failed to extract %s, reason: cv2_imread() fail.' % ( str(filename_path) ) )
|
self.log_err ( 'Failed to extract %s, reason: cv2_imread() fail.' % ( str(filename_path) ) )
|
||||||
return data
|
return data
|
||||||
|
|
||||||
image_shape = image.shape
|
image = imagelib.normalize_channels(image, 3)
|
||||||
if len(image_shape) == 2:
|
|
||||||
h, w = image.shape
|
|
||||||
image = image[:,:,np.newaxis]
|
|
||||||
ch = 1
|
|
||||||
else:
|
|
||||||
h, w, ch = image.shape
|
h, w, ch = image.shape
|
||||||
|
|
||||||
if ch == 1:
|
|
||||||
image = np.repeat (image, 3, -1)
|
|
||||||
elif ch == 4:
|
|
||||||
image = image[:,:,0:3]
|
|
||||||
|
|
||||||
wm, hm = w % 2, h % 2
|
wm, hm = w % 2, h % 2
|
||||||
if wm + hm != 0: #fix odd image
|
if wm + hm != 0: #fix odd image
|
||||||
image = image[0:h-hm,0:w-wm,:]
|
image = image[0:h-hm,0:w-wm,:]
|
||||||
|
@ -393,7 +383,8 @@ class ExtractSubprocessor(Subprocessor):
|
||||||
if self.cache_original_image[0] == filename:
|
if self.cache_original_image[0] == filename:
|
||||||
self.original_image = self.cache_original_image[1]
|
self.original_image = self.cache_original_image[1]
|
||||||
else:
|
else:
|
||||||
self.original_image = cv2_imread( filename )
|
self.original_image = imagelib.normalize_channels( cv2_imread( filename ), 3 )
|
||||||
|
|
||||||
self.cache_original_image = (filename, self.original_image )
|
self.cache_original_image = (filename, self.original_image )
|
||||||
|
|
||||||
(h,w,c) = self.original_image.shape
|
(h,w,c) = self.original_image.shape
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue