<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Nikita Gupta</title>
    <description>The latest articles on DEV Community by Nikita Gupta (@nikitagpt05).</description>
    <link>https://dev.to/nikitagpt05</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4017938%2F1fa055fc-20e2-40ea-9490-1918c73241a8.jpg</url>
      <title>DEV Community: Nikita Gupta</title>
      <link>https://dev.to/nikitagpt05</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nikitagpt05"/>
    <language>en</language>
    <item>
      <title>How I Built a Lightweight Local AI Assistant (Python + PyQt6 + Ollama)</title>
      <dc:creator>Nikita Gupta</dc:creator>
      <pubDate>Mon, 13 Jul 2026 19:08:52 +0000</pubDate>
      <link>https://dev.to/nikitagpt05/how-i-built-a-lightweight-local-ai-assistant-python-pyqt6-ollama-2d0j</link>
      <guid>https://dev.to/nikitagpt05/how-i-built-a-lightweight-local-ai-assistant-python-pyqt6-ollama-2d0j</guid>
      <description>&lt;p&gt;I built a fast, privacy focused desktop assistant by keeping the architecture modular and lightweight.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Tech Stack&lt;/strong&gt;&lt;br&gt;
-&amp;gt;Python &amp;amp; PyQt6 (Frontend UI and Screen Capture)&lt;br&gt;
-&amp;gt;Ollama API (Local LLM Backend)&lt;br&gt;
-&amp;gt;PyInstaller (Standalone Packaging)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Decouple the UI from Ollama?&lt;/strong&gt;&lt;br&gt;
Instead of embedding a multi-gigabyte model file directly into the application, I used a client-server split.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lightweight Executable:&lt;/strong&gt; The desktop app stays tiny because Ollama handles the heavy model inference externally in the background.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Resource Efficiency:&lt;/strong&gt; System RAM and VRAM are managed dynamically by the operating system rather than choking a single monolithic process.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solving the Windows DPI Scaling&lt;/strong&gt;&lt;br&gt;
A core feature is a custom screen-snipping tool. However, Windows DPI virtualization often desyncs logical mouse coordinates from physical screen pixels, causing cropped selections to pull from completely wrong areas.&lt;/p&gt;

&lt;p&gt;Instead of relying on flaky operating system scaling multipliers, I bypassed the issue using direct dynamic ratio calculations, Capture the raw full-screen image first.&lt;/p&gt;

&lt;p&gt;Calculate the exact mathematical ratio between the physical image size and the widget size.&lt;br&gt;
Multiply the user's selection coordinates by that ratio to crop exact physical pixels cleanly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Packaging It Up&lt;/strong&gt;&lt;br&gt;
By separating the UI and application logic from the raw model weights, compiling a clean, portable standalone .exe using PyInstaller takes seconds and avoids massive build file sizes.&lt;/p&gt;

&lt;p&gt;Keeping your AI engine external isn't just easier to build, it is a cleaner, more scalable architecture for local desktop software.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>python</category>
      <category>showdev</category>
    </item>
    <item>
      <title>Fixing My House Price Prediction App</title>
      <dc:creator>Nikita Gupta</dc:creator>
      <pubDate>Sat, 11 Jul 2026 08:33:28 +0000</pubDate>
      <link>https://dev.to/nikitagpt05/fixing-my-house-price-prediction-app-27bl</link>
      <guid>https://dev.to/nikitagpt05/fixing-my-house-price-prediction-app-27bl</guid>
      <description>&lt;p&gt;I built a web app that estimates house prices. You type in details about a house like its location, age, and number of rooms and a machine learning model calculates a price based on historical data.&lt;/p&gt;

&lt;p&gt;I ran into two main bugs that stopped the app from making predictions. Here is what happened and how I fixed the code.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The Webpage Crash
The Problem:
As soon as I started the server and opened the website, it crashed completely.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The Cause:&lt;br&gt;
The code for the webpage was designed to remember what you typed into the form so your numbers wouldn't disappear after you clicked "Predict." However, when you load the page for the very first time, you haven't typed anything yet. Because that data was missing, the webpage panicked and broke.&lt;/p&gt;

&lt;p&gt;The Fix:&lt;br&gt;
I updated the backend code to hand the webpage a blank slate (an empty set of data) when it first loads. This gave it what it needed to load normally without crashing.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The Data Mismatch
The Problem:
Once the webpage was loading properly, I tried to predict a price. It failed again, throwing errors about a "shape mismatch."&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The Cause:&lt;br&gt;
Before the machine learning model can predict a price, the input numbers have to be scaled down by a mathematical tool. When I trained this model, that tool was built to handle exactly 10 numerical inputs. But my app was trying to hand it 15 inputs all at once, including text-based choices like "Ocean Proximity." It didn't know how to handle the text, so it threw an error.&lt;/p&gt;

&lt;p&gt;The Fix:&lt;br&gt;
I split the background process into two steps. First, the code separates the 10 numbers and scales them properly. Then, it takes the text choice (like whether the house is near the ocean), translates it into a format the computer understands, and attaches it back to the numbers. This gave the model the exact 15-piece format it was expecting.&lt;/p&gt;

