🧬 PROJECT HELIX - The Journey


💡 What Inspired Me

I sat down wanting to continue training a pre-trained model from HuggingFace for computer vision. The datasets were massive, and my HP EliteBook Folio 9470m was struggling hard—RAM maxing out, fans screaming, processes crashing.

So I went back to the drawing board. Started sketching it out. At first, I thought it wasn't going to be possible. I did weeks of research with GPT-4o and Claude Sonnet 4.5, trying to find a way to make this work on constrained hardware.

Then it clicked: Why store all the pixels when you can store the instructions to regenerate them?

I also discovered that many users in the SaaS space and data-related sectors (AI training, computer vision pipelines) had similar problems deep down—massive storage costs, slow data loading, memory constraints. So I decided to keep building it, at least just for fun.

And here we are.


🛠️ How I Built the Project

Phase 1: Foundation (Core Extraction)

The first step was building the semantic extraction pipeline:

  • Face detection using OpenCV's Haar cascades
  • Identity anchor extraction (eyes, nose, mouth, face regions)
  • Blueprint schema design with constraints and mesh geometry
  • AES-256-GCM encryption for secure storage

Phase 2: Cross-Platform Compatibility (HLX v2)

Made HELIX files universally viewable:

  • Innovation: HLX v2 files are valid JPEGs that any app can display
  • Embedded encrypted blueprint data after the JPEG EOI marker
  • Any photo viewer sees the preview; only HELIX unlocks full reconstruction

Phase 3: Gemini Integration

Integrated Google's Gemini 3 as the "brain" of HELIX:

  • Gemini 3 Pro for intelligent anchor extraction (vs. basic OpenCV)
  • Semantic understanding of scenes, aura, and color palettes
  • AI-powered materialization for resolution upscaling

Phase 4: Memory Optimization & 8K Support

This is where things got real:

Initial: Load 8K image → Crash (Out of Memory)
Attempt 1: Resize to 4096px → Lost quality
Attempt 2: PIL dimension reading only → Still crashed on processing
Final: pyvips disk-streaming → Process without loading full image to RAM ✅

Phase 5: Deployment & Polish

  • Published SDK to PyPI (pip install helix-sdk)
  • Next.js frontend with glassmorphic UI
  • Backend deployed to Railway/Render free tier
  • Keep-alive systems to prevent cold starts

📚 What I Learnt

Technical Learnings

  1. Sequential streams are "consume-once"
    pyvips with access='sequential' can only read the image once. If you need to process it twice (e.g., resize for detection AND save full-res), you must re-open the file.

  2. Environment variables in Docker need shell expansion
    uvicorn --port ${PORT:-8001} doesn't work directly in Docker CMD. You need sh -c 'uvicorn --port ${PORT:-8001}' for shell variable expansion.

  3. Free tier hosting has hidden constraints

    • Render free tier: 512MB RAM, 15-min sleep timeout
    • Railway: Different package names (Debian trixie vs older)
    • Both: Ephemeral filesystems (need backup strategies)
  4. Semantic compression is real
    You can achieve 2-10x compression by storing what matters (identity anchors, geometric constraints) instead of raw pixels.

  5. Cross-platform file formats are possible
    By appending data after JPEG EOI marker, you create hybrid files that work everywhere but unlock extra features for aware apps.

Soft Learnings

  • Research deeply before declaring something "impossible"
  • AI coding assistants are powerful collaborators, but you still need to understand the problem
  • Building for constraints (512MB RAM, free tier) forces creative solutions

⚔️ Challenges I Faced (And How I Solved Them)

Challenge 1: Out of Memory on 8K Images

Problem: Processing 7680×4320 images crashed on 512MB RAM
Attempt 1: Resize to 4096px before processing → Lost full resolution
Attempt 2: Use PIL to read dimensions only → Still crashed during face detection
Solution: Implemented pyvips disk-streaming. The image never fully loads into RAM—it streams from disk through the processing pipeline.

Commits:

  • 5e34819 Fix: Memory optimization for Railway 512MB
  • 7c5a40b Feat: Disk-streaming for 8K images using pyvips
  • 21bda6a Fix pyvips out-of-order read in 8K pipeline

Challenge 2: VipsJpeg "Out of Order Read" Error

Problem: After implementing disk-streaming, got cryptic error during encoding
Root Cause: Sequential access in pyvips consumes the stream. Tried to read same handle twice.
Solution: Re-open the image file for the second operation.

Commit: 21bda6a Fix pyvips out-of-order read in 8K pipeline


Challenge 3: Railway Deployment PORT Not Expanding

Problem: uvicorn --port ${PORT:-8001} treated as literal string, not variable
Root Cause: Docker CMD doesn't invoke a shell by default
Solution: Wrap command in sh -c '...' for proper shell expansion

Commits:

  • c4dcfd7 fix: use shell expansion in Procfile for PORT
  • 1dcb2ba Fix railway start command with shell expansion

Challenge 4: Dockerfile Package Names Changed

Problem: apt-get install libvips failed on Railway's Debian trixie base
Root Cause: Package renamed from libvips-tools to libvips42 in newer Debian
Solution: Updated Dockerfile with correct package names

Commit: 893e4d4 Fix: Dockerfile for Railway - updated package names


Challenge 5: Authentication 401 Errors

Problem: Users logged in successfully locally but got 401 on deployed version
Root Cause: Database path wasn't persisting between container restarts
Solution: Implemented JSON backup system + proper DATABASE_PATH configuration

Commit: 95dbf37 fix: 8K memory safety (pyvips) & auth persistence


Challenge 6: API URL Double Slash Bug

Problem: Frontend calling https://api.example.com//api/login (double slash)
Root Cause: Base URL had trailing slash + endpoint had leading slash
Solution: Strip trailing slashes from API URL configuration

Commit: 946f3d9 Fix: strip trailing slash from API URL


Challenge 7: Gemini Rate Limits & Fallbacks

Problem: Gemini 3 Pro sometimes returns 429 (quota exceeded) or fails
Solution: Implemented model cascade with automatic failover:

  1. Gemini 3 Pro Preview (primary)
  2. Imagen 3 (high-fidelity fallback)
  3. Gemini 2.0 Flash (speed fallback)
  4. Deterministic baseline (always works)

Commits:

  • b83c6c1 Update model cascade: Remove OpenRouter, add stealth fallbacks
  • 33e7b17 Remove enhancement layers, revert to high fidelity baseline

📊 Commit Timeline Summary

Phase Key Commits Description
Foundation b9541e5 HELIX v1.0 - Core build with extraction pipeline
SDK 28a2782, fff54ab PyPI package + documentation
Cross-Platform 57a2c3f HLX v2 format (JPEG-compatible)
AI Integration c6fb15a, cd7f9aa Gemini model cascade
Memory Optimization 7c5a40b, 21bda6a pyvips disk-streaming for 8K
Deployment ccc2276, 1dcb2ba Render/Railway compatibility

🚀 The Result

HELIX now:

  • ✅ Processes 8K images on 512MB RAM
  • ✅ Achieves 2-10x semantic compression
  • ✅ Works cross-platform (HLX files viewable as JPEGs)
  • ✅ Integrates Gemini 3 for intelligent extraction & materialization
  • ✅ Ships as a pip-installable SDK
  • ✅ Deploys on free tier hosting

The mantra: Store the instructions for regeneration, not the pixels themselves.


Built with determination, a lot of debugging, and the belief that "impossible" just means "not yet figured out."

Built With

Share this project:

Updates