@tags caffe python

windows下配置caffe后,create_cifar10.sh无法执行,因为是shell脚本。那就看懂脚本意思,用python重写一个:

# create_cifar10.py
# by ChrisZZ

import os
import shutil

EXAMPLE="examples\\cifar10"
DATA="data\\cifar10"
DBTYPE="lmdb"

print "Creating "+DBTYPE+"..."

path1=EXAMPLE+"\\cifar10_train_"+DBTYPE
path2=EXAMPLE+"\\cifar10_test_"+DBTYPE

if os.path.exists(path1):
    shutil.rmtree(path1)
if os.path.exists(path2):
    shutil.rmtree(path2)

caffe_build=os.environ['caffe_build']
cmd1=caffe_build+"\\convert_cifar_data.exe "+DATA+" "+EXAMPLE+" "+DBTYPE
print cmd1
os.system(cmd1)

print "Computing image mean..."

cmd2=caffe_build+"\\compute_image_mean.exe --backend="+DBTYPE+" "+EXAMPLE+"\\cifar10_train_"+DBTYPE+" "+EXAMPLE+"\\mean.binaryproto"
print cmd2
os.system(cmd2)

然后在<caffe_root>目录执行:

python examples\cifar10\create_cifar10.py