Enhance evaluation suite to support visualization of multi-input and target#35
Enhance evaluation suite to support visualization of multi-input and target#35wli51 wants to merge 1 commit into
Conversation
…put and multi-target dataset and predictions
d33bs
left a comment
There was a problem hiding this comment.
Nice! Consider also adding tests to prove these capabilities out a bit more. Given that visualization is involved, it could be helpful to rapidly perform a visual test as well (something static perhaps but that would change in the source diff if something changed).
| def _to_numpy_image(value: Any) -> np.ndarray: | ||
| if isinstance(value, torch.Tensor): | ||
| return value.detach().cpu().numpy() | ||
| return np.asarray(value) | ||
|
|
||
|
|
||
| def _normalize_to_list(sample: Any) -> List[np.ndarray]: |
There was a problem hiding this comment.
Consider docstrings providing information as to what these do and why.
| inputs.append(input_list[0] if len(input_list) == 1 else input_list) | ||
| targets.append(target_list[0] if len(target_list) == 1 else target_list) |
There was a problem hiding this comment.
Could the normalization step do this?
| def _to_numpy_image(value: Any) -> np.ndarray: | ||
| if isinstance(value, torch.Tensor): | ||
| return value.detach().cpu().numpy() | ||
| return np.asarray(value) | ||
|
|
||
|
|
||
| def _normalize_to_list(sample: Any) -> List[np.ndarray]: | ||
| if isinstance(sample, (list, tuple)): | ||
| return [_to_numpy_image(item) for item in sample] | ||
| return [_to_numpy_image(sample)] |
There was a problem hiding this comment.
These seem to be repeats from another module. Consider reusing them instead of reinventing.
| return [_to_numpy_image(sample)] | ||
|
|
||
|
|
||
| def _split_channels(img: np.ndarray, channel_indices: Optional[List[int]]) -> List[np.ndarray]: |
There was a problem hiding this comment.
Similar comments here, consider adding docstrings for all functions in this PR.
| return split_images | ||
|
|
||
|
|
||
| def _build_titles(prefix: str, count: int) -> List[str]: |
There was a problem hiding this comment.
This is a pretty thin function. Consider a lambda closer to where needed.
Helps with visualization of multi channel dataset and multi channel prediction