ViTImageSafetyClassifier<T>
Models & Types · AiDotNet.Safety.Image
Patch-statistics image safety classifier: hand-set colour and edge rules evaluated per image patch and pooled with fixed similarity weights. Despite its name it is not a Vision Transformer and has no learned weights.
Inheritance: ModelBase<T, Vector<T>, Vector<T>> → SafetyModuleBase<T> → ImageSafetyModuleBase<T> → ViTImageSafetyClassifier<T>
For Beginners
this classifier cuts the image into small squares, measures simple colour and edge statistics in each, and combines them with fixed rules. It catches some obviously skin-heavy or red-heavy images, but it does not understand what the image shows the way a trained neural network would.
How It Works
The image is cut into square patches, as a ViT tokenizes an image, but each patch is then summarised by fixed statistics (channel means and spreads, the fraction of pixels passing an RGB skin-colour rule after Kovac, Peer and Solina 2003, dark, bright and red-dominant fractions, and gradient energy). The patch summaries are pooled with softmax weights given by their similarity to the mean patch, and each safety category is scored by a hand-written rule on the pooled summary. Nothing is trained: the scores are heuristics that colour and texture alone can trigger, and should be treated as weak signals for review rather than classifications.
References:
- Kovac, Peer, Solina. Human Skin Colour Clustering for Face Detection (EUROCON 2003) — the skin rule
Constructors
| Constructor | Summary |
|---|---|
ViTImageSafetyClassifier(int patchSize, double threshold) |
Initializes a new patch-statistics image safety classifier. |
Properties
| Property | Summary |
|---|---|
string ModuleName { get; } |
Methods
| Method | Summary |
|---|---|
IReadOnlyList<SafetyFinding> EvaluateImage(Tensor<T> image) |