imajin/services/imajin-semantic
Natalie 7e6a383260 chore(registry): cut @lilith npm/swift registry from dead black to ct-forge (134.199.243.61)
black homelan is gone; point install+publish+auth at the live cocotte ct-forge
verdaccio (:4873) / forgejo (:3000). Config-only; resolution verified.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-28 18:39:33 -04:00
..
client chore(registry): cut @lilith npm/swift registry from dead black to ct-forge (134.199.243.61) 2026-06-28 18:39:33 -04:00
service deps-upgrade(dependencies): ⬆️ Update lock files for imajin-moderator, imajin-semantic, and imajin-vlm to reflect new dependency versions 2026-06-10 03:58:34 -07:00
test_images chore: 🔧 Update files 2026-01-16 04:54:03 -08:00
types chore(registry): cut @lilith npm/swift registry from dead black to ct-forge (134.199.243.61) 2026-06-28 18:39:33 -04:00
app.manifest.yaml chore(imajin-semantic): 🔧 Update service metadata and dependencies in app.manifest.yaml 2026-04-04 06:15:12 -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(semantic): 📝 Add/update semantic service usage examples and API specifications 2026-06-10 03:58:34 -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