original_docstring: Test the network inference speed.
docstring: Test the network inference speed.
docstring_tokens: Test the network inference speed .
code: def benchmark(net, val_data, ctx, size, args):
      """Test the network inference speed."""
      net.collect_params().reset_ctx(ctx)
      net.hybridize()
      # set nms threshold and topk constraint
      net.set_nms(nms_thresh=0.45, nms_topk=400)
  
      mx.nd.waitall()
      total_time = 0
      with tqdm(total=size, ncols=0) as pbar:
          for ib, batch in enumerate(val_data):
              data = gluon.utils.split_and_load(batch[0], ctx_list=ctx, batch_axis=0, even_split=False)
              inf_time = 0
              for x in data:  # y stands for img_info
                  mx.nd.waitall()
                  a_tic = time()
                  ids, scores, bboxes = net(x)
                  mx.nd.waitall()
                  b_tic = time()
                  inf_time += (b_tic - a_tic)
              if ib >= 50:  # Ignore the first 50 batches
                  total_time += inf_time
  
              pbar.update(batch[0].shape[0])
              pbar.set_description("Batch %.4f s | fps %.2f" % (inf_time, batch[0].shape[0] / inf_time))
  
      print('Average fps %.2f' % ((size-50) / total_time))
      return None
code_tokens: def benchmark ( net , val_data , ctx , size , args ) : net . collect_params ( ) . reset_ctx ( ctx ) net . hybridize ( ) net . set_nms ( nms_thresh = 0.45 , nms_topk = 400 ) mx . nd . waitall ( ) total_time = 0 with tqdm ( total = size , ncols = 0 ) as pbar : for ib , batch in enumerate ( val_data ) : data = gluon . utils . split_and_load ( batch [ 0 ] , ctx_list = ctx , batch_axis = 0 , even_split = False ) inf_time = 0 for x in data : mx . nd . waitall ( ) a_tic = time ( ) ids , scores , bboxes = net ( x ) mx . nd . waitall ( ) b_tic = time ( ) inf_time += ( b_tic - a_tic ) if ib >= 50 : total_time += inf_time pbar . update ( batch [ 0 ] . shape [ 0 ] ) pbar . set_description ( "Batch %.4f s | fps %.2f" % ( inf_time , batch [ 0 ] . shape [ 0 ] / inf_time ) ) print ( 'Average fps %.2f' % ( ( size - 50 ) / total_time ) ) return None
short_docstring: Test the network inference speed.
short_docstring_tokens: Test the network inference speed .
comment: """Test the network inference speed."""$SEP$# set nms threshold and topk constraint$SEP$# y stands for img_info$SEP$# Ignore the first 50 batches