pycaffe

Caffe HDF5 pixel-wise classification

最后都变了- 提交于 2019-12-12 11:18:01
问题 I am trying to implement a pixel-wise binary classification for images using caffe. For each image having dimension 3x256x256, I have a 256x256 label array in which each entry is marked as either 0 or 1. Also, when I read my HDF5 file using the below code, dirname = "examples/hdf5_classification/data" f = h5py.File(os.path.join(dirname, 'train.h5'), "r") ks = f.keys() data = np.array(f[ks[0]]) label = np.array(f[ks[1]]) print "Data dimension from HDF5", np.shape(data) print "Label dimension

How to generate concate layer prototxt using python

筅森魡賤 提交于 2019-12-12 04:22:21
问题 I have a prototxt as follows: layer { name: "data" type: "HDF5Data" top: "data1" top: "data2" top: "label" include { phase: TRAIN } hdf5_data_param { source: "./source_list.txt" batch_size: 2 shuffle: true } } layer { name: "concat" type: "Concat" bottom: "data1" bottom: "data2" top: "data" concat_param { concat_dim:1 } } I want to generate above prototxt using caffe NetSpec in python. However, It was wrong. This is my code. Please help me to fix it. Thanks from caffe import layers as L ... n

Caffe install getting ImportError: DLL load failed: The specified module could not be found

≡放荡痞女 提交于 2019-12-12 04:06:00
问题 I am trying to compile and run the snippets posted here, which basically is going to let me visualize the network internals(feature maps). I have successfully compiled caffe and pycaffe using the caffe-windows branch, And I have copied the caffe folder, into T:\Anaconda\Lib\site-packages folder. Yet still, when I try to run this snippet of code in jupyter notebook : import numpy as np import matplotlib.pyplot as plt %matplotlib inline # Make sure that caffe is on the python path: caffe_root =

How do I reduce 4096-dimensional feature vector to 1024-dimensional vector in CNN Caffemodel?

余生长醉 提交于 2019-12-11 22:07:18
问题 I used 16-layers VGGnet to extract features from an image. It outputs a 4096-dimensional feature vector. However, I need a 1024-dimensional vector. How do I further reduce this 4096-vector into 1024-vector? Do I need to add a new layer on top of fc7 ? 回答1: Yes, you need to add another layer on top of fc7 . This is how your last few layers should be like layers { bottom: "fc7" top: "fc7" name: "relu7" type: RELU } layers { bottom: "fc7" top: "fc7" name: "drop7" type: DROPOUT dropout_param {

caffe create networks by python

旧城冷巷雨未停 提交于 2019-12-11 12:14:52
问题 We all know this python code can create caffe networks: n = caffe.NetSpec() n.data, n.label = L.Data(batch_size=batch_size, backend=P.Data.LMDB, source=lmdb, transform_param=dict(scale=1. / 255), ntop=2) n.conv1 = L.Convolution(n.data, kernel_size=5, num_output=20, weight_filler=dict(type='xavier')) n.pool1 = L.Pooling(n.conv1, kernel_size=2, stride=2, pool=P.Pooling.MAX) The layer's name is on the right of n. for example:"n.data",this layer's name is "data". Write simple code If I want to

Getting error for adding InfogainLoss layer?

只谈情不闲聊 提交于 2019-12-11 07:29:47
问题 I followed the instructions here to create weight matrix for classes and add the Infogainloss function, which is able to tackle my imbalance data. The few last layers .... layer { name: "score_fr" type: "Convolution" bottom: "fc7" top: "score_fr" param { lr_mult: 1 decay_mult: 1 } param { lr_mult: 2 decay_mult: 0 } convolution_param { num_output: 5 #21 pad: 0 kernel_size: 1 weight_filler { type: "xavier" } bias_filler { type: "constant" } } } layer { name: "upscore" type: "Deconvolution"

Caffe CNN: multiple hierarchical losses for hierarchical classification

大城市里の小女人 提交于 2019-12-11 06:55:17
问题 I am familiar with how to use multiple loss in a CNN while all the labels of these loss are identical. My case here is handling hierarchical labels using multiple losses, as shown in figure bellow: loss1 is responsible for labelset1:{Sport, Food}. loss2 for labelset2:{volley, soccer}, loss3 for labelset3:{Pizza, Pasta, burger}. For example, Sample A∈{sport, soccer}, sample B∈{food,burger}. Any ideas how to do this? 回答1: Adding "don't care" lables, you should have three labels for each sample.

How to solve this issue in Python (creating weights for Infogain Loss layer)?

烂漫一生 提交于 2019-12-11 06:36:24
问题 I am working on semantic segmentation using CNNs. I have an imbalance number of pixels for each class. Based on this link, I am trying to create weight matrix H in order to define Infogain loss layer for my imbalance class members. My data has five classes. I wrote the following code in python: Reads a sample image: im=imread(sample_img_path) Counts the number of pixels of each class cl0=np.count_nonzero(im == 0) #0=background class . . cl4=np.count_nonzero(im == 4) #4=class 4 output: 39817

How can i know whether “bias” exists in a layer?

雨燕双飞 提交于 2019-12-11 06:17:59
问题 I'm trying to read weight and bias in a caffe network with pycaffe. Here is my code weight = net.params[layer_name][0].data bias = net.params[layer_name][1].data But, some layers in my network has no bias, so that there will be an error which is Index out of range . So my question is can I use if(net.params[layer_name][1] exists): bias = net.params[layer_name][1].data to control the assignments to bias ? And how to write the code? 回答1: You can simply iterate over net.params[layer_name] :

caffe:Check failed: target_blobs.size() == source_layer.blobs_size() (2 vs. 1) Incompatible number of blobs for layer conv1

…衆ロ難τιáo~ 提交于 2019-12-11 06:14:15
问题 I modify the FCN net and design a new net,in which I use two ImageData Layer as input param and hope the net produces a picture as output. here is the train_val.prototxt and the deploy.prototxt the original picture and the label are both gray scale pics and sizes are 224*224. I've trained a caffemodel and use infer.py to use the caffemodel to do a segmentation,but meet the error: F0505 06:15:08.072602 30713 net.cpp:767] Check failed: target_blobs.size() == source_layer.blobs_size() (2 vs. 1)