mirror of
https://github.com/iperov/DeepFaceLab.git
synced 2025-07-06 13:02:15 -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
|
@ -14,7 +14,7 @@ from .reduce_colors import reduce_colors
|
||||||
|
|
||||||
from .color_transfer import color_transfer, color_transfer_mix, color_transfer_sot, color_transfer_mkl, color_transfer_idt, color_hist_match, reinhard_color_transfer, linear_color_transfer
|
from .color_transfer import color_transfer, color_transfer_mix, color_transfer_sot, color_transfer_mkl, color_transfer_idt, color_hist_match, reinhard_color_transfer, linear_color_transfer
|
||||||
|
|
||||||
from .common import normalize_channels, cut_odd_image, overlay_alpha_image
|
from .common import random_crop, normalize_channels, cut_odd_image, overlay_alpha_image
|
||||||
|
|
||||||
from .SegIEPolys import *
|
from .SegIEPolys import *
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,16 @@
|
||||||
import numpy as np
|
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):
|
def normalize_channels(img, target_channels):
|
||||||
img_shape_len = len(img.shape)
|
img_shape_len = len(img.shape)
|
||||||
if img_shape_len == 2:
|
if img_shape_len == 2:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue