afeld / mustachio

automatic mustachifying of any image
https://mustachify.me
MIT License
344 stars 93 forks source link

find alternative to Rekognition #48

Closed afeld closed 8 years ago

afeld commented 9 years ago

The Rekognition API (which is what mustachio uses for face detection) is shutting down on Dec 2 :cry:

https://news.ycombinator.com/item?id=10497743

Need to find an alternative API, or finally move to local detection.

/cc https://github.com/shiffman/Rekognition-for-Processing/issues/16

afeld commented 8 years ago
josephearl commented 8 years ago

Any of these http://blog.mashape.com/list-of-10-face-detection-recognition-apis/ usable for Mustachio?

afeld commented 8 years ago

That's a relatively old article, and these companies seem to go out of business pretty quickly. I would love to figure out local detection if we can.

brodock commented 8 years ago

You can probably use flandmark (face landmark detection algorithm). There is a ruby-binding gem for that library: https://github.com/ssowonny/ultra-face Original article/description: http://cmp.felk.cvut.cz/~uricamic/flandmark/ Original C++ code: https://github.com/biometrics/flandmark/tree/master/libflandmark

Note: it's GPLv3 code

afeld commented 8 years ago

Would love some help experimenting with the different options!

afeld commented 8 years ago

Just got an email from someone interested in helping out – pasting here to keep all of the information in one place.

It looks like in mustachio.rb there is some hints at the concept of modular-ability by defining @@face_detection_proc (line 39, 64) and also the face_span function thats commented out (line 83).

Anyways, any advice you have would be awesome. Im going to try to use face (https://github.com/rociiu/face) but we'll see if it can really do what needs to be done.

Response

in mustachio.rb there is some hints at the concept of modular-ability by defining @@face_detection_proc (line 39, 64)

Haven't looked at this code in a while...I think that can be removed. https://github.com/afeld/mustachio/issues/50

the face_span function thats commented out (line 83)

Hmm, not sure how that got left that way...I wouldn't worry about it for now.

Anyways, any advice you have would be awesome.

In short, the task here is to replace (the logic in) the Mustachio::Rekognition class. The trick is getting .face_detection to return the data in the same format (though I'm not opposed to other parts of the codebase changing to make the task easier).

Im going to try to use face (https://github.com/rociiu/face)

That's a wrapper for the face.com API, which is originally what mustachio was using. Unfortunately it shut down a few years ago :crying_cat_face:

brandonkirchner commented 8 years ago

That's a wrapper for the face.com API, which is originally what mustachio was using. Unfortunately it shut down a few years ago

@afeld about 10 minutes after i sent that email i realized that. I've done the "fun" part of demolishing all the rekognition code out of my fork. I'm currently looking at using ruby-opencv, but its non-trivial to get it configured correctly.

how / where is this application deployed? will it be possible to install / configure opencv in that environment?

afeld commented 8 years ago

It's deployed to Heroku. I wouldn't be opposed to Docker-izing the thing if installation of dependencies becomes a headache, which I imagine would be the case for something like OpenCV, which theoretically Heroku supports (though I haven't really tried it). We can cross that bridge when we come to it, I guess.

brodock commented 8 years ago

We can just use https://github.com/ddollar/heroku-buildpack-apt and include opencv packages there. Docker is not required for that.

brandonkirchner commented 8 years ago

One of the benefits of using docker is that it (could, maybe, sometimes) simplify development (not having to set up / install opencv dependencies, etc). But the buildpack is a simpler, lower overhead solution.

afeld commented 8 years ago

Yep yep. Let's figure out what works for detection first, then worry about how to make it easiest to set up / deploy.

brandonkirchner commented 8 years ago

I've been playing around with ruby-opencv all day and I'm not able to use any of the frontalface cascades, and having a hard time getting consistent correct results with the mcs_mouth cascade. I seem to get pretty consistent and correct results with the mcs_nose cascade.

I'm wondering if we could change the algorithm to place the top-center of the stache right under the bottom-center of the nose. it looks like current implementation uses fixed-width mustaches, is that correct? (factories.rb:43)

in any case, I'm going to look more at implementing this without mouth coordinates tomorrow.

afeld commented 8 years ago

All of the positioning logic is here:

https://github.com/afeld/mustachio/blob/242b93a0b06c00df4cb76d5693394f8fd54eca19/lib/mustachio/factories.rb#L30-L50

The mustache image gets scaled to be the height of the nose to the middle of the mouth (plus any mouth_overlap), and is then positioned between the nose and mouth (plus any vert_offset).

mustachify_algorithm

Some of those variables could probably have better names...

afeld commented 8 years ago

If Rekognition.face_detect returns the data in the same format, though, none of that positioning logic should need to change.

chalda commented 8 years ago

just to chime in here. I am looking over your code and sort of lost how to plug in a custom face recognition alternatives. I'd love to add even local face recognition.

Can you point me at fork or particular point in the code where i can hook in something like opencv? I can see that this is sort of a painful issue for you guys.

Of note, it would be a nice crosssection of mustachio and this project: https://github.com/ethanal/mustachify

overall logic is not too different from what you already have! search for the query, download image, do some local processing, upload image, return URL.

afeld commented 8 years ago

I'd love to add even local face recognition

:+1:

particular point in the code where i can hook in something like opencv

See my comment above—that's all I've got. Maybe @brandonkirchner has some actual code for integrating with OpenCV?

it would be a nice crosssection of mustachio and this project: https://github.com/ethanal/mustachify

Yep! Could definitely look into how they are Based on the README, sounds like the main differences are that mustachio:

dijonkitchen commented 8 years ago

Ideas: https://cloud.google.com/vision/ https://developers.google.com/vision/

afeld commented 8 years ago

Google Cloud Vision API seems promising! Wrote up a script to test it out:

https://gist.github.com/afeld/655e6e02bf085feb02193f468516fca5

Local face detection should still be faster, but this would work.

crccheck commented 7 years ago

MS Face API give 30K faces per month for free too: https://www.microsoft.com/cognitive-services/en-us/face-api

I haven't personally tried it, but it looks like they give more landmarks than Google too.