mirror of
https://github.com/iperov/DeepFaceLab.git
synced 2025-08-22 06:23:20 -07:00
Update Sorter.py
This commit is contained in:
parent
0069dd500a
commit
589328ecb8
1 changed files with 15 additions and 3 deletions
|
@ -1,4 +1,4 @@
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import operator
|
import operator
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
@ -21,8 +21,17 @@ def estimate_sharpness(image):
|
||||||
|
|
||||||
if image.ndim == 3:
|
if image.ndim == 3:
|
||||||
image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
||||||
|
|
||||||
return cv2.Laplacian(image, cv2.CV_64F).var()
|
sharpness = 0
|
||||||
|
for y in range(height):
|
||||||
|
for x in range(width-1):
|
||||||
|
sharpness += abs( int(image[y, x]) - int(image[y, x+1]) )
|
||||||
|
|
||||||
|
for x in range(width):
|
||||||
|
for y in range(height-1):
|
||||||
|
sharpness += abs( int(image[y, x]) - int(image[y+1, x]) )
|
||||||
|
|
||||||
|
return sharpness
|
||||||
|
|
||||||
|
|
||||||
class BlurEstimatorSubprocessor(Subprocessor):
|
class BlurEstimatorSubprocessor(Subprocessor):
|
||||||
|
@ -45,6 +54,9 @@ class BlurEstimatorSubprocessor(Subprocessor):
|
||||||
|
|
||||||
if dflimg is not None:
|
if dflimg is not None:
|
||||||
image = cv2_imread( str(filepath) )
|
image = cv2_imread( str(filepath) )
|
||||||
|
image = ( image * \
|
||||||
|
LandmarksProcessor.get_image_hull_mask (image.shape, dflimg.get_landmarks()) \
|
||||||
|
).astype(np.uint8)
|
||||||
return [ str(filepath), estimate_sharpness( image ) ]
|
return [ str(filepath), estimate_sharpness( image ) ]
|
||||||
else:
|
else:
|
||||||
self.log_err ("%s is not a dfl image file" % (filepath.name) )
|
self.log_err ("%s is not a dfl image file" % (filepath.name) )
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue