ptran / idla-person-reid

dlib implementation of the "Improved Deep Learning Architecture for Person Re-Identification"
31 stars 11 forks source link

How to use this project as 3rd Party? #8

Open yagiken0525 opened 5 years ago

yagiken0525 commented 5 years ago

I could build the source file and currently learning the model using run_cuhk03. After I correctly finishing learning process, how can I use it from my own C++ project?

ptran commented 5 years ago

@yagiken0525 Haven't had time, but I'm going to restructure this over the next month to make it easier to do what you're talking about. In the meantime, all you need is to to implement the inference network with the following:

template <
    long num_filters,
    long nr,
    long nc,
    int stride_y,
    int stride_x,
    typename SUBNET
    >
using connp = dlib::add_layer<dlib::con_<num_filters,nr,nc,stride_y,stride_x,0,0>, SUBNET>;

template <long N, template <typename> class BN, long shape, long stride, typename SUBNET>
using block = dlib::relu<BN<connp<N, shape, shape, stride, stride, SUBNET>>>;

using mod_idla = dlib::softmax<dlib::fc<2,
                               dlib::relu<dlib::affine<dlib::fc<500,reinterpret<2,
                               dlib::max_pool<2,2,2,2,block<25,dlib::affine,3,1,
                               block<25,dlib::affine,5,5,
                               dlib::relu<cross_neighborhood_differences<5,5,
                               dlib::max_pool<2,2,2,2,block<25,dlib::affine,3,1,block<25,dlib::affine,3,1,
                               dlib::max_pool<2,2,2,2,block<20,dlib::affine,3,1,block<20,dlib::affine,3,1,
                               input_rgb_image_pair
                               >>>>>>>>>>>>>>>>>;

Instantiate mod_idla and load the weights into it.