&lt;p&gt;Wrapping Up&lt;br&gt;
I also added a safety net to the code so that if an error like this happens again, it displays a clean message on the webpage instead of crashing the whole server. Once the predictions were calculating correctly, I saved the changes and pushed the updated code to my GitHub repository (&lt;a href="https://github.com/nikitagpt05/House-Price-Prediction" rel="noopener noreferrer"&gt;https://github.com/nikitagpt05/House-Price-Prediction&lt;/a&gt;). The app is back up and running.&lt;/p&gt;

</description>
      <category>debugging</category>
      <category>machinelearning</category>
      <category>sideprojects</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Why 97% Accuracy is a Lie: My Journey from ANN to CNN</title>
      <dc:creator>Nikita Gupta</dc:creator>
      <pubDate>Mon, 06 Jul 2026 15:34:15 +0000</pubDate>
      <link>https://dev.to/nikitagpt05/why-97-accuracy-is-a-lie-my-journey-from-ann-to-cnn-458</link>
      <guid>https://dev.to/nikitagpt05/why-97-accuracy-is-a-lie-my-journey-from-ann-to-cnn-458</guid>
      <description>&lt;p&gt;You know the feeling. Your model trains perfectly, the validation loss drops, your accuracy hits a 97.5% on the MNIST dataset and it feels like it might work fine.&lt;/p&gt;

&lt;p&gt;Then you build a real-time UI, test it yourself, and your model completely falls apart.&lt;/p&gt;

&lt;p&gt;That is exactly what happened with my latest project: a real-time handwritten digit recognizer built with PyTorch and Pygame.Here is how my "perfect" Artificial Neural Network (ANN) failed in the real world, and the engineering steps I took to fix it.&lt;/p&gt;

&lt;p&gt;The Setup&lt;br&gt;
The goal was simple. Build a black Pygame canvas where a user can draw a number (0-9) with their mouse, and have a PyTorch model predict the number the moment they release the click.&lt;/p&gt;

&lt;p&gt;I started with a standard flattened ANN. It trained. But the second I drew a number on the screen, it guessed wrong almost every time.Especially numbers like 6,7,8,9.&lt;/p&gt;

&lt;p&gt;The Problem: Domain Shift&lt;br&gt;
The issue was Domain Shift.&lt;/p&gt;

&lt;p&gt;An ANN flattens a 28x28 image into a 1D array of 784 pixels. It doesn't actually understand shapes; it just memorizes where bright pixels should be.&lt;/p&gt;

&lt;p&gt;The Dataset: The MNIST training data has perfectly centered, thin pen strokes.&lt;br&gt;
The Real World: My Pygame digital brush was thick. My hand jittered. The numbers weren't perfectly centered.&lt;/p&gt;

&lt;p&gt;Because the lines were thicker, the pixels didn't perfectly align with the ANN's expectations, and it completely failed to recognize the numbers.&lt;/p&gt;

&lt;p&gt;The Experiment: The "Model Arena"&lt;br&gt;
To fix this, I decided to upgrade to a Convolutional Neural Network (CNN), which actually looks for edges, curves, and loops using spatial filters.&lt;/p&gt;

&lt;p&gt;But I wanted to prove it was better. So, I built a Model Arena: a script that ran both the ANN and the new CNN side-by-side on the exact same drawing. I even built an Ensemble feature to average their probabilities.&lt;/p&gt;

&lt;p&gt;The result? The CNN broke too. It started guessing the number 8 for almost everything.&lt;/p&gt;

&lt;p&gt;The Fix: Normalization &amp;amp; Optimization&lt;br&gt;
It turns out, the architecture wasn't the only issue. It was the math.&lt;/p&gt;

&lt;p&gt;During training, I normalized the PyTorch dataset to a range of [-1, 1]. But my Pygame image pre-processing was scaling the pixels from [0, 1]. The CNN was receiving numbers it didn't expect, panicking, and defaulting to 8 (the mathematical center of the dataset).&lt;/p&gt;

&lt;p&gt;Once I spotted the bug, the fix was incredibly satisfying. I updated the Pygame tensor math.&lt;br&gt;
I also reduced the brush thickness to mimic a real pen, and dropped the random rotation in my training data augmentation from 15° to 5° so the shapes wouldn't distort too heavily.&lt;/p&gt;

&lt;p&gt;The Takeaway&lt;br&gt;
After those fixes, the CNN's accuracy skyrocketed. It easily recognized my live handwriting, completely outperforming the ANN (which I ended up deleting entirely).&lt;/p&gt;

&lt;p&gt;The biggest lesson? A high accuracy score on a pristine dataset means absolutely nothing if your live environment doesn't perfectly match your training environment.&lt;/p&gt;

&lt;p&gt;You can check out the final, fully optimized CNN architecture on my GitHub:&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://assets.dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/nikitagpt05" rel="noopener noreferrer"&gt;
        nikitagpt05
      &lt;/a&gt; / &lt;a href="https://github.com/nikitagpt05/Handwritten-Digit-Recognizer" rel="noopener noreferrer"&gt;
        Handwritten-Digit-Recognizer
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;Handwritten Digit Recognizer (PyTorch &amp;amp; Pygame)&lt;/h1&gt;
&lt;/div&gt;
&lt;p&gt;This is a real-time app that guesses the numbers you draw on the screen. It is built with PyTorch and Pygame. This project shows how a machine learning model can perform perfectly on standard training data but struggle with real-world inputs, and how changing the underlying architecture fixes those issues.&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;How the Project Evolved&lt;/h2&gt;
&lt;/div&gt;
&lt;p&gt;I went through three main testing phases to get the accuracy right for live, interactive drawings.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1. The First Attempt (ANN)&lt;/strong&gt;
I started by building a basic Artificial Neural Network (ANN). It scored about 97.5% accuracy on the standard MNIST dataset. But when I drew numbers with my mouse in the actual app, it failed constantly. An ANN flattens an image into a single line of pixels, so it does not actually understand shapes, edges, or curves. If I used a thick digital brush or drew the number slightly off-center…&lt;/p&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/nikitagpt05/Handwritten-Digit-Recognizer" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;Have you ever had a model fail in production after passing all your tests? Let me know in the comments!&lt;/p&gt;

</description>
      <category>deeplearning</category>
      <category>machinelearning</category>
      <category>python</category>
      <category>showdev</category>
    </item>
  </channel>
</rss>
