Skip to content
DeepForgeby svx
All problems
HardComputer Visioncv-297

Mixup Alpha Blend

Problem

Mix two images with a seeded Beta-distributed lambda (mixup).

Seed the random module and draw lam = betavariate(alpha, alpha). The mixed pixel is lam * image_a + (1 - lam) * image_b, rounded to 4 decimal places. Return [mixed_image, round(lam, 4)].

Test cases

case 1
in: [[[0,0],[0,0]],[[1,2],[3,4]],1,1]
expected: [[[0.9287,1.8575],[2.7862,3.7149]],0.0713]
case 2
in: [[[0,0],[0,0]],[[1,2],[3,4]],0.5,2]
expected: [[[0.9929,1.9858],[2.9788,3.9717]],0.0071]
case 3
in: [[[0,0],[0,0]],[[1,2],[3,4]],2,0]
expected: [[[0.2384,0.4768],[0.7151,0.9535]],0.7616]
Starter codePython
def mixup(image_a, image_b, alpha, seed):
    # Your code here
    pass

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