Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: Browser based deep fakes in pure JavaScript (omg.lol)
117 points by huras on Dec 31, 2021 | hide | past | favorite | 21 comments



So seemingly this is a Tensorflow model compiled as WASM? Pretty cool no matter how it's accomplished but I'll echo the other commenter that a more detailed writeup would be nice especially for the HN folks!


Yeah, really. What's with the claim about "pure JS"...?

      async function setup() {
        await faceapi.tf.setWasmPaths('https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm@3.12.0/dist/');
        await faceapi.tf.setBackend('wasm');
        await faceapi.tf.enableProdMode();
        await faceapi.tf.ENV.set('DEBUG', false);
        await faceapi.tf.ready();

        const model = await set_and_get_filter('gigachad');
        await faceapi.nets.tinyFaceDetector.load('./faceapi-models');
      };


There's not a whole lot of difference between minified JS and WASM anyway.


How.. Wai... What do you mean? There is a lot of difference! That's like saying Java bytecode is the same as Java source code, not nearly the same thing! Things that can run JS can run minified JS but doesn't mean it can run WASM, and just because something can run WASM doesn't mean it can run JS.


If something can run wasm, it can run JS by running an interpreter compiled to wasm.

Conversely, wasm can be transpiled to JS, and asm.js is also a thing.


Sure but a from scratch implementation in pure JS instead of a wasm compile would be cool.


Seems it's just the HN title that is incorrect, the website itself makes no claim about being vanilla JS/"pure" JS. Maybe mods/dang can correct it to remove the "Pure JavaScript" part?


I think a better description would be "pure client-side"


Apologies for the re-post. I realized since I'm the author this would make more sense as a Show HN than as a anonymous link (and it was too late to edit).


seems broken? i see CORS problems with loading model.json in both Chrome and Safari.


Hm, it definitely works for me (on a re-try) and most people according to analytics don't get an error message (as well as friends who've tried it). I do load the models from a different domain (via cloudfront, though I've set up CORS there). Maybe you have some extra strict setting activated? (Ps big fan paul! fanboying from the interaction)


I used a photo of my face and the results were pretty nightmarish with some of those faces. Makes me realise snapchat-like filters on social media apps are heavily designed to be as non-disturbing/threatening as possible, because deep fakes IMO tend to be disturbing more often than not


I broke it with this: https://www.pinterest.com/pin/383861568216457362/

Neat project!


This is wonderful. There's so much potential for doing ML in the browser and this makes for a great demonstration.


Neat. What model does it use? How did you go about getting inference running quickly enough in WASM?


FYI anyone looking for an easy DIY deepfake program for fun can try First-Order-Wrapper:

https://github.com/dunnousername/yanderifier

It’s quick and dirty but they come out pretty decent and don’t take too terribly long if you have a dedicated GPU/card.

Example: https://youtu.be/32X3LOUorLI


what is the purpose of this site?


Mostly a tech demo of something that hasn't really been shown to be possible until now. We've seen lots of GPU heavy models that achieve similar things like this (often requiring VRAM outside what most consumer GPUs can usually handle), but here I show (after a lot of effort on my part) that cool effects like that are in fact possible to make run decently fast even on mobile web. Hopefully it's inspirational and might nudge some people to try making more cool creative tfjs models that can run on the device (preserving privacy and activating a new layer of fun that's only possible once you get these things real time) rather than hidden behind an API. (I thought that would happen 5 years ago but the phase shift still hasn't really happened for some reason.)


It sounds like potentially a very decent feat. Some writeup would be nice, even in a comment. How does it work? What problems did you encounter? etc.


But this is just this just doing a forward evaluation of a NN, not training, right?

Ironically, I remember the first Javascript demos (from 1996) I ever saw was a neural net demo: https://web.archive.org/web/19961226105339/http://www.ozemai...

Probably could be ported easily to ES 2.0 which still runs in most recent browsers. Just like in the late 80s, there was a hype cycle around neural nets in the late 90s.


> But this is just this just doing a forward evaluation of a NN, not training, right?

It's been my experience that disabling automatic differentiation for a neural net still uses 50-100% as much memory in the forward pass/inference.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: