Calling vision/face/register more than once

When calling the register accesspoint a second time for a userid, I get reply “updated”. Does this mean that the first image was removed?

I am making an application which scans for faces in photographs, and when the user identifies a face and I already have that person registered I want to add this “new” face/photo to the list of faces for this person.

Is there any way I can “add” a face, or must I re-assemble all photos for this person and call register again?

Thx
Peter

PS. According to Registering faces this is the way it works. I think this is a flaw that should be fixed. btw when will the code be open sourced? :wink:

@John can add more insight, but essentially the more images (e.g. from different angles) of a face you can add, the better. For each face a vector is calculated, then for new images this vector is calculated and compared to the vectors on record. If there is a close match then a face is recognised

1 Like

Hi @john, just wondering if you’re able to provide any input on this?

Obviously we’d like to be able to train the face recognition over time by adding additional faces.

Would your suggestion be to keep track of the list of all “known” faces separately, and when there’s a new image to add to the list, we send the whole list again?

Thanks

1 Like

@kanebullen to register a new face, you don’t need to send the whole list again. Every image added/registered is permanently store.

For training faces overtime, please refer to this comment on the DeepStack repository.

Thanks @OlafenwaMoses I’m a little confused though, as on the following post (DeepStack Release on Jetson ) you mentioned:

Note that overriding the registered images is by design. And this happens only when you are registering for an id you already registered prior.

Several people seem to be confused about this, such as on this thread:

Thanks
Kane

1 Like

@kanebullen Thanks for raising this question.

By design, you can register multiple images for the same face/id by registering all the images in a single request. The face embedding (used for recognition) generated will be averaged across all the images.

Python sample

user_image1 = open("image1.jpg","rb").read()
user_image2 = open("image2.jpg","rb").read()
..
.
.
.
user_imageX = open("imageX.jpg","rb").read()

response = requests.post("http://localhost:80/v1/vision/face/register",
files={"image1":user_image1,"image2":user_image2,........,"imageX":user_imageX },data={"userid":"Dr Thanos"}).json()

However, if you register new images in a different request, the existing face embedding will be replaced as opposed to updated.

Thanks @OlafenwaMoses, that clarifies it.

So if we are collecting images for training over time, we’ll just need to keep a copy of them, and each time we find a new one to use, call /vision/face/register with the full list. Easy enough.

2 Likes

Resubmission of multiple faces is quite cumbersome, so I wrote a small python script for registering faces with all image files in current directory. Perhaps someone finds it useful.

3 Likes

Trying to understand this…
How can I register say 3 faces for user 1, and 2 faces for user 2?

1 Like

There are few options here. You can use curl:
curl -F "image1=@file1.jpg" -F "image2=@file2.jpg" -F "userid=person_A" http://localhost/v1/vision/face/register

Or with the above deepstack manager, place image files of a person to a folder, enter it and run
dsm.py -H localhost register person_A

Thank you!
so If I want to register a multiple images for multiple people, I should have a folder for each person?

Exactly, move any new images to that folder and rerun the command.

1 Like

Thank you,
not sure if this is the correct place for posting this…
I am trying to register as follows:

python3 dsm.py -H localhost:777 register -p "/deepstack/faces/user1" user1

and my output is as follows:

