souvikg544/quickdraw-classifier
๐จ QuickDraw Classifier
A zero-shot drawing classification app using OpenAI's CLIP model. Draw anything and let AI guess what it is from 345+ categories from Google's QuickDraw dataset!
๐ Features
- Zero-shot Classification: Uses CLIP to classify drawings without training on specific drawing data
- 345+ Categories: Supports all categories from Google's QuickDraw dataset
- Interactive Drawing: Real-time drawing canvas with classification
- Beautiful UI: Modern, child-friendly interface built with Gradio
- API Ready: Includes API endpoints for external integration
๐ฏ Use Cases
- Educational Tool: Help children learn vocabulary through drawing
- Art Games: Interactive drawing games and challenges
- Accessibility: Visual learning aid for different learning styles
- Creative AI: Explore AI's understanding of visual concepts
๐ ๏ธ How It Works
- Draw: Use the interactive canvas to draw anything
- Classify: CLIP model analyzes your drawing against 345+ text prompts
- Results: Get top 5 predictions with confidence scores
- Learn: Discover new vocabulary and concepts!
๐ฆ Installation
Local Setup
# Clone the repository
git clone <your-repo-url>
cd quickdraw-classifier
# Install dependencies
pip install -r requirements.txt
# Run the app
python app.pyHugging Face Spaces Deployment
- Create a new Space on Hugging Face Spaces
- Choose "Gradio" as the SDK
- Upload these files to your Space:
app.pyrequirements.txtcategories.txtREADME.md
๐ฎ Usage
Web Interface
- Open the app in your browser
- Draw something on the canvas
- Click "Classify Drawing" or wait for auto-classification
- See the top 5 predictions with confidence scores!
API Usage
The app also provides an API endpoint for programmatic access:
import requests
import base64
# Encode your image to base64
with open("drawing.png", "rb") as f:
image_data = base64.b64encode(f.read()).decode()
# Make API request
response = requests.post(
"https://your-space-name.hf.space/api/classify",
json={"image_data": image_data, "top_k": 5}
)
results = response.json()
print(results["predictions"])๐ Supported Categories
The classifier supports 345 categories including:
Animals: cat, dog, bird, fish, elephant, giraffe, etc. Vehicles: car, airplane, bicycle, boat, truck, etc. Objects: house, tree, flower, book, chair, etc. Food: apple, banana, cake, pizza, etc. And many more!
See categories.txt for the complete list.
๐ง Technical Details
- Model: OpenAI CLIP (ViT-B/32)
- Framework: Gradio for UI, PyTorch for ML
- Classification: Zero-shot learning with text prompts
- Performance: Real-time inference on CPU/GPU
๐จ Drawing Tips
- Keep drawings simple and clear
- Focus on the main shape/form of the object
- Try common, recognizable objects first
- Experiment with different drawing styles!
๐ Deployment to Hugging Face Spaces
Step 1: Create a New Space
- Go to Hugging Face Spaces
- Fill in the details:
- Name:
quickdraw-classifier(or your preferred name) - License: MIT or Apache 2.0
- SDK: Select "Gradio"
- Hardware: CPU Basic (free tier)
Step 2: Upload Files
Upload these files to your Space:
app.py(main application)requirements.txt(dependencies)categories.txt(drawing categories)README.md(this file)
Step 3: Wait for Build
- The Space will automatically build and deploy
- Build time: ~5-10 minutes (downloading CLIP model)
- Your app will be available at:
https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME
Step 4: Test Your App
- Open the deployed URL
- Draw something on the canvas
- Verify classifications are working correctly
๐ง Configuration
Adjusting Categories
To use a custom set of categories:
- Edit
categories.txtwith your desired categories (one per line) - Or modify the
load_categories()function inapp.py
Performance Tuning
- GPU: The app will automatically use GPU if available
- Model Size: You can switch to different CLIP models in
app.py: ViT-B/32(default, balanced)ViT-B/16(more accurate, slower)ViT-L/14(most accurate, slowest)
๐ค Contributing
Contributions are welcome! Areas for improvement:
- Add more interactive features
- Implement drawing tutorials
- Add difficulty levels for children
- Improve classification accuracy
- Add multi-language support
๐ License
This project is licensed under the MIT License. See LICENSE file for details.
๐ Acknowledgments
- OpenAI CLIP for the amazing zero-shot capabilities
- Google QuickDraw for the comprehensive category list
- Gradio for the beautiful and easy-to-use interface
- Hugging Face for free hosting and deployment
Made with โค๏ธ for educational AI applications
