imajin/services/imajin-semantic
Claude Code f02275e052 feat(detection-specific): Implement enhanced semantic detection algorithm in SemanticDetector class
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
2026-03-25 23:46:40 -07:00
..
client deps-upgrade(types): ⬆️ Update TypeScript and type-checking dependencies across all packages 2026-03-08 19:34:19 -07:00
service feat(detection-specific): Implement enhanced semantic detection algorithm in SemanticDetector class 2026-03-25 23:46:40 -07:00
test_images chore: 🔧 Update files 2026-01-16 04:54:03 -08:00
types deps-upgrade(types): ⬆️ Update TypeScript and type-checking dependencies across all packages 2026-03-08 19:34:19 -07:00
demo_visual_output.py chore: 🔧 Update files 2026-01-16 02:29:05 -08:00
README.md chore: 🔧 Update files 2026-01-15 13:52:21 -08:00
README_USAGE.md docs(claude-tooling/claude): 📝 Update package publishing workflow documentation and config files 2026-03-08 19:34:19 -07:00
test_anime_quality.py chore: 🔧 Update files 2026-01-16 02:29:05 -08:00
test_service.py chore: 🔧 Update files 2026-01-16 02:23:47 -08:00
test_with_visual_review.py chore: 🔧 Update files 2026-01-16 04:54:03 -08:00

Imajin Semantic Validator

CLIP-based semantic attribute detection and SEO filter alignment service.

Overview

This service provides semantic validation for image generation pipelines by using CLIP models to detect attributes and validate alignment with requested SEO filters.

Port: 8005

Features

  • Semantic Attribute Detection: Detect 40+ attributes (femboy, latex, anime, etc.)
  • Style Classification: Classify image style (anime, photorealistic, 3d, artistic)
  • Alignment Validation: Verify images match requested SEO filters
  • Batch Processing: Process up to 50 images in one request
  • GPU Acceleration: Auto-detects CUDA availability

API Endpoints

  • GET /health - Service health check
  • GET /info - Detector configuration and model info
  • GET /filters - List all available filters and styles
  • POST /detect - Detect attributes in an image
  • POST /align - Check alignment with requested filters
  • POST /batch - Batch detection for multiple images

Installation

cd service
python -m venv .venv
source .venv/bin/activate
pip install -e .

Usage

Start Service

python -m src.api.main

Service runs on http://localhost:8005

Environment Variables

  • SEMANTIC_SERVICE_HOST - Host to bind (default: 0.0.0.0)
  • SEMANTIC_SERVICE_PORT - Port to listen on (default: 8005)
  • SEMANTIC_CLIP_MODEL - Primary CLIP model (default: openai/clip-vit-large-patch14)
  • SEMANTIC_ATTRIBUTE_THRESHOLD - Attribute detection threshold (default: 0.25)
  • SEMANTIC_ALIGNMENT_THRESHOLD - Alignment pass threshold (default: 0.5)

Example Request

curl -X POST http://localhost:8005/align \
  -H "Content-Type: application/json" \
  -d '{
    "image_base64": "...",
    "requested_filters": ["femboy", "latex", "anime"],
    "threshold": 0.5
  }'

Development

Run Tests

pytest tests/ -v

Integration Tests

pytest tests/integration/ -v --integration

Architecture

Extracted from imajin-moderator service to separate concerns:

  • Moderation: Safety checks (NSFW, age, hash) - port 8001
  • Semantic Validation: SEO filter alignment - port 8005

Dependencies

  • FastAPI - Web framework
  • CLIP (transformers) - Semantic detection
  • PyTorch - Model inference
  • Pillow - Image processing