Skip to content

GangGreenTemperTatum/toronto-visual-ai-hackathon-2025

Repository files navigation

Toronto Visual AI Hackathon 2025

https://voxel51.com/computer-vision-events/visual-ai-hackathon-march-22-2025/

Demo screenshot 1

Demo screenshot 2

Setup Instructions

Prerequisites

  • Python 3.10+
  • A trained YOLO model checkpoint

Installation

  1. Clone the repository:

    git clone https://github.com/GangGreenTemperTatum/toronto-visual-ai-hackathon-2025.git
    cd toronto-visual-ai-hackathon-2025
  2. Install dependencies:

    pip install -r requirements.txt
    pip install -e .

    For Poetry users:

    poetry install
  3. Important: Update the model path in src/toronto_visual_ai_hackathon/__init__.py:

    MODEL_PATH = "/path/to/your/model.pt"  # Change this to your model checkpoint

Running the Application

You can run the application in two ways:

  1. Using the run.py script:

    python run.py
  2. Using the package directly:

    python -m toronto_visual_ai_hackathon

The API server will start at http://localhost:5000.

Docker Deployment

  1. Build the Docker image:

    docker build -t yolo-classifier .
  2. Run the container with the models directory mounted:

    docker run -p 5000:5000 -v "$(pwd)/models:/app/models" yolo-classifier

    This ensures the model file is accessible inside the container.

Development

  • Run code formatting and linting:

    poetry run ruff check --fix .
  • Run tests:

    # Option 1: Run directly
    python tests/test_request.py --image path/to/test/image.jpg
    
    # Option 2: Make executable and run
    chmod +x tests/test_request.py
    ./tests/test_request.py --image path/to/test/image.jpg
    
    # Option 3: Run as module (if package structure is set up)
    python -m tests.test_request --image path/to/test/image.jpg

Project Structure

toronto-visual-ai-hackathon-2025/
├── data/                # Data files (not tracked by git)
├── models/              # Model checkpoints
│   └── best.pt          # Your trained YOLO model
├── notebooks/           # Jupyter notebooks for exploration
├── scripts/             # Utility scripts
├── src/                 # Source code
│   └── toronto_visual_ai_hackathon/
│       ├── __init__.py  # Main Flask application
│       └── __main__.py  # Entry point for running as module
├── tests/               # Test files
│   └── test_request.py  # Script to test the API
├── run.py               # Script to run the application
├── setup.py             # Package installation configuration
├── requirements.txt     # Dependencies
├── pyproject.toml       # Poetry configuration
├── Dockerfile           # Docker configuration
└── README.md            # This file

API Usage

The application provides a single endpoint for image classification or detection:

POST /predict

Accepts form data with an 'image' file and returns classification or detection results, depending on the model type.

Example using curl:

# Option 1: Use absolute path
curl -X POST -F "image=@/Users/path/to/image" http://localhost:5000/predict

# Option 2: Use current directory path for a file in the same directory
curl -X POST -F "image=@./test_image.jpg" http://localhost:5000/predict

# Option 3: Expand tilde manually for Bash
curl -X POST -F "image=@$HOME/path/to/image" http://localhost:5000/predict

Example response for classification models:

{
  "success": true,
  "model_type": "classify",
  "predictions": [
    {
      "class": "good_quality",
      "class_id": 0,
      "confidence": 0.95,
      "rank": 1
    },
    {
      "class": "poor_quality",
      "class_id": 1,
      "confidence": 0.05,
      "rank": 2
    }
  ]
}

Example response for detection models:

{
  "success": true,
  "model_type": "detect",
  "predictions": [
    {
      "class": "face",
      "class_id": 0,
      "confidence": 0.95,
      "bbox": [10, 20, 100, 200]
    }
  ]
}

Team Slides

  • Team: DeepFace-FiftyFive
  • Slides available here TODO

References

Dataset(s) sources