title: convert float image array to int in PIL via Image.fromarray
body: <p>I have a PyTorch tensor of shape <code>3,256,256</code> where 3 is the number of channels and the image dimensions are 256, with all float values.</p>
  
  <p>I am trying to feed this into the network and use PIL to do some transforms. To this end, I do:</p>
  
  <pre><code>img = Image.fromarray((255*imgs[i]).numpy().astype(np.uint8))
  </code></pre>
  
  <p>but I get:</p>
  
  <pre><code>TypeError: Cannot handle this data type: (1, 1, 256), |u1
  </code></pre>
  
  <p>When I check the output of <code>(255*imgs[i]).numpy().astype(np.uint8)</code>, I do however see, for example:</p>
  
  <pre><code>[[[ 62  57  59 ...  63  46  36]
    [ 72  71  67 ...  80  76  82]
    [ 58  63  63 ... 145 152 169]
    ...
    [238 240 243 ...   7   7   7]
    [241 239 240 ...   5   5   6]
    [241 243 242 ...   4   3   5]]
  
   [[ 83  78  80 ...  86  70  61]
    [ 91  90  85 ...  95  93  98]
    [ 80  83  80 ... 141 150 168]
    ...
    [176 178 181 ...  14  14  14]
    [177 176 178 ...  15  15  17]
    [179 180 180 ...  13  13  15]]
  
   [[147 141 143 ... 150 136 128]
    [147 149 148 ... 154 149 154]
    [141 149 148 ... 178 182 196]
    ...
    [129 131 134 ...  43  43  43]
    [130 130 131 ...  45  45  47]
    [133 134 133 ...  44  44  46]]]
  </code></pre>
  
  <p>I am not an image expert by a long shot, and I am struggling to troubleshoot this issue now.</p>