Traceback (most recent call last):
File “dsm.py”, line 47, in
response = requests.post(“http://”+args.host+"/v1/vision/face/register", files=images, data={“userid”:args.name}).json()
File “/usr/local/lib/python3.6/dist-packages/requests/models.py”, line 897, in json
return complexjson.loads(self.text, **kwargs)
File “/usr/lib/python3/dist-packages/simplejson/init.py”, line 518, in loads
return _default_decoder.decode(s)
File “/usr/lib/python3/dist-packages/simplejson/decoder.py”, line 370, in decode
obj, end = self.raw_decode(s)
File “/usr/lib/python3/dist-packages/simplejson/decoder.py”, line 400, in raw_decode
return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

on my deepstack console, I get the following error messages:

2021/02/16 22:02:36 [Recovery] 2021/02/16 - 22:02:36 panic recovered:
runtime error: invalid memory address or nil pointer dereference
/usr/local/go/src/runtime/panic.go:212 (0x4575a9)
/usr/local/go/src/runtime/signal_unix.go:695 (0x4573f8)
/home/johnolafenwa/Documents/NewDeepStack/2/DeepStack/server/middlewares/middlewares.go:369 (0xa47663)
/home/johnolafenwa/go/pkg/mod/github.com/gin-gonic/gin@v1.4.0/context.go:124 (0x9ba07a)
/home/johnolafenwa/Documents/NewDeepStack/2/DeepStack/server/middlewares/middlewares.go:42 (0xa4663a)
/home/johnolafenwa/go/pkg/mod/github.com/gin-gonic/gin@v1.4.0/context.go:124 (0x9ba07a)
/home/johnolafenwa/go/pkg/mod/github.com/gin-gonic/gin@v1.4.0/logger.go:240 (0x9cba10)
/home/johnolafenwa/go/pkg/mod/github.com/gin-gonic/gin@v1.4.0/context.go:124 (0x9ba07a)
/home/johnolafenwa/go/pkg/mod/github.com/gin-gonic/gin@v1.4.0/recovery.go:83 (0x9cc95f)
/home/johnolafenwa/go/pkg/mod/github.com/gin-gonic/gin@v1.4.0/context.go:124 (0x9ba07a)
/home/johnolafenwa/go/pkg/mod/github.com/gin-gonic/gin@v1.4.0/gin.go:389 (0x9c328f)
/home/johnolafenwa/go/pkg/mod/github.com/gin-gonic/gin@v1.4.0/gin.go:351 (0x9c2ac2)
/usr/local/go/src/net/http/server.go:2807 (0x716d92)
/usr/local/go/src/net/http/server.go:1895 (0x71270b)
/usr/local/go/src/runtime/asm_amd64.s:1373 (0x471600)

2021/02/16 22:03:30 [Recovery] 2021/02/16 - 22:03:30 panic recovered:
runtime error: invalid memory address or nil pointer dereference
/usr/local/go/src/runtime/panic.go:212 (0x4575a9)
/usr/local/go/src/runtime/signal_unix.go:695 (0x4573f8)
/home/johnolafenwa/Documents/NewDeepStack/2/DeepStack/server/middlewares/middlewares.go:369 (0xa47663)
/home/johnolafenwa/go/pkg/mod/github.com/gin-gonic/gin@v1.4.0/context.go:124 (0x9ba07a)
/home/johnolafenwa/Documents/NewDeepStack/2/DeepStack/server/middlewares/middlewares.go:42 (0xa4663a)
/home/johnolafenwa/go/pkg/mod/github.com/gin-gonic/gin@v1.4.0/context.go:124 (0x9ba07a)
/home/johnolafenwa/go/pkg/mod/github.com/gin-gonic/gin@v1.4.0/logger.go:240 (0x9cba10)
/home/johnolafenwa/go/pkg/mod/github.com/gin-gonic/gin@v1.4.0/context.go:124 (0x9ba07a)
/home/johnolafenwa/go/pkg/mod/github.com/gin-gonic/gin@v1.4.0/recovery.go:83 (0x9cc95f)
/home/johnolafenwa/go/pkg/mod/github.com/gin-gonic/gin@v1.4.0/context.go:124 (0x9ba07a)
/home/johnolafenwa/go/pkg/mod/github.com/gin-gonic/gin@v1.4.0/gin.go:389 (0x9c328f)
/home/johnolafenwa/go/pkg/mod/github.com/gin-gonic/gin@v1.4.0/gin.go:351 (0x9c2ac2)
/usr/local/go/src/net/http/server.go:2807 (0x716d92)
/usr/local/go/src/net/http/server.go:1895 (0x71270b)
/usr/local/go/src/runtime/asm_amd64.s:1373 (0x471600)

When I run the list command, it works fine

I think I’m missing something

OK, I’m going to try and answer my own question as I was able to sort it out.
The issue was with the path argument. The path required a trailing /.

Hope this helps anyone having similar issue.

1 Like

Glad you figured that out. Indeed handling of the -p argument needs fixing.

I can offer you few hints. If you place dsm.py to /usr/bin/ (or any other folder in your $PATH), python3 shouldn’t be necessary. Once you enter the /deepstack/faces/user1 folder and omit the path argument, dsm will submit files from that folder. Finally, if you edit DEEPSTACK_ADDRESS on line 12 of dsm.py with your address, you won’t need to specify the host. Hope you find that useful.

1 Like

Great ideas! thanks. I’ll incorporate your ideas. In my scenario, the faces will be send from a different machine; so I’ll have to run registration on demand from a remote server.
appreciate your help and advice!

1 Like

so here I’m running into an issue I mentioned elsewhere. For some reason, I can only register 25 images at a time…even though, I thought my 6GB GPU and 32 GB ram would be sufficient
Now since I have 250 face images for each user, how do I get all 250 into the system considering it only accepts 25 and overrides if I add another 25.
Is there a way to make the system process a few images at a time so it can accept a large number?

Out of curiosity - why would you need so many photos? I’m impressed how accurate deepstack face recognition is with as little as 10 photos.

I have used these images before with reasonable success so I decided to try this on deepstack as well.

I think I may have identified the issue with number of images. It may have something to do with python or the deepstack manager. I opened an issue on github, you can look at your convenience

Thanks!