jfhealthcare/Chexpert

RuntimeError: stack expects a non-empty TensorList

jericho555 opened this issue · 1 comments

I get a runtime error when I execute heatmap.py. logit_maps = torch.stack(logit_maps) the model returns an empty tensor for logit_maps. Am not sure where the problem is coming from.
Any assistance will be highly appreciated
Take a look.
W NNPACK.cpp:51] Could not initialize NNPACK! Reason: Unsupported hardware.
Traceback (most recent call last):
File "/root/CCF5/Chexpert/bin/heatmap.py", line 114, in
main()
File "/root/CCF5/Chexpert/bin/heatmap.py", line 110, in main
run(args)
File "/root/CCF5/Chexpert/bin/heatmap.py", line 96, in run
prefix, figure_data = heatmaper.gen_heatmap(jpg_file)
File "/root/CCF5/Chexpert/bin/../utils/heatmaper.py", line 129, in gen_heatmap
logit_maps = torch.stack(logit_maps)
RuntimeError: stack expects a non-empty TensorList

function snippet from heatmapper.py where the error is raised.
def gen_heatmap(self, image_file):
"""
Args:
image_file: str to a jpg file path
Returns:
prefix_name: str of a prefix_name of a jpg with/without prob
figure_data: numpy array of a color image
"""
image_tensor, image_color = self.image_reader(image_file)
image_tensor = image_tensor.to(self.device)
# model inference
logits, logit_maps = self.model(image_tensor)
logits = torch.stack(logits)
logit_maps = torch.stack(logit_maps)

I figured it out