Skip to content

Commit

Permalink
fix: allows to specify size and color/bw with segmentation models
Browse files Browse the repository at this point in the history
  • Loading branch information
beniz authored and sileht committed Sep 15, 2020
1 parent 53edf52 commit 58ecb4a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/backends/caffe/caffelib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,10 @@ namespace dd
{
update_protofile_imageDataLayer(net_param);
}
else if (this->_inputc._segmentation)
{
update_protofile_denseImageDataLayer(net_param);
}

// input should be ok, now do the output
if (this->_inputc._multi_label)
Expand Down Expand Up @@ -638,6 +642,8 @@ namespace dd
this->_inputc.height());
lparam->mutable_dense_image_data_param()->set_new_width(
this->_inputc.width());
lparam->mutable_dense_image_data_param()->set_is_color(
this->_inputc.channels() == 3);
// XXX: DenseImageData supports crop_height and crop_width
}
}
Expand Down Expand Up @@ -4882,6 +4888,21 @@ namespace dd
lparam->clear_transform_param();
}

template <class TInputConnectorStrategy, class TOutputConnectorStrategy,
class TMLModel>
void CaffeLib<TInputConnectorStrategy, TOutputConnectorStrategy, TMLModel>::
update_protofile_denseImageDataLayer(caffe::NetParameter &net_param)
{
caffe::LayerParameter *lparam = net_param.mutable_layer(0);
caffe::DenseImageDataParameter *image_data_parameter
= lparam->mutable_dense_image_data_param();
image_data_parameter->set_new_height(this->_inputc.height());
image_data_parameter->set_new_width(this->_inputc.width());
ImgCaffeInputFileConn *timg
= reinterpret_cast<ImgCaffeInputFileConn *>(&this->_inputc);
image_data_parameter->set_is_color(!timg->_bw);
}

template <class TInputConnectorStrategy, class TOutputConnectorStrategy,
class TMLModel>
bool CaffeLib<TInputConnectorStrategy, TOutputConnectorStrategy,
Expand Down
2 changes: 2 additions & 0 deletions src/backends/caffe/caffelib.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@ namespace dd

void update_protofile_imageDataLayer(caffe::NetParameter &net_param);

void update_protofile_denseImageDataLayer(caffe::NetParameter &net_param);

void update_protofiles_dice_params(caffe::DiceCoefLossParameter *dclp,
const APIData &ad);

Expand Down

0 comments on commit 58ecb4a

Please sign in to comment.