MCPcopy Create free account
hub / github.com/CVCUDA/CV-CUDA / __call__

Method __call__

bench/python/nvcodec_utils.py:532–569  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

530 # docs_tag: end_init_imagebatchdecoder_nvimagecodec
531
532 def __call__(self):
533 if self.total_decoded == len(self.file_names):
534 return None
535
536 # docs_tag: begin_call_imagebatchdecoder_nvimagecodec
537 self.cvcuda_perf.push_range("decoder.nvimagecodec")
538
539 file_name_batch = self.file_name_batches[self.batch_idx]
540
541 data_batch = [open(path, "rb").read() for path in file_name_batch]
542
543 # docs_tag: begin_decode_imagebatchdecoder_nvimagecodec
544
545 tensor_list = []
546 image_list = self.decoder.decode(data_batch, cuda_stream=self.cuda_stream)
547
548 # Convert the decoded images to cvcuda tensors in a list.
549 for i in range(len(image_list)):
550 tensor_list.append(cvcuda.as_tensor(image_list[i], "HWC"))
551
552 # Stack the list of tensors to a single NHWC tensor.
553 cvcuda_decoded_tensor = cvcuda.stack(tensor_list)
554 self.total_decoded += len(tensor_list)
555 # docs_tag: end_decode_imagebatchdecoder_nvimagecodec
556
557 # docs_tag: begin_return_imagebatchdecoder_nvimagecodec
558 batch = Batch(
559 batch_idx=self.batch_idx,
560 data=cvcuda_decoded_tensor,
561 fileinfo=file_name_batch,
562 )
563 self.batch_idx += 1
564
565 # docs_tag: end_return_imagebatchdecoder_nvimagecodec
566
567 self.cvcuda_perf.pop_range()
568 # docs_tag: end_call_imagebatchdecoder_nvimagecodec
569 return batch
570
571 def start(self):
572 pass

Callers

nothing calls this directly

Calls 3

BatchClass · 0.90
push_rangeMethod · 0.80
pop_rangeMethod · 0.80

Tested by

no test coverage detected