Filipa Almeida Filipa Almeida - 18 days ago 8
Python Question

How to load images and labels to image_data_layer using Python?

I'm trying to load images to a network and calculate the top 5 error rate. My data layer is

name: "CaffeNet"
layer {
name: "data"
type: "ImageData"
top: "data"
top: "label"
image_data_param {
source: "/home/filipa/PycharmProjects/Proposal_Code/Labels/val.txt"

}
}


where val.txt file have the name of each image and correspondent label. (Total 50000 images)

My last layers are

name: "fc8"
type: "InnerProduct"
bottom: "fc7"
top: "fc8"
inner_product_param {
num_output: 1000
}
}
layer {
name: "prob"
type: "Softmax"
bottom: "fc8"
top: "prob"
}
layer {
name: "accuracy_top_5"
type: "Accuracy"
bottom: "fc8"
bottom: "label"
top: "accuracy_top_5"
accuracy_param {
top_k: 5
}
include {
phase: TEST
}
}


The error I'm getting is

E1116 11:34:28.173830 7465 io.cpp:80] Could not open or find file ILSVRC2012_val_00000001.JPEG
F1116 11:34:28.173835 7465 image_data_layer.cpp:72] Check failed: cv_img.data Could not load ILSVRC2012_val_00000001.JPEG


In my code, I load the image to the network as

im = caffe.io.load_image(IMAGE_FILE)


where IMAGE_FILE points to the exact location of my images.

Answer

I would edit the prototxt to be:

  image_data_param {
      root_folder: "/home/filipa/PycharmProjects/root/folder/for/data"
      source: "/home/filipa/PycharmProjects/Proposal_Code/Labels/val.txt"
  }

And then set the paths in "val.txt" to be relative to the root_folder.

Comments