Basic Usage
LAFT (Language-Assisted Feature Transformation) enables anomaly detection by transforming image features based on language-guided concept subspaces. This guide walks you through a complete workflow.Overview
The LAFT workflow consists of these key steps:Semantic Anomaly Detection
For datasets with semantic attributes (e.g., Color MNIST, Waterbirds, CelebA), LAFT can guide or ignore specific concepts.Complete Example: Color MNIST
Guide vs Ignore
LAFT supports two transformation strategies:Waterbirds Example
Industrial Anomaly Detection
For industrial defect detection (e.g., MVTec AD, VisA), LAFT works with normal/anomaly prompts.Complete Example: MVTec AD
Component Selection
The number of principal components affects performance. Typically:- Semantic datasets: 10-50 components work well
- Industrial datasets: Experiment with 2-100 components
Working with Raw Images
If you don’t have pre-computed features:Best Practices
Memory Management
Memory Management
Always disable gradients for inference:
Feature Caching
Feature Caching
Use
get_clip_cached_features() to cache extracted features and avoid recomputation:Batch Processing
Batch Processing
For large datasets, use DataLoader for efficient processing:
Next Steps
Prompts
Learn about the prompt system and how to create custom prompts
Evaluation
Understand metrics and how to evaluate your models
