Last active
November 26, 2020 08:21
-
-
Save aplz/cbaf270431286fd9fadb1060bb440c0d to your computer and use it in GitHub Desktop.
Create a sparse vector for dlib from a numpy array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""How to create a sparse vector for dlib from a numpy array. | |
dlib: http://dlib.net/ | |
""" | |
import dlib | |
import numpy | |
vector = [0,2,0] | |
sv = dlib.sparse_vector() | |
for i in numpy.nonzero(vector)[0]: | |
sv.append(dlib.pair(i, vector[i])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment