I want to read data from hdf5
file and do data augmentation.
I can do data augmentation in transform_param
with mirror and crop.
However,I cannot have transformation_param
in a HDF5Data
layer - caffe does not support this.
I consider it might be a good way to write a python layer to solve it. Read data from hdf5 file and do data augmentation at the same time.
I have read some relevant answers such as " caffe data layer example step by step " and " What is a Python layer in caffe? "
I still don't know some details such as where should I put the written file "*.py"
? And how to write the codes to do data augmentation?
You python layer *.py
should be in your $PYTHONPATH
.
Consider examples of python layers in $CAFFE_ROOT/examples/pycaffe/layers
,for custom python loss and data layer.
Consider particularly in $CAFFE_ROOT/examples/pycaffe/layers/pascal_multilabel_datalayers.py
Before next batch gets loaded, you can do the data augmentation on the fly.
Then in *.prototxt
layer {
name: "data"
type: "Python"
top: "data"
top: "label"
python_param {
module: "pascalcontext_layers"
layer: "PASCALContextSegDataLayer"
param_str: "{\'context_dir\': \'../../data/pascal-context\', \'seed\': 1337, \'split\': \'train\', \'voc_dir\': \'../../data/pascal\'}"
}
}
module
is the file name and layer
is the class name.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.