Skip to content
DeepForgeby svx
All problems
HardComputer Visioncv-298

CutMix Alpha

Problem

Cut and paste a centered box from image_b into image_a (CutMix).

Seed the random module and draw lam = betavariate(alpha, alpha). The box side ratio is r = sqrt(1 - lam), giving box_h = round(r * H) and box_w = round(r * W) centered in the image. Return [mixed_image, round(lam, 4)].

Test cases

case 1
in: [[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],[[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]],1,3]
expected: [[[1,2,3,0],[5,6,7,0],[9,10,11,0],[0,0,0,0]],0.257]
case 2
in: [[[0,0,0],[0,0,0],[0,0,0]],[[1,2,3],[4,5,6],[7,8,9]],2,1]
expected: [[[1,2,3],[4,5,6],[7,8,9]],0.1477]
case 3
in: [[[0,0],[0,0]],[[1,2],[3,4]],0.5,5]
expected: [[[1,2],[3,4]],0.0006]
Starter codePython
def cutmix(image_a, image_b, alpha, seed):
    # Your code here
    pass

3 test cases · run your code against them in the editor