Skip to main content
Glama
19892500339

attribute-classifier-mcp

by 19892500339

Attribute Classifier MCP Server

🎯 YOLO Detection β†’ Object Cropping β†’ CNN Attribute Classification β†’ JSON Results

A Model Context Protocol (MCP) server that combines YOLO object detection with per-attribute CNN classifiers. Detects objects in images, crops them, and classifies each object's visual attributes (material, color, has_armrest, etc.) using dedicated CNN models.

✨ Features

Feature

Description

πŸ“¦ Object Cropping

Crop objects from images using YOLO txt bbox annotations

πŸ—‚οΈ Dataset Organization

Organize cropped images by attribute value for CNN training

🧠 CNN Training

Train dedicated CNN classifiers per attribute (ResNet, MobileNet, EfficientNet)

πŸ” Full Pipeline Inference

YOLO detect β†’ crop β†’ multi-attribute CNN classify β†’ JSON output

πŸ”„ Hot-swap Models

Register/replace attribute models without restarting

πŸ“‹ Attribute Discovery

Auto-discover attributes from X-AnyLabeling JSON annotations

⚑ Batch Processing

Process multiple images in one call

βš™οΈ Configurable

YAML config for paths, training params, YOLO settings

Related MCP server: Kolosal Vision MCP

πŸš€ Quick Start

Installation

# Clone the repository
git clone https://github.com/your-username/attribute-classifier-mcp.git
cd attribute-classifier-mcp

# Install dependencies
pip install -r requirements.txt

# Or install as package
pip install -e .

Configure MCP Client

Add to your MCP client config (e.g. Claude Desktop claude_desktop_config.json):

{
  "mcpServers": {
    "attribute-classifier": {
      "command": "python",
      "args": ["src/server.py"],
      "cwd": "/path/to/attribute-classifier-mcp"
    }
  }
}

With Docker

docker build -t attribute-classifier-mcp .
docker run -v /your/data:/app/data -v /your/models:/app/models attribute-classifier-mcp

πŸ“Š Complete Workflow

Step 1: Prepare Your Data

data/
β”œβ”€β”€ images/          # Original images (.jpg, .png)
β”œβ”€β”€ labels/          # YOLO txt annotations (one per image)
β”‚   └── img001.txt   # "0 0.5 0.5 0.3 0.4" (class cx cy w h)
β”œβ”€β”€ jsons/           # X-AnyLabeling JSON attributes (one per image)
β”‚   └── img001.json  # {shapes: [{label, attributes: {material: "leather"}}]}
β”œβ”€β”€ classes.txt      # Class names (one per line)
└── attributes.json  # Optional: master JSON with all attributes

Step 2: Crop Objects

Use the crop_objects tool to crop all annotated objects from images:

{
  "tool": "crop_objects",
  "arguments": {
    "images_dir": "./data/images",
    "labels_dir": "./data/labels",
    "json_dir": "./data/jsons",
    "classes_file": "./data/classes.txt"
  }
}

Step 3: Organize by Attribute

Organize crops into classification datasets:

{
  "tool": "organize_dataset",
  "arguments": {
    "cropped_dir": "./data/cropped",
    "attribute_name": "material",
    "master_json": "./data/attributes.json"
  }
}

This creates:

data/datasets/material/
β”œβ”€β”€ leather/     # Images of leather objects
β”œβ”€β”€ wood/        # Images of wooden objects
β”œβ”€β”€ fabric/      # Images of fabric objects
└── metal/       # Images of metal objects

Step 4: Train Models

Train a CNN for each attribute:

{
  "tool": "train_attribute_model",
  "arguments": {
    "dataset_dir": "./data/datasets/material",
    "attribute_name": "material",
    "backbone": "resnet18",
    "epochs": 50
  }
}

Or train all attributes at once:

{
  "tool": "train_all_attributes",
  "arguments": {
    "datasets_dir": "./data/datasets"
  }
}

Step 5: Inference

Run the full pipeline on new images:

{
  "tool": "detect_and_classify",
  "arguments": {
    "image_path": "./test.jpg"
  }
}

Output:

{
  "image": "test.jpg",
  "image_size": {"width": 1920, "height": 1080},
  "total_objects": 2,
  "detections": [
    {
      "index": 0,
      "class_name": "chair",
      "confidence": 0.92,
      "bbox": {"x1": 100, "y1": 200, "x2": 400, "y2": 600},
      "attributes": {
        "material": {
          "attribute": "material",
          "predicted_value": "leather",
          "confidence": 0.95,
          "all_probabilities": {
            "leather": 0.95,
            "wood": 0.03,
            "fabric": 0.02
          }
        },
        "has_armrest": {
          "attribute": "has_armrest",
          "predicted_value": "yes",
          "confidence": 0.88,
          "all_probabilities": {"yes": 0.88, "no": 0.12}
        }
      }
    }
  ]
}

πŸ› οΈ All MCP Tools (16 total)

Data Preparation

Tool

Description

crop_objects

Crop objects from images using YOLO txt bbox annotations

organize_dataset

Organize crops by attribute value into classification folders

discover_attributes

Discover all attribute names and values from JSON annotations

Training

Tool

Description

train_attribute_model

Train a CNN classifier for one attribute

train_all_attributes

Train CNN classifiers for all discovered attributes

Inference

Tool

Description

detect_and_classify

Full pipeline: YOLO β†’ crop β†’ CNN classify β†’ JSON

classify_crop

Classify a pre-cropped image through attribute models

batch_detect_and_classify

Process multiple images through the full pipeline

Model Management

Tool

Description

register_model

Register/replace a CNN model for an attribute

unregister_model

Remove a model from the registry

list_models

List all registered attribute models

get_model_info

Get detailed info about a specific model

Configuration

Tool

Description

update_config

Update server configuration

get_config

Get current configuration

set_class_attributes

Map detected classes to their attributes

full_pipeline

Run complete pipeline: crop β†’ organize β†’ train

πŸ”§ Configuration

Edit config/default_config.yaml or pass a custom config:

python src/server.py /path/to/my_config.yaml

Key Config Options

# Paths
paths:
  images_dir: "./data/images"
  labels_dir: "./data/labels"
  json_dir: "./data/jsons"
  master_json: "./data/attributes.json"

# Training
training:
  backbone: "resnet18"    # resnet18/34/50, mobilenet_v2, efficientnet_b0
  epochs: 50
  batch_size: 32
  device: "auto"          # auto, cpu, cuda

# YOLO
yolo:
  model: "yolov8n.pt"
  confidence: 0.5

πŸ”„ Hot-swap Models

Replace any attribute's model at runtime:

{
  "tool": "register_model",
  "arguments": {
    "attribute_name": "material",
    "model_path": "./models/material_efficientnet_b0_best.pth"
  }
}

πŸ“ Supported Annotation Formats

YOLO TXT (for bounding boxes)

0 0.5125 0.4833 0.3250 0.4167
1 0.2500 0.7500 0.2000 0.3000

X-AnyLabeling JSON (for attributes)

{
  "shapes": [
    {
      "label": "chair",
      "points": [[100, 200], [400, 600]],
      "shape_type": "rectangle",
      "flags": {"has_armrest": true},
      "attributes": {"material": "leather", "seat_count": "1"}
    }
  ]
}

πŸ“œ License

MIT License

Related MCP Connectors

Related MCP Servers

  • F
    license
    A
    quality
    Not graded
    maintenance
    Enables AI agents to analyze images through vision AI providers (Gemini, OpenAI, Claude), performing tasks like image description, object detection with bounding boxes, region-specific analysis, and precise color extraction without consuming context window with raw pixels.
    4
    -
  • A
    license
    A
    quality
    D
    maintenance
    Provides AI-powered image analysis and OCR capabilities using the Kolosal Vision API. Supports analyzing images from URLs, local files, or base64 data with natural language queries for object detection, scene description, text extraction, and visual assessment.
    1
    6 npm
    MIT
  • A
    license
    A
    quality
    D
    maintenance
    Provides advanced image analysis capabilities including object recognition, OCR text extraction, and multi-turn visual dialogues using OpenAI-compatible APIs. It supports both local files and Base64 inputs with additional features for session persistence and web-based configuration management.
    3
    MIT