# How I Built a Face Authentication App in Django: A Complete ML Learning Journey > Stop following generic “top 5 projects” lists. This is how I chose a project that matched my level, prepared before writing any code, and built a Django app you log in to with your face. - Author: Yadunandan Singh (https://yadunandan-singh.pages.dev/) - Published: 2025-12-22 · updated 2026-10-19 - URL: https://yadunandan-singh.pages.dev/blog/django-face-authentication-app/ - Topics: Machine Learning, Django, Learning - First published on Medium: https://medium.com/@yadunandan-ai-dev/how-i-built-a-face-authentication-app-in-django-a-complete-ml-learning-journey-6ea0a8bbc2ef ## Summary Yadunandan Singh describes building a Django web app that users log in to with their face, using the eigenfaces method: greyscale 100 × 100 face images are flattened, centred on the mean face and decomposed with SVD in NumPy, and logins are matched by Euclidean distance with a rejection threshold. Because one photo per user wasn't enough to train on, OpenCV generates eight synthetic variations of each sign-up photo. The post also sets out his method for learning a new framework through a project without copying AI-generated code. ## Key takeaways - Choose a project that builds on what you already know and stretches you in one new direction. - Learn the new framework from documentation and tutorials first, and write down your architecture before coding. - Tell your AI assistant to guide and review, not to write the code for you. - Eigenfaces: flatten each face, subtract the mean face, run SVD, and match logins by distance in eigenface space. - When data is scarce, generate it: one photo becomes nine with flips, lighting, noise, blur, tilt and contrast changes. --- Every developer knows the moment when a concept finally clicks and everything falls into place. For me, it came while building a face-authentication app in Django from scratch: an app you sign up to with your face and your name, and log in to with your face alone. This post is about that project, but mostly it's about the process behind it. If you're tired of generic tutorials and want to build something that actually teaches you, this is the method I'd hand you. ## Phase 0: Choose a project that fits your level Here's the uncomfortable truth: most "Top 5 Projects to Land Your Dream Job" articles never tell you what you need to know *first*. They sell the destination and skip the road. Think back to maths at school. Solving your first equation for *x* felt good because it built on things you already understood. Now imagine being handed advanced calculus without ever learning algebra. That's what happens when a beginner jumps straight into a complex project with no foundation, and the result is predictable: anxiety, burnout, and a voice in your head saying coding isn't for you. ### Let an assistant match a project to you Instead of picking from a listicle, have a real conversation with an AI assistant about what you already know and what you want to learn: ```prompt Hi, I'm an AI/ML learner looking for challenging projects that match my current skills. Here's what I know: - Programming language: [your preferred language] - Maths I'm comfortable with: [SVD, linear algebra, etc.] - What I want to learn: [Django, FastAPI, TensorFlow, etc.] Can you suggest 2–3 projects that would challenge me while building on what I already know? ``` That's how I found this project. I was comfortable with SVD and wanted to learn Django, and face authentication sat exactly where the two overlap. ## Phase 1: Preparation, the part everyone skips You've chosen a project. Now resist the urge to open your editor. ### Step 1: Learn the new technology without shortcuts For me the new technology was Django; for you it might be React or PyTorch. Either way, don't let AI write the code yet. - **Watch tutorials from people who explain the *why*,** not just the keystrokes. - **Read the official documentation.** Yes, really. - **Give it a day or two.** Rushing this stage produces shallow understanding that collapses the first time something breaks. - **Ask yourself why you're learning it.** The answer shapes how you'll use it. Once you've done the research, use AI to clear up specific doubts, not to hand you answers. ### Step 2: Write down your architecture Open a notebook, paper or digital, and answer three questions: 1. What problem am I solving? 2. Which technologies will I use, and **why**? "Because it's the thing I wanted to learn" doesn't count; give a real reason. 3. How do those pieces fit together? Here's what I wrote for Django: *"I'm using Django as my web framework because it structures code logically and has built-in security features, which matter for authentication."* This one exercise is the difference between copying code and engineering a system. ### Step 3: Give your AI chat clear boundaries Start a fresh chat for the project and set the rules before anything else: ```prompt Your role is to assist and document my learning journey. Do NOT provide me code. Instead, help me think through problems and validate my solutions. ``` That single rule changed everything for me. I learned instead of copy-pasting, and the conversation turned into a record of every decision I made. ## Phase 2: Building it This is the visible half of the work: the code that shows how you think. Write it as if someone else will read it, because one day someone will. Comment the parts that aren't obvious, check for bugs at every step, and debug properly rather than poking at things until they work. When you hit a wall, and you will, follow the same order every time: 1. **Search for it yourself** and give it a genuine 30 minutes. 2. **Try different approaches**, and note what didn't work. 3. **Then ask the AI**, explaining both the problem *and* what you tried. 4. **Learn from the answer.** Don't just paste it in. ## How the app works The recognition is linear algebra, not a pre-trained face-recognition library. It's the classic *eigenfaces* method, built on Singular Value Decomposition with NumPy. **Training.** Every stored face goes through the same preparation: OpenCV reads it in greyscale (colour is just noise for this method) and resizes it to 100 × 100 pixels. The 2D image is then flattened into one long column of 10,000 numbers, and the columns for every face are placed side by side in a matrix. I subtract the *mean face*, the average of all the columns, so what's left is how each face differs from average, and run SVD on that centred matrix: ```python mean_face = data_matrix.mean(axis=1).reshape(-1, 1) centered_matrix = data_matrix - mean_face U, S, Vt = np.linalg.svd(centered_matrix, full_matrices=False) weights = np.dot(U.T, centered_matrix) # each face's coordinates in "eigenface" space ``` The columns of `U` are the eigenfaces: the directions in which faces in the dataset vary the most. Each face is stored as its `weights`, its coordinates along those directions, which is a far more compact description than 10,000 raw pixels. **Logging in.** The photo from the webcam goes through exactly the same steps: greyscale, 100 × 100, flatten, subtract the mean face, and project onto the eigenfaces. The app then measures the Euclidean distance from that vector to every stored face. The closest one wins, but only if it is closer than a fixed threshold; otherwise the login is rejected rather than matched to the least-bad candidate. The whole thing is Dockerised, so it runs the same way on any machine. ## The problem I didn't see coming My first version trained badly. One photo per person wasn't enough. Recognising a face reliably needs that face under different lighting, at slightly different angles, from cameras of different quality. But I couldn't expect every new user to upload ten photos. So instead of asking for more data, I generated it. When you sign up, an augmenter takes your one real photo and uses **OpenCV to create eight synthetic variations**: a mirror image, a brighter and a darker copy, a grainy copy that imitates a poor camera sensor, a blurred one for out-of-focus shots, a 5° tilt each way, and a high-contrast version. Here are a few of them: ```python flip = cv2.flip(img, 1) # mirror image M_bright = np.ones(img.shape, dtype="uint8") * 40 bright = cv2.add(img, M_bright) # brighter lighting dark = cv2.subtract(img, M_bright) # darker lighting blur = cv2.GaussianBlur(img, (5, 5), 0) # out-of-focus shot M_left = cv2.getRotationMatrix2D((cols / 2, rows / 2), 5, 1) rot_left = cv2.warpAffine(img, M_left, (cols, rows)) # head tilted 5° ``` One photo becomes nine training images. That fixed the training problem, and it taught me something I've used ever since: when the data you need doesn't exist, you can often manufacture it from the data you have. The finished app does something I still find satisfying. You sign up with your face and name, and from then on you log in with your face. There's no password to guess, leak or forget. I added a notes feature for signed-in users too, which turned it into a small private notebook with your face as the key. One honest caveat: this is a learning project, not bank-grade biometrics. A simple matcher like this can be fooled by a good enough photo, which is why production systems add liveness checks on top. ## Four lessons that changed how I build **1. Confidence comes from building, not watching.** You learn a framework by fighting with it, not by watching someone else use it. **2. Architecture matters more than code.** Thinking it through before writing anything saved me from rebuilding halfway through. **3. Problems are learning opportunities in disguise.** The synthetic-image problem became the most interesting part of the whole project. **4. Document everything.** My AI chat history became a learning journal, and I still go back to it to revise concepts. ## Why this approach works None of this is about being perfect. It's about: - building real confidence through real challenges, - learning a framework deeply, not just its syntax, - ending up with a project you're genuinely proud of, and - developing problem-solving habits that carry over to every project after it. Follow this process and you won't just build a face-authentication app. You'll build the habits of someone who can learn any technology. ## What's next If this resonates, I'd love to hear about the project you're planning; tell me about it on [LinkedIn](https://www.linkedin.com/in/yadunandan-singh-ai-dev/). The code for this one is on [GitHub](https://github.com/YADUNANDAN-SINGH/django-svd-face-auth), and a star there genuinely helps me keep writing breakdowns like this. Your next great project is waiting. Stop preparing to build, and start building.