Skip to main content

AI-powered clothing image classification tool.

Project description

OutfitAI

Description

AI-powered clothing image classification tool. The tool analyzes clothing images and outputs color, category, dress code, and seasonal information in JSON format.

Features

  • Multiple AI provider support (OpenAI and Gemini)
  • Image classification (color, category, dress code, season)
  • Both CLI and library usage support
  • Single image and batch processing support
  • Performance optimization through async processing
  • Flexible configuration management
  • Support for both local file and image URL

Classification Criteria

  • Color: white, gray, black, red, orange, yellow, green, blue, indigo, purple, other
  • Category: tops, bottoms, outerwear, dresses, shoes, bags, hats, accessories, other
  • Dress code: casual wear, business attire, campus style, date night outfit, travel wear, wedding attire, loungewear, resort wear, other
  • Season: spring, summer, fall, winter

Requirements

  • Python 3.9+

Installation

1. Install from PyPI (Recommended)

pip install outfitai

2. Install from source

# Clone repository
git clone https://github.com/23tae/outfitai.git
cd outfitai

# Install package
pip install -e .

Usage

  • Set up API credentials before use (see Configuration)
  • Supported image file formats:
    • OpenAI: PNG(.png), JPEG(.jpeg, .jpg), WEBP(.webp) and non-animated GIF(.gif)
    • Gemini: PNG(.png), JPEG(.jpeg, .jpg), WEBP(.webp)

1. As a Library

You can use it in your Python code:

from outfitai import Settings, ClassifierFactory
import asyncio

# Method 1: Use environment variables or .env file
classifier = ClassifierFactory.create_classifier()

# Method 2: Direct settings
settings = Settings(
    OUTFITAI_PROVIDER="openai",
    OPENAI_API_KEY="your-api-key"
)

classifier = ClassifierFactory.create_classifier(settings)

# Process single image
async def process_single():
    # Method 1: From local file
    result = await classifier.classify_single("path/to/image.jpg")
    print(result)
    
    # Method 2: From URL
    result = await classifier.classify_single("https://example.com/image.jpg")
    print(result)

asyncio.run(process_single())

# Process multiple images
async def process_batch():
    # From directory
    results = await classifier.classify_batch("path/to/images/")
    # Or from list of files
    results = await classifier.classify_batch(["image1.jpg", "image2.jpg"])
    print(results)

asyncio.run(process_batch())

2. Command Line Interface

Process a single image and display results:

outfitai path/to/image.jpg

Save results to file:

outfitai path/to/image.jpg --output result.json

Process all images in a directory:

outfitai path/to/images/ --batch

CLI Options

Required:
  IMAGE_PATH          Path to image file/directory or image URL

Optional:
  --batch, -b         Process all images in directory
  --output, -o FILE   Save results to JSON file

Example Output

[
  {
    "image_path": "path/to/image.jpg",
    "color": "indigo",
    "category": "outerwear",
    "dress_code": "casual wear",
    "season": ["spring", "fall"]
  }
]

Configuration

Setting API Credentials

  1. Environment variables (Recommended):

    # For OpenAI
    export OUTFITAI_PROVIDER=openai
    export OPENAI_API_KEY=your-api-key
    
    # For Gemini
    export OUTFITAI_PROVIDER=gemini
    export GEMINI_API_KEY=your-api-key
    
  2. In .bashrc or .zshrc:

    # For OpenAI
    echo 'export OUTFITAI_PROVIDER=openai' >> ~/.bashrc
    echo 'export OPENAI_API_KEY=your-api-key' >> ~/.bashrc
    
    # For Gemini
    echo 'export OUTFITAI_PROVIDER=gemini' >> ~/.bashrc
    echo 'export GEMINI_API_KEY=your-api-key' >> ~/.bashrc
    
  3. .env file in project root:

    # For OpenAI
    OUTFITAI_PROVIDER=openai
    OPENAI_API_KEY=your_api_key
    
    # For Gemini
    OUTFITAI_PROVIDER=gemini
    GEMINI_API_KEY=your_api_key
    
  4. Direct in code:

    # For OpenAI
    settings = Settings(
        OUTFITAI_PROVIDER="openai",
        OPENAI_API_KEY="your-api-key"
    )
    classifier = ClassifierFactory.create_classifier(settings)
    
    # For Gemini
    settings = Settings(
        OUTFITAI_PROVIDER="gemini",
        GEMINI_API_KEY="your-api-key"
    )
    classifier = ClassifierFactory.create_classifier(settings)
    

Available Settings

All settings can be configured through environment variables, .env file, or in code:

  • Required:
    • OPENAI_API_KEY: OpenAI API key (required when using OpenAI)
    • GEMINI_API_KEY: Gemini API key (required when using Gemini)
  • Optional:
    • OUTFITAI_PROVIDER: API provider to use ("openai" or "gemini") (default: openai)
    • OPENAI_MODEL: OpenAI model to use (default: gpt-4o-mini)
    • GEMINI_MODEL: Gemini model to use (default: gemini-2.0-flash)

Example of using custom settings:

settings = Settings(
    OUTFITAI_PROVIDER="gemini",
    GEMINI_API_KEY="your-api-key",
    GEMINI_MODEL="gemini-2.0-flash",
)
classifier = ClassifierFactory.create_classifier(settings)

Notes

  • API costs vary by provider and model.
  • When using as a library, remember that the classifier methods are asynchronous.
  • The library automatically handles image size optimization.
  • GIF support is only available with the OpenAI provider.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

outfitai-1.2.3.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

outfitai-1.2.3-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

Details for the file outfitai-1.2.3.tar.gz.

File metadata

  • Download URL: outfitai-1.2.3.tar.gz
  • Upload date:
  • Size: 16.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for outfitai-1.2.3.tar.gz
Algorithm Hash digest
SHA256 c96061823829bdd3222cb817bdf173d621aed6adfbaf50d64d41b24913a06bf9
MD5 2c38c46f52adefb4971f6b3b5aa2b23e
BLAKE2b-256 97df3f61a06254be04ecece0fe0f8d6e8ba33a098a814a8f33f6fe3f486c3043

See more details on using hashes here.

File details

Details for the file outfitai-1.2.3-py3-none-any.whl.

File metadata

  • Download URL: outfitai-1.2.3-py3-none-any.whl
  • Upload date:
  • Size: 15.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for outfitai-1.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2a4bf1d8c7270b0b1aeb44be191dee294cf529836cf9ffc2ee893d2949f4322a
MD5 cf61701d6d1e982762e3b632e2807aa7
BLAKE2b-256 1ef40d122c31c56481892cd43a28e2a764ef0956e81ae3184fdf19a5f662bd74

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page