CoolFace
Apppublic

souvikg544/quickdraw-classifier

sourceHugging Faceupdated 1y agoView on Hugging Face
1likes
App README

๐ŸŽจ 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

  1. 1.Draw: Use the interactive canvas to draw anything
  2. 2.Classify: CLIP model analyzes your drawing against 345+ text prompts
  3. 3.Results: Get top 5 predictions with confidence scores
  4. 4.Learn: Discover new vocabulary and concepts!

๐Ÿ“ฆ Installation

Local Setup

bash
# Clone the repository
git clone <your-repo-url>
cd quickdraw-classifier

# Install dependencies
pip install -r requirements.txt

# Run the app
python app.py

Hugging Face Spaces Deployment

  1. 1.Create a new Space on Hugging Face Spaces
  2. 2.Choose "Gradio" as the SDK
  3. 3.Upload these files to your Space:
  4. 4.app.py
  5. 5.requirements.txt
  6. 6.categories.txt
  7. 7.README.md

๐ŸŽฎ Usage

Web Interface

  1. 1.Open the app in your browser
  2. 2.Draw something on the canvas
  3. 3.Click "Classify Drawing" or wait for auto-classification
  4. 4.See the top 5 predictions with confidence scores!

API Usage

The app also provides an API endpoint for programmatic access:

python
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

  1. 1.Go to Hugging Face Spaces
  2. 2.Fill in the details:
  3. 3.Name: quickdraw-classifier (or your preferred name)
  4. 4.License: MIT or Apache 2.0
  5. 5.SDK: Select "Gradio"
  6. 6.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:

  1. 1.Edit categories.txt with your desired categories (one per line)
  2. 2.Or modify the load_categories() function in app.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


Made with โค๏ธ for educational AI applications