我有一件事想请教大家,就是调用’/api/storage’接口时传递的格式参数是什么,‘storage_id’和’vector encoding’,‘Image encoding’和’identity_id’有什么关系。
What is the relationship between storage_id
and vector_encoding
, image_encoding
and identity_id
Okay, that’s a good question. Think of Identity
as a specific person. That person can have many things associated with it. You might want to associate a ‘face’ and a ‘person’ and a ‘license_plate’ with the same Identity. Because of that, we allow creation of identities, and then the association of an identity with a specific image.
These “images” are templates. For example, think about a face recognition application. It needs the user to upload example images of “Alex”'s face in order to recognize “Alex”. There might even be multiple template images- so the relationship between # of template images and an Identity is NOT 1:1.
When you upload face images to brainframe (documented here Identities) what happens is BrainFrame will try to extract a “encoding” that describes that face. That “encoding” is a vector, produced by a machine learning model inside of a capsule. BrainFrame can use that vector/encoding to judge the similarity of faces in a video stream to known faces from a template.
HOWEVER- sometimes, there are objects that can be “recognized” that are NOT faces. For example, in the case of a fiducial tag (example image: https://i.imgur.com/UMoMbBa.png), these tags can automatically be converted to a number or a vector. For those cases, BrainFrame allows you to directly upload a “vector” to associate with an Identity, that way, if a capsule is able to detect that Vector, BrainFrame will then associate it with an identity and return it through the API.
To summarize:
Identities can have many ‘templates’ associated with them. Different pictures of the same persons face, maybe pictures of a license plate, etc.
BrainFrame recognizes things by converting images into vectors, using whatever method the capsule outputs. It then compares vectors to see how similar they are, and matches similar vectors with the known identity in the database.
你可以想象一下你在实际生活中是如何识别一个人的身份的,举例来说,你有个朋友叫张三,你是如何判断你现在看到的人是不是张三?你会去自己的记忆中搜索张三的特征,与眼前的人做比较,从而判断是不是同一个人,这里的特征可能是他的脸,穿着,或者身高体重等等,同时在你的脑海中关于张三的记忆可能不止一个,比如不同发型、不同年龄、不同穿着的张三,你会将记忆中不同特征的张三与眼前的人做比较,从而得到你的判断。
与实际生活不同,在人工智能领域,以人脸识别为例,一般识别的方法是通过算法计算得到某个人脸图片的矢量,再计算这个矢量与目标人脸矢量的差别来判断两个人脸是否属于同一个人。当然不同的算法对应的计算方法不同,比如这张图片中的二维码,它对应的不是一个矢量,而就是一个数字,算法会通过数字来判断是否为同一个二维码。
在BrainFrame中,Identity代表的是一个身份,可以是某个人,某辆车,或者某个车牌,每个Identity都会有对应的identity_id。对应上面实际生活中的例子,identity_id就是张三。image_encoding和vector_encoding就是用来描述或者识别某个Identity的方法,对应上面的例子,它们可以是张三的人脸,穿着,身高体重等等。因此identity_id与image_encoding和vector_encoding的对应关系不是1比1的,一个identity_id可能对应多个image_encoding或者vector_encoding。
image_encoding与vector_encoding是有区别的,对image_encoding来说,BrainFrame会根据image_encoding的类型(比如人脸、车牌)调用不同的胶囊从图片中计算矢量,因此image_encoding必须对应一张图片,而在BrainFrame中所有图片都是存在数据库中的并且有一个与之对应storage_id,因此想要创建一个新的image_encoding,你需要先将图片上传到Brainframe的数据库中并的到一个对应的storage_id,并使用它来创建Image_encoding。而vector_encoding则是这个矢量本身,你可以直接上传矢量而不是图片,因此它不需要storage_id就可以创建,但是你需要确保生成这个矢量的算法与BrainFrame使用的算法的使用一个算法,以为即使是同一个人脸,不同算法计算出来的矢量可能是不同的。
总结一下,一个identity可以对应多个image_encoding和vector_encoding,不同的image_encoding和vector_encoding对应的可能是同一个人的不同人脸照片或矢量,或者同一个车牌的不同照片或矢量。当检测到某个物体后,BrainFrame会根据物体的类型调用不同算法胶囊是计算矢量并与数据库中的image_encoding或vector_encoding比较,从而判断这个物体的的身份。