[PYTHON] [Caffe] Convert mean file from binary proto format to npy format

code


import caffe
import numpy as np
import sys

if len(sys.argv) != 3:
    print "Usage: python convert_protomean.py proto.mean out.npy"
    sys.exit()

blob = caffe.proto.caffe_pb2.BlobProto()
data = open( sys.argv[1] , 'rb' ).read()
blob.ParseFromString(data)
arr = np.array( caffe.io.blobproto_to_array(blob) )
out = arr[0]
np.save( sys.argv[2] , out )

Recommended Posts

[Caffe] Convert mean file from binary proto format to npy format
How to easily convert format from Markdown
Convert matplotlib graphs to emf file format
Convert binary packages for windows to wheel format
Convert a text file with hexadecimal values to a binary file
How to convert Json file to CSV format or EXCEL format
Convert Pascal VOC format xml file to COCO format json file
Convert hexadecimal string to binary
Convert HTML to text file
Linux script to convert Markdown files from JupyterLab format to Qiita format
Convert genbank file to gff file
Convert PIL format images read from form with Django to base64 format
Convert from pdf to txt 2 [pyocr]
[Python] How to convert db file to csv
Convert xml format data to txt format data (yolov3)
Script to generate directory from json file
How to convert Python to an exe file
[Python] Convert csv file delimiters to tab delimiters
Convert from PDF to CSV with pdfplumber
Convert psd file to png in Python
Convert from katakana to vowel kana [python]
Convert PDF attached to email to text format
Convert Python date types to RFC822 format
How to convert DateTimeField format in Django
Convert from Markdown to HTML in Python
convert youtube playlist to local m3u format file for smplayer (by toy tool)