-1

I want to send a batch of images to profile.runctx Ex

profile.runctx('print (inference(image_batch,batch_size)); print()',
               globals(),
               {'image_batch':'how to send image batch?','batch_size':128})

I have a function called inference which accepts a sequence image batches as input. How to pass a sequence of images as parameter in profile.runctx?

martineau
  • 119,623
  • 25
  • 170
  • 301
Rehoboth
  • 43
  • 2
  • 6

1 Answers1

1

You've left many details out the example code in your question, but here's a guess:

import profile


def inference(image_batches, size):
    for i in range(size):
        print('image_batches[{}]: {}'.format(i, image_batches[i]))
    return 42


image_batch = ['image1', 'image2']
batch_size  = 2

profile.runctx('print(inference(image_batch, batch_size)); print()',
               globals(), locals())

Alternatively you could do something more explicit like this:

profile.runctx('print(inference(image_batch, batch_size)); print()',
               globals(), {'image_batch': ['image1', 'image2'],
                           'batch_size': 2})
martineau
  • 119,623
  • 25
  • 170
  • 301