48 Hours, One Model, and a Lot of Confused Questions About Loss Functions
My first AI/ML hackathon experience at KU Hackfest 2025, building an X-ray disease classification model with transfer learning, DenseNet-121, and Grad-CAM visualization.
I walked into KU Hackfest 2025 as a complete beginner in AI/ML. That's not false modesty, that's just what happened. My teammates Abhyudaya Pokhrel and Unique Shrestha were carrying actual knowledge and I was mostly trying to keep up without it being too obvious.
By hour 48, I understood most of what I was looking at. That turnaround is the thing I keep thinking about.
What We Built
XR-AI is an X-ray disease classification model. You give it a chest X-ray image and it tells you whether the patient has tuberculosis, pneumonia, COVID-19, or is normal.
We hit 90% accuracy on chest X-ray datasets using transfer learning on DenseNet-121 pretrained on ImageNet. That number felt good. Getting there was less clean.
The Architecture Journey
We started with ResNet. ResNet's whole thing is residual connections, skip connections that let the gradient flow through deep networks without vanishing. Good architecture, well understood, reasonable starting point.
It didn't perform well enough. Specifically, we kept seeing poor class separation between COVID-19 and pneumonia. These two conditions can look similar on chest X-rays, and ResNet wasn't drawing the boundary clearly enough. Validation accuracy was lower than we wanted, training stability was inconsistent.
We switched to DenseNet-121.
DenseNet is different from ResNet in a specific way. Where ResNet has skip connections between individual layers, DenseNet connects every layer to every subsequent layer. Each layer receives feature maps from all preceding layers. This means features learned early in the network are directly accessible to layers deep in the network. For medical imaging, where subtle texture patterns and fine-grained features matter, this dense connectivity is genuinely useful.
We used the pretrained ImageNet weights and replaced the final classifier. The pretrained features learned from millions of ImageNet images (edges, textures, shapes) transfer reasonably well to medical imaging. You're not starting from scratch, you're adapting an already capable feature extractor.
The loss function was cross-entropy. We optimized with standard gradient descent. Proper image normalization made a noticeable difference, something I would've underestimated before.
After switching to DenseNet-121 and getting the normalization right, the improvement in validation performance was visible. The class separation between COVID-19 and pneumonia got better. Training became more stable.
Grad-CAM
We wanted to know what the model was actually looking at. This matters a lot in medical diagnostics. A model that's right for the wrong reasons is dangerous.
We integrated Grad-CAM visualization. Gradient-weighted Class Activation Mapping computes which regions of an input image most influenced the network's classification decision. You get a heatmap overlaid on the X-ray showing where the model's attention was concentrated.
For tuberculosis classifications, the heatmap highlighted regions in the upper lung lobes, which is consistent with where TB tends to manifest. For pneumonia, the focus was more diffuse and concentrated in the lower lobes. This kind of interpretability output is what makes AI systems usable in clinical contexts. You need to be able to explain and verify what the model is doing.
Watching the Grad-CAM visualization highlight the correct anatomical regions was one of the more memorable moments of the 48 hours.
The 48 Hour Reality
There's a particular quality to thinking that happens under that kind of time constraint. You become a lot less precious about your ideas. You don't argue about architecture for 45 minutes when the deadline is real.
Unique and Abhyudaya were patient in a way I'm genuinely grateful for. Every confused question I asked about loss functions, about why we use cross-entropy instead of MSE for classification, about what validation loss actually tells you, about the math behind what DenseNet is doing, got a real answer. Not a dismissive answer, not a "just trust the code" answer. An actual explanation.
By hour 24 I was following most of it. By hour 48 I was contributing to the architecture decisions, not just implementing whatever I was told. That progression in two days is something I couldn't have gotten from a course or a tutorial.
What I Took Away
The AI/ML stuff specifically: I have a much better intuition now for why architecture choices matter, why pretrained weights are valuable, why interpretability matters, and what validation metrics are actually telling you. Unique and Abhyudaya didn't just teach me the how, they taught me the why, and that's the part that sticks.
The hackathon itself was exceptionally well-run. The organizing committee at KU did something genuinely hard, creating an event where 48 hours feels productive rather than chaotic. I'd go back in a heartbeat.
Regardless of results, we learned a lot, met brilliant people, and had a great time. That's the actual measure.