Skip to content

RandGaussianNoise changes the type of the input to np.float64 #356

@murraycutforth

Description

@murraycutforth

First, thanks for creating a great library!

Describe the bug
Applying the RandGaussianNoise tranform to a np.float32 array changes the dtype to np.float64. This causes a crash down the line since pytorch expects np.float32 inputs.

Expected behavior
The transformed image's dtype does not change

Screenshots
image

Environment (please complete the following information):

  • OS: Centos 7
  • Python version: 3.6
  • MONAI version: 0.1.0

This could be an easy fix, by changing
return img + self._noise if self._do_transform else img
to
return img + self._noise.astype(img.dtype) if self._do_transform else img .

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions