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.5-flash)

Example of using custom settings:

settings = Settings(
    OUTFITAI_PROVIDER="gemini",
    GEMINI_API_KEY="your-api-key",
    GEMINI_MODEL="gemini-2.5-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.4.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.4-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for outfitai-1.2.4.tar.gz
Algorithm Hash digest
SHA256 b674f40690633eccfaadbd36509bf8f1e62cb76bf77e222a1ff4f93f24e13d1d
MD5 19e21fb292a205972ebc5e5bc2e33345
BLAKE2b-256 fde02f2eb0d33b6013f4f86d95ca324c8e0b965e19586291c8892b3016c6e398

See more details on using hashes here.

File details

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

File metadata

  • Download URL: outfitai-1.2.4-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.2

File hashes

Hashes for outfitai-1.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a3f7e13f4cd7525fa5ef10546992735becf3c7e88737416b787a21024118861e
MD5 f4e5e1462f39623652c9c1030338c267
BLAKE2b-256 6a2890391605eacd655f76cd9588b2b1d7cee6b5ccf75adb64df470e6341e878

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