Caffe2 : image requirements and things we need to be aware of.

Caffe2 : requirements for image and things we need to be aware of.
 
1. Caffe2 requires image in BGR order, which is different from more commonly used RGB order. The result you get from image input of different color order can lead to entirely different results.

2. Aside from the color order requirement, there is also the image format requirement. To illustrate, For GPU processing,caffe2 expects image in CHW order(because cuDNN expects image in CHW format); for CPU processing, caffe2 expects image in HWC format.

To sum the following two points up, a raw image has to go through two preprocessing steps:

A. RGB->BGR
B. CHW->HWC(FOR CPU PROCESSING) / HWC->CHW(FOR GPU PROCESSING)

3. Resizing: images in caffe2 should be square(?), so image resizing is sometimes required. However, resizing could lead to image distortion, and in cases such as face detection distortion is not desired, so we use rescaling.

4. Rescaling: as resizing is not desired, we could use rescaling. Firstly, rescale the image by its short side, that is, if our desired image size is 128x128 and the raw image is 200x300, we can rescale the image by a factor of 200/128=1.5625 and the resulting image turns into 128x192, then we can crop 192 to 128 and the image turns into 128x128.

5. Upscaling: well....I think image upscaling is rarely used, so I will add this part when I need it.

转载于:https://www.cnblogs.com/SongHaoran/p/7660775.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值