A web application that uses AI to determine if an image contains a Hotdog. Built with Cloudflare Pages and Hugging Face's Vision Transformer API.
Inspired by Jian Yang from Silicon Valley.
- Upload images through drag-and-drop or file selection
- Take photos directly using your device's camera
- Real-time Hotdog detection using state-of-the-art AI
- Mobile-friendly interface
- Secure API key management
- Detailed classification results
- Frontend: HTML, CSS, JavaScript
- Backend: Cloudflare Pages Functions
- AI Model: Google's Vision Transformer (ViT) via Hugging Face
- Development: Wrangler CLI
- Node.js (v16 or higher)
- Wrangler CLI (
npm install -g wrangler
) - Hugging Face API key
-
Clone the repository:
git clone https://github.com/yourusername/hotdog-detector.git cd hotdog-detector
-
Create a
.dev.vars
file in the project root:HUGGINGFACE_API_KEY=your_api_key_here
-
Install dependencies:
npm install
-
Start the development server:
wrangler pages dev ./pages --local --local-protocol https --port 8790 --ip 0.0.0.0
-
Login to Cloudflare:
wrangler login
-
Deploy to Cloudflare Pages:
wrangler pages deploy ./pages
-
Set up your API key:
wrangler pages project list # Note your project name wrangler pages secret put HUGGINGFACE_API_KEY --project-name hotdog-detector # When prompted, paste your Hugging Face API key
-
Deploy again:
wrangler pages deploy ./pages
- API keys are securely stored in environment variables
- HTTPS-only communication
- Input validation and sanitization
- Error message sanitization
{
"isHotDog": true,
"confidence": 0.9982,
"debug": {
"top3Predictions": [
"hotdog, Hotdog, red hot: 99.8%",
"French loaf: 0.1%",
"cheeseburger: 0.1%"
],
"imageSize": 36595
}
}
Here are some useful commands for managing your Cloudflare Pages project:
# Start local development server
wrangler pages dev ./pages --local --local-protocol https --port 8790 --ip 0.0.0.0
# Kill all running wrangler processes
pkill -f wrangler
# View deployment logs
wrangler pages deployment tail
# List all secrets
wrangler pages secret list --project-name hotdog-detector
# Add a secret
wrangler pages secret put HUGGINGFACE_API_KEY --project-name hotdog-detector
# Delete a secret
wrangler pages secret delete HUGGINGFACE_API_KEY --project-name hotdog-detector
# Deploy to production
wrangler pages deploy ./pages
# List all deployments
wrangler pages deployment list --project-name hotdog-detector
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Hugging Face for their amazing AI models
- Cloudflare for their serverless platform
- Google for the ViT model
- Codeium Windsurf for the excellent development environment
- Anthropic Claude for assistance in development
- All the cool people who made this project possible!# hot-dog-detector