Image-Text-Embedding icon indicating copy to clipboard operation
Image-Text-Embedding copied to clipboard

any way to get text/image embedding

Open xogo123 opened this issue 7 years ago • 10 comments

is there any way to get text or image embedding if given text or image as input? thanks

xogo123 avatar Mar 02 '18 14:03 xogo123

Hi @xogo123 You may check the code in the test dir. You would find the code with name extract feature. I used them to extract text & image embedding.

layumi avatar Mar 03 '18 08:03 layumi

thanks a lot. there's another problem showed below when I run the code "extract_pic_feature_word2_plus_52" on my macbook

Undefined variable "dagnn" or class "dagnn.DagNN.loadobj". Error in extract_pic_feature_word2_plus_52 (line 3) net = dagnn.DagNN.loadobj(netStruct.net);

so I followed the instruction below to compile http://www.vlfeat.org/matconvnet/install/ run

mex -setup C++ cd <MatConvNet> addpath matlab vl_compilenn run <MatConvNet>/matlab/vl_setupnn

and run extract_pic_feature_word2_plus_52 again but another issue come out as below

Error using dagnn.Layer/load (line 200) No property init for a layer of type dagnn.Conv. Error in dagnn.DagNN.loadobj (line 27) block.load(struct(s.layers(l).block)) ; Error in extract_pic_feature_word2_plus_52 (line 3) net = dagnn.DagNN.loadobj(netStruct.net);

any thought? are you using matlab r2017b? matconvnet-1.0-beta25? or others? what's your other environment? (OS? compiler?)

or is there any chance to pack your "extract" code as an python app such that input : sentence or image output : sentence or image embedding after your model I think that will be very helpful for many python user

thanks

xogo123 avatar Mar 03 '18 17:03 xogo123

Hi @xogo123 Sorry for that. In fact, I write this code on two machines. Some part of code is mis-matching.

One easy way is to ignore the init in the Conv Layer. (I use it to chose msra init or other init methods.) Please comment https://github.com/layumi/Image-Text-Embedding/blob/master/matlab/%2Bdagnn/Layer.m#L205

Hope it may help you. If the bug still appears, let me know.

layumi avatar Mar 04 '18 00:03 layumi

@layumi hello, I have the same problem, Error using dagnn.Layer/load (line 200) No property init for a layer of type dagnn.Conv.

Error in dagnn.DagNN.loadobj (line 27) block.load(struct(s.layers(l).block)) ;

Error in extract_pic_feature_word2_plus (line 4) net = dagnn.DagNN.loadobj(netStruct.net); how can I solve it?

jingyaa avatar Apr 25 '18 10:04 jingyaa

Hi @jingyaa Would you like to ignore the line in your code? https://github.com/layumi/Image-Text-Embedding/blob/master/matlab/%2Bdagnn/Layer.m#L205

If the bug still appears, let me know.

layumi avatar Apr 25 '18 11:04 layumi

Hi @layumi My Layer.m #205 is %error('No property %s for a layer of type %s.', ... But the bug still appears.

jingyaa avatar Apr 25 '18 13:04 jingyaa

@jingyaa Could you show me the code in dagnn.Layer/load (line 200) as mentioned in the log? The whole function is better.

layumi avatar Apr 25 '18 14:04 layumi

@layumi dagnn.Layer/load (line 200) is error('No property %s for a layer of type %s.', ... I ignore the line run again. No public property init exists for class dagnn.Conv.

Error in dagnn.Layer/load (line 203) obj.(fc) = s.(fc) ;

Error in dagnn.DagNN.loadobj (line 27) block.load(struct(s.layers(l).block)) ;

Error in extract_pic_feature_word2_plus (line 4) net = dagnn.DagNN.loadobj(netStruct.net);

jingyaa avatar Apr 25 '18 14:04 jingyaa

@jingyaa Did you use my Matconvnet? You install two matconvnet? Actually I has included my Matconvnet in this repos.

So there are two methods.

  1. Remove the matconvnet that you installed. Then install with my included matconvnet.

  2. Or replace the your matconvnet Layer.m with my Layer.m. I am not sure whether other bugs will appear.

So I suggest you uninstall the matconvnet you downloaded. And install my matconvnet.

layumi avatar Apr 25 '18 15:04 layumi

@layumi I install another Matconvnet. I will try your solution later. Thanks a lot.

jingyaa avatar Apr 26 '18 01:04 jingyaa