caffe2官网教程学习(三)—— 图像预处理

本文档详细介绍了Caffe2中图像预处理的步骤,包括从RGB到BGR转换、旋转与镜像处理、调整图像大小以适应模型输入、保持纵横比缩放、裁剪、按比例放大图像以及批处理的HWC到CHW转换。Caffe2期望图像以BGR顺序和CHW格式存储,以便于GPU处理。
摘要由CSDN通过智能技术生成

  • image prep for Caffe2 ingestion
  • Caffe Prefers CHW Order
  • H: Height
  • W: Width
  • C: Channel (as in color)
  • For GPU processing, which is what Caffe2 excels at, this order needs to be CHW. For CPU processing, this order is generally HWC. 
  • And the reason points to cuDNN which is what helps accelerate processing on GPUs. It uses only CHW, and we'll sum it up by saying it is faster.
  • Caffe Uses BGR Order
  • Due to legacy support of OpenCV in Caffe and how it handles images in Blue-Green-Red (BGR) order instead of the more commonly used Red-Green-Blue (RGB) order, Caffe2 also expects BGR order. 

1.导入模块

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

%matplotlib inline
import skimage
import skimage.io as io
import skimage.transform 
import sys
import numpy as np
import math
from matplotlib import pyplot
import matplotlib.image as mpimg
print("Required modules imported.")

2.测试一个图像RGB->BGR 

# You can load either local IMAGE_FILE or remote URL
# For Round 1 of this tutorial, try a local image.
IMAGE_LOCATION = 'images/cat.jpg'

# 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值