A computer vision-powered Loteria game using YOLO object detection and a modern Gradio web interface. Detect, match, and play Loteria cards in real time using your webcam or uploaded images!
- Dual Camera Matching: Detect and match Loteria cards from two camera feeds or images.
- Single Image Detection: Test card detection on any image.
- Real-Time Feedback: Visualize detected cards with red (unmatched) and green (matched) circles.
- Progress Tracking: See your matched cards count and win status.
- Modern Web UI: Clean, mobile-friendly Gradio interface with tabs and controls.
- Game Controls: Reset game, adjust detection confidence, and more.
- Public Sharing: Share your game with a public Gradio link.
You can try the AI Loteria Card Detection app instantly online via Hugging Face Spaces:
- Python 3.9+
- macOS (MPS), CUDA, or CPU
- Two webcams (for full dual camera experience)
best.ptYOLO model file (place in project root)
Install dependencies:
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txtsource venv/bin/activate
python gradio_app.py- Open the local or public URL printed in the terminal.
- Upload images or use camera snapshots to play!
source venv/bin/activate
python app.py- Uses two webcams for real-time card detection and matching.
- Press
rto reset,qto quit.
AI Loteria/
├── app.py # Classic dual-camera Loteria app
├── gradio_app.py # Gradio web interface
├── requirements.txt # Python dependencies
├── best.pt # YOLO model weights (not included)
└── README.md # Project documentation
- Model: Place your trained YOLO
best.ptfile in the project root. - Cameras: The classic app uses camera 0 and 1 by default. Adjust in
app.pyif needed. - Detection Threshold: Adjustable in the Gradio UI.
- Uses YOLO (via Ultralytics) for object detection.
- Matches detected cards between two camera feeds or images.
- Tracks matched cards and displays win status ("LOTERIA!").
- Gradio app provides a user-friendly web interface for uploads and results.
- Built with Ultralytics YOLO and Gradio
- Inspired by the classic Mexican game Lotería
- For best results, use clear, well-lit images of Loteria cards.
- You can deploy the Gradio app to Hugging Face Spaces for free hosting.
- Extend the app with sound effects, leaderboards, or more game modes!
For questions, suggestions, or collaborations, open an issue or reach out via GitHub.