You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
A clear and concise description of what the bug is.
The inference do not work for semantic segmentation.
To Reproduce
Steps to reproduce the behavior: AttributeError: BaseRecord has no attribute segmentation
imgs_array = list([PIL.Image.open(f) for f in image_files[:10]])
infer_ds = Dataset.from_images(imgs_array, valid_tfms, class_map=class_map)
Batch Inference
infer_dl = model_type.infer_dl(infer_ds, batch_size=1, shuffle=False)
preds = model_type.predict_from_dl(model, infer_dl, keep_images=True)
`
I get the following error:
"AttributeError: BaseRecord has no attribute segmentation"
File /projects/icevision/icevision/models/fastai/unet/prediction.py:69, in convert_raw_predictions(batch, raw_preds, records, keep_images)
58 for record, tensor_image, mask_pred, tensor_gt in zip(
59 records, tensor_images, mask_preds, tensor_gts
60 ):
61 pred = BaseRecord(
62 (
63 ImageRecordComponent(),
(...)
66 )
67 )
---> 69 pred.segmentation.set_class_map(record.segmentation.class_map)
70 pred.segmentation.set_mask_array(MaskArray(mask_pred.cpu().numpy()[None]))
72 if tensor_gt is not None:
73
74 # This is used at train time to have mask available for metric computation
File /projects/icevision/icevision/core/components/composite.py:46, in TaskComposite.getattr(self, name)
43 except KeyError:
44 pass
---> 46 raise AttributeError(f"{self.class.name} has no attribute {name}")
AttributeError: BaseRecord has no attribute segmentation
The text was updated successfully, but these errors were encountered:
🐛 Bug
Describe the bug
A clear and concise description of what the bug is.
The inference do not work for semantic segmentation.
To Reproduce
Steps to reproduce the behavior:
AttributeError: BaseRecord has no attribute segmentation
imgs_array = list([PIL.Image.open(f) for f in image_files[:10]])
infer_ds = Dataset.from_images(imgs_array, valid_tfms, class_map=class_map)
Batch Inference
infer_dl = model_type.infer_dl(infer_ds, batch_size=1, shuffle=False)
preds = model_type.predict_from_dl(model, infer_dl, keep_images=True)
`
I get the following error:
"AttributeError: BaseRecord has no attribute segmentation"
AttributeError Traceback (most recent call last)
Cell In [131], line 9
5 # model_type.show_results(model, infer_ds, num_samples=4)
6
7 # Batch Inference
8 infer_dl = model_type.infer_dl(infer_ds, batch_size=4, shuffle=False)
----> 9 preds = model_type.predict_from_dl(model, infer_dl, keep_images=True)
File /projects/icevision/icevision/models/fastai/unet/prediction.py:112, in predict_from_dl(model, infer_dl, show_pbar, keep_images, **predict_kwargs)
105 def predict_from_dl(
106 model: nn.Module,
107 infer_dl: DataLoader,
(...)
110 **predict_kwargs,
111 ):
--> 112 return _predict_from_dl(
113 predict_fn=_predict_batch,
114 model=model,
115 infer_dl=infer_dl,
116 show_pbar=show_pbar,
117 keep_images=keep_images,
118 **predict_kwargs,
119 )
File ~/.pyenv/versions/3.10.7/envs/3107/lib/python3.10/site-packages/torch/autograd/grad_mode.py:27, in _DecoratorContextManager.call..decorate_context(*args, **kwargs)
24 @functools.wraps(func)
25 def decorate_context(*args, **kwargs):
26 with self.clone():
---> 27 return func(*args, **kwargs)
File /projects/icevision/icevision/models/utils.py:107, in _predict_from_dl(predict_fn, model, infer_dl, keep_images, show_pbar, **predict_kwargs)
105 all_preds = []
106 for batch, records in pbar(infer_dl, show=show_pbar):
--> 107 preds = predict_fn(
108 model=model,
109 batch=batch,
110 records=records,
111 keep_images=keep_images,
112 **predict_kwargs,
113 )
114 all_preds.extend(preds)
116 return all_preds
File ~/.pyenv/versions/3.10.7/envs/3107/lib/python3.10/site-packages/torch/autograd/grad_mode.py:27, in _DecoratorContextManager.call..decorate_context(*args, **kwargs)
24 @functools.wraps(func)
25 def decorate_context(*args, **kwargs):
26 with self.clone():
---> 27 return func(*args, **kwargs)
File /projects/icevision/icevision/models/fastai/unet/prediction.py:25, in _predict_batch(model, batch, records, keep_images, device)
22 images = images.to(device)
24 raw_preds = model(images)
---> 25 preds = convert_raw_predictions(
26 batch=batch,
27 raw_preds=raw_preds,
28 records=records,
29 keep_images=keep_images,
30 )
32 return preds
File /projects/icevision/icevision/models/fastai/unet/prediction.py:69, in convert_raw_predictions(batch, raw_preds, records, keep_images)
58 for record, tensor_image, mask_pred, tensor_gt in zip(
59 records, tensor_images, mask_preds, tensor_gts
60 ):
61 pred = BaseRecord(
62 (
63 ImageRecordComponent(),
(...)
66 )
67 )
---> 69 pred.segmentation.set_class_map(record.segmentation.class_map)
70 pred.segmentation.set_mask_array(MaskArray(mask_pred.cpu().numpy()[None]))
72 if tensor_gt is not None:
73
74 # This is used at train time to have mask available for metric computation
File /projects/icevision/icevision/core/components/composite.py:46, in TaskComposite.getattr(self, name)
43 except KeyError:
44 pass
---> 46 raise AttributeError(f"{self.class.name} has no attribute {name}")
AttributeError: BaseRecord has no attribute segmentation
The text was updated successfully, but these errors were encountered: