CoolFace
Apppublic

Suman-SG/helmet-system

sourceHugging Faceupdated 5mo agoView on Hugging Face
0likes
App README

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=false or 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)

  1. 1.Start the app locally:
powershell
.\venv\Scripts\Activate.ps1
python web_app.py
  1. 1.Start ngrok (download from https://ngrok.com):
powershell
ngrok authtoken YOUR_NGROK_TOKEN   # one-time
ngrok http 5000
  1. 1.Share the https URL printed by ngrok with your teacher.

Deploy to Fly.io (persistent public app)

  1. 1.Install flyctl: https://fly.io/docs/getting-started/installing-flyctl/
  2. 2.Create a Fly account and login from terminal: flyctl auth login
  3. 3.From repo root:
bash
flyctl launch --name helmet-system --builder dockerfile --port 8080
# Follow prompts (choose region). When asked to deploy, say yes.
  1. 1.Set environment variables (e.g. SMTP credentials) on Fly before or after deploy:
bash
flyctl secrets set ENABLE_EMAILS=false ADMIN_PASSWORD=2006 SMTP_HOST=... SMTP_USER=... SMTP_PASS=...
flyctl deploy

Notes: 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)

bash
docker build -t helmet-system:latest .
docker run -p 8080:8080 --env-file .env helmet-system:latest

Sharing 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 short deploy.sh script and prepare .env.example edits 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:

  1. 1.flyctl auth login (opens browser to authenticate)
  2. 2../deploy.sh helmet-system to build and deploy the Docker image
  3. 3.flyctl 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.py through the Dockerfile.
  • —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

bash
python web_app.py