mirror of
https://github.com/iperov/DeepFaceLab.git
synced 2025-07-16 10:03:41 -07:00
imagelib: random crop func (unused)
This commit is contained in:
parent
bee8628d77
commit
65432d0c3d
2 changed files with 12 additions and 1 deletions
|
@ -1,5 +1,16 @@
|
|||
import numpy as np
|
||||
|
||||
def random_crop(img, w, h):
|
||||
height, width = img.shape[:2]
|
||||
|
||||
h_rnd = height - h
|
||||
w_rnd = width - w
|
||||
|
||||
y = np.random.randint(0, h_rnd) if h_rnd > 0 else 0
|
||||
x = np.random.randint(0, w_rnd) if w_rnd > 0 else 0
|
||||
|
||||
return img[y:y+height, x:x+width]
|
||||
|
||||
def normalize_channels(img, target_channels):
|
||||
img_shape_len = len(img.shape)
|
||||
if img_shape_len == 2:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue