Skip to content
DeepForgeby svx
All problems
MediumComputer Visioncv-283

Inference Batch Padding

Problem

Pad every image in an inference batch to the same square size.

Each image is padded on the bottom and right with value up to target x target. Return the list of padded images.

Test cases

case 1
in: [[[[1,2],[3,4]],[[5]]],3,0]
expected: [[[1,2,0],[3,4,0],[0,0,0]],[[5,0,0],[0,0,0],[0,0,0]]]
case 2
in: [[[[1,2]],[[3,4]]],2,9]
expected: [[[1,2],[9,9]],[[3,4],[9,9]]]
case 3
in: [[[[1,2]]],3,5]
expected: [[[1,2,5],[5,5,5],[5,5,5]]]
Starter codePython
def pad_batch(batch, target, value):
    # Your code here
    pass

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