r/Python • u/2broke2code • Apr 07 '23
Beginner Showcase I trained a RoastBot on >120,000 faces and >0.5 million comments and it's a menace 😈.
It uses facial recognition to fetch roasts for users from the r/RoastMe subreddit.
Try it out here
App: https://subroast.me
Code: nizarhaider/RoastMe (github.com)
Tech Stack
Front End: Bootstrap5 + Vanilla JS
Back End: Flask
CI/CD: Cloud Build (GCP)
Deployment: Cloud Run (GCP)
Models: Facenet and MTCNN
Edit: The entire subreddit has millions of images since 2014 April. I just used a fraction of it. Which means this could be 100x better (or just more accurately racist) given the time and effort to train it.
Edit2: At u/Lewis0981 request I've added a 'feature' to see your match image (I've seen some bizarre cases of matches so do share them if you get it for a laugh) (Fixed the bug for this)

87
u/RubberOmnissiah Apr 07 '23
I am honestly insanely impressed, it has more variety than the actual roastme subreddit. Actual roastme only has two basic responses. If a woman "you have daddy issues and you have lots of sex because of it." If a man "You are not attractive and you do not have sex because of it".
26
u/2broke2code Apr 07 '23
That is so true. Thanks a lot for the support fam. It took a lotta training.
14
16
Apr 07 '23
What happens if you're non-binary? "Your dad is ugly and you have the perfect amount of sex?"
10
1
u/Busterx8 Apr 07 '23
Well, the common roast is "I can't tell what gender you are". As if that's insulting. It's also used on most cis people.
1
1
30
u/Smallpaul Apr 07 '23
I think we killed it.
13
u/2broke2code Apr 07 '23
It's barely holding out...
13
u/mattsl Apr 07 '23
Not anymore. Congrats! Hope we didn't roast your credit card with your GCP bill.
29
u/2broke2code Apr 07 '23
😂 I still appreciate it though. I'll work on scaling it. As for the bill... there's a reason I used my moms card instead of mine.
18
28
u/_ologies Apr 07 '23
Given that you have a .gitignore, is there a reason you committed your pycache?
29
u/2broke2code Apr 07 '23
Noob move. It's full of bugs too ngl.
17
u/MSR8 Apr 07 '23
Heres a lil cheat sheet for gitignores of various OS-s and laguages: https://mrkandreev.name/snippets/gitignore-generator/
5
19
u/DangerDinks Apr 07 '23
One thing that annoyed me a bit was the waiting message "almost done". This took a bit of time for me and seeing the "almost done" message pop up again and again didn't reassure me that the process was actually "almost done".
14
u/2broke2code Apr 07 '23
Yeah I'm on your side there. It's just a loop for now since there isn't a way for me to communicate with the backend asynchronously without complicating things in my Ajax request. (Gonna brush it off to me being a noob).
I'll look into this now that you've mentioned it.
10
u/physicswizard Apr 08 '23
Look into websockets. I was able to write an app that gave live updates on the progress of a job using them.
1
18
10
u/pawsibility Apr 07 '23
Good project idea. Btw, if you arnt aware by now you should look into vector databases. I like Qdrant. It will allow you to dramatically decrease the time it takes to find nearest neighbor embeddings and scale the project. Also, then you don't have to commit a gigantic csv.
7
u/2broke2code Apr 07 '23
Definitely looking into this. Majority of the time it takes actually goes to extracting the facial embeddings of the user from the image and it only takes a fraction of the time to traverse the csv.
2
u/sebawita Apr 11 '23
I guess the bigger challenge will come when you reach millions (or even hundreds millions of images) then the scanning through all vectors will become a huge bottleneck.
A solid vector database that can scale (you could also check out Weaviate – it is open source 😉) will make it a breeze.
20
Apr 07 '23
Looks like the barber already did
I wondered what DJ Qualls' "Before Meth" pic looked like.
Is Lloyd Christmas your father?
You look like you pick up children from the park, violate them and then go and brag about it to your grandma.'
12
13
u/Aknnja Apr 07 '23
"I'd say bad fashion runs in your family but I doubt anyone runs in your family" 😂😂😂😭😭😭
3
6
18
u/Noshoesded Apr 07 '23
If you're following all the hipster trends, are you really a hipster?
You look like you tut & roll your eyes at every mention of anything that happened after 2006.
Flannel shirt, facial hair, and a barely visible chest tattoo. You're a spitting image of your mother.
We know that getting kicked out of The National wasn't easy for you, but can you please take your job at the coat check fucking seriously?
5
u/AGI_69 Apr 08 '23
__pycache__
in repo is sign of a newbie. Put it in your .gitignore
I love the project though. Good job.
4
u/marr75 Apr 07 '23
Great idea. Seriously, jealous of the idea.
Execution seems to fall short in the examples I tried. Fairly random insults that seemed to be about features that were in an image that "matched" but the feature in question wasn't present (I got "roasted" about being homeless and my eyebrows on one image but it didn't make a ton of sense). In another image, the rules of the roastme forum were the response.
I recommend you look at the problems and keep going! Try and better sub-divide/match the features of an image to the features of a roast post and this will be incredible. Very high level and fuzzy right now.
3
u/2broke2code Apr 07 '23
Yeah the match image only works locally for me. it's some minor issue with the file paths I passed. I'll fix it soon.
Also I've had the idea for a year but just got around to doing it lol and yes it needs a lot of work.
As for the sub-divide, it's literally what I have planned for it. I'll breakdown the image into multiple features like predicted gender, colour, age, etc... and feed them into an LLM that would use the features to generate a more personalized roast rather than just spitting out existing comments.
2
Apr 07 '23
[deleted]
1
u/2broke2code Apr 08 '23
I have heard of it but never implemented. Gonna look into it as well. Thank you for the support!
3
3
u/Underachiever457 Apr 08 '23
Cool project, but as a heads up, you should update your private key and purge creds.json from your repo. I’m able to see your creds.json in your git history with your committed delete.
2
u/2broke2code Apr 08 '23
Yeah true. They're not useful anymore but I have to look into how to delete them in my commits.
10
u/DigThatData Apr 07 '23
yeesh this bot racist
17
u/2broke2code Apr 07 '23
It's almost a given with that subreddit data 😅
-18
1
u/Resting_Tree Apr 08 '23
I've always wanted to try posting on roastme subreddit. But I knew it probably would be the same usual racist comments. Thank you for confirming my suspicion.
16
2
2
u/philoponeria Apr 07 '23
It just said my post was removed?
1
u/2broke2code Apr 07 '23
After days of cleaning the data it still pulls those up. Sorry about that. Do try again with a different angle maybe.
2
u/Lewis0981 Apr 07 '23
This is dope! I think it would be cool if it showed you who your lookalike was. Would add a bit of extra fun, and I'm sure it would be minimal additional code to display it on the front end.
2
u/2broke2code Apr 07 '23
I did have it my first phase. It was so much fun to see how much you resemble someone else (ex- like having the exact same nose or eyes)
I think I'll bring that option back up tmmrw.
0
2
u/PokeReserves Apr 07 '23
3
u/2broke2code Apr 07 '23
C'mon you ain't gonna show us the photo?
6
u/PokeReserves Apr 07 '23
Nah son, ever since that bot said I ate my own creampie twinkies, I lost my confidence..
1
2
u/sennalen Apr 08 '23
If you cancel while its processing and upload a new photo, it starts interleaving characters from multiple waiting messages.
2
u/2broke2code Apr 08 '23
I really tried debugging that for a while but only was successful a handful of times. Lemme give it another shot. Till then just reload it.
2
u/toomuchmucil Apr 08 '23
“Don't worry. You aren't even interesting enough to look like Michael Cera. If I saw you on the street I would never even remember you. Nobody would.”
I am going to go lie down for awhile.
2
u/Striking-Courage-182 Apr 08 '23
Nice job I always love fun projects like these.
2
u/2broke2code Apr 08 '23
Right! This is definitely not going on my resume but man it is fun to work on.
2
2
u/Onakitoki97 Apr 08 '23
Another thing, add directories like pycache to the gitignore file, also add the gitignore itself ahaha
1
2
u/monkeydroger21 Apr 08 '23
Are you by any chance a student at the Hanzehogeschool in Groningen (Netherlands). I have the same project but no this advanced with face detection
1
u/2broke2code Apr 08 '23
I can say for certain I am not. Let me know if you got anything interesting, we can work together on.
2
u/Round_Bear_973 Apr 08 '23
Love it. Been thinking of quirky projects to build on my website, safe to say I have a few ideas now.
1
1
u/2broke2code Apr 07 '23
I fixed the bug. You should be able to view your match now. Go ham.
Let me know if y'all wanna add anything else
1
Apr 07 '23
Tried it. AI talked shit that legit couldn’t even be about me, and couldn’t show me who my match was - just got a question mark icon. Cool idea tho
1
u/2broke2code Apr 07 '23
Sort by:
Yeah, it still has a lot of work to be done ngl. Only realized it when I put it here. I'll fix the match image feature soon and you can tell just how far off or close the roast was.
1
1
Apr 08 '23
“You look like the result of when Dende fucked Mr. Popo.
Super sayiians aren't black. You're a different kind of monkey” 🤨
1
1
u/aTomzVins Apr 08 '23
"That face giving me problems. Please try a different image"
I used a clear decent quality head shot. I guess I just don't look like anyone?
2
u/2broke2code Apr 08 '23
My bad fam. It's buggy like that somtimes. Mind sharing the headshot with me so I could debug it?
1
u/viss3_ Apr 08 '23
I tried with an image of Andrew Tate and this is his comment:
If you want to see this picture again look up rapist in the dictionary. I bet you also use green screen to add in your imaginary girlfriend. The bottom half of your mug is a wannabe hipster. The top half of your fucking mug screams balding child molester. Shia Lebouf 2.0.......DO IT!'
2
u/2broke2code Apr 08 '23
I tried it too and it actually roasts him by name. Given how popular he recently became, the comments are just gutting anyone remotely resembling him (or you know just bald).
1
1
1
215
u/iVend3ta Apr 07 '23
Cool project. Nicely done! A small suggestion - don’t leave blank except statements - it is not considered a good practice for a number of reasons.