Suman-SG/helmet-system
Helmet Violation System — Deploy & Share
This repo runs the Helmet Violation System Flask app (web_app.py) with full user/admin pages, helmet detection, plate OCR, evidence capture, and optional invoice emails.
Two quick ways to share the app publicly:
1) Quick demo (requires your laptop to stay running) — expose localhost via a tunnel (ngrok / localtunnel / cloudflared). 2) Persistent public URL (recommended) — deploy the app to a small container host (Fly.io / Railway / Render). This will run even after you close your laptop.
Important notes before sharing
- Disable or test email sending to avoid spamming recipients. Set
ENABLE_EMAILS=falseor use a safe test recipient in.env. - Model weights and PyTorch are large. Free hosts may be limited in memory and CPU. For demos, prefer CPU-only or a smaller model.
Quick demo with ngrok (fast, laptop must run)
- Start the app locally:
.\venv\Scripts\Activate.ps1
python web_app.py- Start ngrok (download from https://ngrok.com):
ngrok authtoken YOUR_NGROK_TOKEN # one-time
ngrok http 5000- Share the https URL printed by ngrok with your teacher.
Deploy to Fly.io (persistent public app)
- Install
flyctl: https://fly.io/docs/getting-started/installing-flyctl/ - Create a Fly account and login from terminal:
flyctl auth login - From repo root:
flyctl launch --name helmet-system --builder dockerfile --port 8080
# Follow prompts (choose region). When asked to deploy, say yes.- Set environment variables (e.g. SMTP credentials) on Fly before or after deploy:
flyctl secrets set ENABLE_EMAILS=false ADMIN_PASSWORD=2006 SMTP_HOST=... SMTP_USER=... SMTP_PASS=...
flyctl deployNotes: Fly gives free resources but heavy models may need more memory or paid plan. If deployment fails due to build timeouts or memory, consider either using a smaller model for demo or hosting the model in a separate service.
Alternative hosts
- Railway / Render: connect GitHub repo and deploy a Docker service. They have free tiers/credits but limits.
- Hugging Face Spaces: great for Gradio/Streamlit but not ideal for custom Flask apps with heavy PyTorch models.
Docker (build & run locally or push to a registry)
docker build -t helmet-system:latest .
docker run -p 8080:8080 --env-file .env helmet-system:latestSharing with your teacher
- If using ngrok/localtunnel: send the https URL.
- If using Fly/Railway/Render: send the service URL (they provide a stable https domain).
Want me to do it for you?
- I can add a minimal
fly.toml(Fly) and a shortdeploy.shscript and prepare.env.exampleedits to make it easy to deploy. I can also create a GitHub-friendly small-weights fallback config for quick demos.
I added fly.toml and deploy.sh to this repo to simplify Fly.io deploys. To have me deploy from this machine now, confirm you're ready and that flyctl is installed and you are comfortable providing any required secrets interactively.
Interactive deploy steps I'll run if you confirm:
flyctl auth login(opens browser to authenticate)./deploy.sh helmet-systemto build and deploy the Docker imageflyctl secrets set ...to push SMTP/ADMIN secrets from your.env(I will prompt before sending any secrets)
If you'd like me to proceed now, reply "deploy now" and I will start. If you prefer to run these yourself, run the deploy.sh steps above.
No-card persistent hosting option
- Use Hugging Face Spaces with Docker so it launches
web_app.pythrough theDockerfile. - Copy this repo to GitHub, then create a new Space from the repository and let Spaces build the Docker image.
- If the full model is too heavy, either use lighter weights for the Space or host the weights externally and download them on startup.
Typical Spaces startup command
python web_app.py