muhleder / elasticsearch-vector-scoring

Apache License 2.0
36 stars 16 forks source link

Converting Numpy Array to Acceptable Format #3

Closed xemose closed 6 years ago

xemose commented 6 years ago

Hello,

I'm trying to convert a 128 numpy array for a face vector into the format in the example. My array looks something like: I shortened the data

[array([ -6.16890378e-02,   1.32967532e-01,   5.41357733e-02,
        -5.18525653e-02,  -1.45536378e-01,   5.02044894e-02,
        -3.01426891e-02,  -1.59610152e-01,   1.00656509e-01,
        -1.02305926e-01,   2.94480890e-01,  -4.39144783e-02,
        -2.55719155e-01,   1.88736506e-02,   1.56637020e-02,
         1.06674865e-01,  -1.35885611e-01,  -1.80689216e-01,
        -1.08774021e-01,  -1.22006856e-01,  -4.66329567e-02,
         8.44624937e-02,  -2.24375781e-02,   4.32376787e-02])]

I get that you have to put it into base64, but how would you go about doing this? Would I go through all the values and merge them into one big string, then conver that to base64?

Also I noticed the example had some / in it. I was wondering if that represented the commas

From Example: v7l48eAAAAA/s4VHwAAAAD+R7I5AAAAAv8MBMAAAAAA/

Thank You!

xemose commented 6 years ago

Figured it out!

For anyone looking at this in the future the solution is base64.b64encode(encoding[0])