Python usage record

Source: Internet
Author: User

1. Python Loaded Caffe Mean.binaryproto
# # # # mean_file # # " RB "  == Caffe.io.blobproto_to_array (a) [0]

2. Python Loading caffe image input
## # # Load input and configure preprocessing type 1 # # # # #im = Caffe.io.load_image ("tmp.jpg")#read it in RGB format and 0~1Transformer = Caffe.io.Transformer ({'Data': net_full_conv.blobs['Data'].data.shape})#Transformer.set_mean (' Data ', np.load (caffe_root + ' python/caffe/imagenet/ilsvrc_2012_mean.npy '). Mean (1). Mean (1))Transformer.set_transpose ('Data', (2, 0, 1))#channel width (cols) height (cows)Transformer.set_channel_swap ('Data', (2, 1, 0))#transform RGB to BGRTransformer.set_raw_scale ('Data', 255.0)#Zoom to 0~255

# # # # Load input and configure preprocessing type 2 # # # # # #Cv_im = Cv2.imread ("tmp.jpg" c5>) transformer.set_transpose ('data'#

3. Python OpenCV
# # # #python opencv####  = Img.rows = High img.shape[1] = img.cols= cv2.resize (src, newshape[1], newshape[0], interpolation = Cv2. Inter_linear) C+ +: Resize (midimage, Tmpimage, Cv::size (Ratio*midimage.cols, ratio*midimage.rows), (0, 0), (0, 0), Cv::inter_area);

4. Python matplotlib
## # #python matplotlib####ImportMatplotlib.pyplot as Plt#plt for displaying picturesImportMatplotlib.image as Mpimg#mpimg for reading picturesImportNumPy as Nplena= Mpimg.imread ('Lena.png')#Lena.png of Reading and code in the same directory#at this time Lena is already a np.array, you can handle it arbitrarilyLena.shape#(3)Plt.imshow (Lena)#Show PicturesPlt.axis ('off')#do not display axesplt.show () FIG= Plt.figure ()#New Figure 0Plt.savefig ()#SavePlt.close (' All')#close Up Figure 0

Python usage record

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.