How caoyunkang/adaclip works
AdaCLIP is a zero-shot image-anomaly detection system that adapts CLIP with learnable static and image-conditioned prompts, trained on annotated auxiliary datasets and applied to novel categories. Its main workflow is training or interactive inference: select datasets or upload an image, run the adapted model, and produce anomaly scores and localization maps. The graph also includes documented dataset preparation and evaluation capabilities. Relationships reflect the excerpts, SOURCE INDEX references, and README; unsampled implementation details are not assumed.
Main entry points: trainer.py Training and inference · train.py Training command · adaclip.py Prompted anomaly model · base_dataset.py Image and mask loading
Components 18
Entry points
- Training command
train.py - Image demo
app.py
Data pipeline
- Dataset preparation
data_preprocess - Dataset selection
dataset/__init__.py - Dataset adapters
dataset - Image and mask loading
dataset/base_dataset.py
AdaCLIP model
- Prompted anomaly model
method/adaclip.py - CLIP backbone
method/clip_model.py - Transformer layers
method/transformer.py - Prompt tokenizer
method/simple_tokenizer.py - CLIP construction
method/custom_clip.py
Training and evaluation
- Training and inference
method/trainer.py - Training losses
loss.py - Anomaly metrics
tools/metrics.py - Result visualization
tools/visualization.py - Run logging
tools/logger.py - Training utilities
tools/training_tools.py
Other components
- User
Connections 20
- User → Training command: starts training
- User → Image demo: submits image
app.py - Training command → Dataset selection: selects datasets
train.py - Training command → Training and inference: runs training
train.py - Dataset preparation → Image and mask loading: creates metadata
- Dataset selection → Dataset adapters: selects adapter
dataset/__init__.py - Dataset adapters → Image and mask loading: inherits loading
dataset/dtd.py - Image and mask loading → Training and inference: supplies batches
- Image demo → Training and inference: loads and predicts
app.py - Training and inference → CLIP construction: creates backbone
method/trainer.py - Training and inference → Prompted anomaly model: constructs and trains
method/trainer.py - Training and inference → Training losses: computes losses
method/trainer.py - Training and inference → Anomaly metrics: calculates scores
method/trainer.py - Training and inference → Result visualization: renders results
method/trainer.py - Training and inference → Run logging: records runs
- Training and inference → Training utilities: uses utilities
- Prompted anomaly model → CLIP backbone: adapts CLIP
method/adaclip.py - Prompted anomaly model → Prompt tokenizer: tokenizes prompts
method/adaclip.py - CLIP backbone → Transformer layers: uses layers
method/clip_model.py - CLIP construction → CLIP backbone: builds model
method/custom_clip.py