In Pytorch no normalize but has toTensor

MarcSteven: <p>I converted the PyTorch to CoreML and then used it in my iOS project.<br>
But I found in PyTorch there is no normalize code to do image preprocess , so it means I should do image preprocess option in CoreML.<br>
Does it have same effect between toTensor and Normalize</p>

Marc_Dumon: <p>You can do image normalization with <code>torchvision.transforms.Normalize(mean, std, inplace=False)</code>, if that’s what you want to do.</p>

MarcSteven: <p><a class="mention" href="/u/marc_dumon">@Marc_Dumon</a> <div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/e/c/ec119b53be3cc81ecc0f53c5bab5c52cadf61000.png" data-download-href="https://discuss.pytorch.org/uploads/default/ec119b53be3cc81ecc0f53c5bab5c52cadf61000" title="Screen Shot 2020-01-08 at 12.22.50"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/e/c/ec119b53be3cc81ecc0f53c5bab5c52cadf61000_2_383x499.png" alt="Screen Shot 2020-01-08 at 12.22.50" data-base62-sha1="xGmp7ZTpIRjkiChYWg32Bi7fRpC" width="383" height="499" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/e/c/ec119b53be3cc81ecc0f53c5bab5c52cadf61000_2_383x499.png, https://discuss.pytorch.org/uploads/default/optimized/3X/e/c/ec119b53be3cc81ecc0f53c5bab5c52cadf61000_2_574x748.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/e/c/ec119b53be3cc81ecc0f53c5bab5c52cadf61000.png 2x" data-dominant-color="3E4041"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">Screen Shot 2020-01-08 at 12.22.50</span><span class="informations">608×792 24.7 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div>my model file without scaler<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/1/4/14d23bc08edfb1f06ce109f22c952a2c8a25d2ce.png" data-download-href="https://discuss.pytorch.org/uploads/default/14d23bc08edfb1f06ce109f22c952a2c8a25d2ce" title="Screen Shot 2020-01-08 at 12.23.12"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/1/4/14d23bc08edfb1f06ce109f22c952a2c8a25d2ce_2_690x369.png" alt="Screen Shot 2020-01-08 at 12.23.12" data-base62-sha1="2YbYhVAwESzTDZPHWSIKgCGu6QK" width="690" height="369" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/1/4/14d23bc08edfb1f06ce109f22c952a2c8a25d2ce_2_690x369.png, https://discuss.pytorch.org/uploads/default/original/3X/1/4/14d23bc08edfb1f06ce109f22c952a2c8a25d2ce.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/1/4/14d23bc08edfb1f06ce109f22c952a2c8a25d2ce.png 2x" data-dominant-color="404041"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">Screen Shot 2020-01-08 at 12.23.12</span><span class="informations">762×408 10.5 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div> standard model file<br>
I met one weird issue - I input the image and then predict wrongly.I used CoreML but the model doesn’t have scaler</p>
<p><a class="mention" href="/u/ptrblck">@ptrblck</a></p>

Marc_Dumon: <p>Could you rephrase because I have no idea what your problem is.</p>

MarcSteven: <p><a class="mention" href="/u/marc_dumon">@Marc_Dumon</a> because onnx doesn’t support preprocess so in CoreML I must do the job manually.So I mean the model doesn’t have scaler.</p>

Marc_Dumon: <p>In pytorch you can do normalization, resizing etc with <a href="https://pytorch.org/docs/stable/torchvision/transforms.html" rel="nofollow noopener">torchvision.transforms</a>.</p>

MarcSteven: <p>Yeah ,if don’t do normalization ,what will happen ?</p>