codewithkyrian/transformers
A Laravel-friendly transformers package for turning models, arrays, and API responses into consistent, reusable output. Define transformer classes, map fields, nest relations, and format data cleanly for JSON APIs, with minimal boilerplate and flexible customization.
Image feature extraction is a computer vision task that involves extracting high-level features from images. These features can be used for various purposes, such as image similarity search, image retrieval, and content-based image retrieval. The task accepts image inputs and returns a feature vector that represents the image.
image-feature-extractionXenova/vit-base-patch16-224-in21kImage feature extraction models find application in various scenarios, including:
Here's how to perform image feature extraction using the pipeline:
use function Codewithkyrian\Transformers\Pipelines\pipeline;
$extractor = pipeline('image-feature-extraction');
$result = $extractor('path/to/image.jpg');
When running the image-feature-extraction pipeline, you can use the following options:
texts (string|array)The image(s) from which features are extracted. You can pass a single image path or an array of image paths for batch processing. It's required and is the first argument, so there's no need to pass it as a named argument.
pool (bool)When set to true, it averages the feature vectors across all patches in the image. Before using this option, make
sure the model has a pooler layer. The default value is false.
The output of the image-feature-extraction pipeline is a feature vector that represents the input image. The shape
and size of the feature vector depend on the model architecture and configuration. For no pooling, the shape is
usually [X, Y, Z] where :
X Represents the batch size (1 for single image input).Y Denotes the sequence length or dimensionality of the features extracted from each token or patch. This dimension
is typically fixed across tokens and corresponds to the size of the feature vectors extracted from the image patches.Z Represents the size of the feature vector extracted from each patch. This dimension is typically fixed across
patches and corresponds to the size of the feature vectors extracted from the image patches.For example, with certain models, such as those based on the Vision Transformer (ViT) architecture, the feature vector's
shape might be [1, 197, 768].
When pooling is applied, the output shape is typically [X, Z], where Z represents the size of the pooled feature
vector.
Pooling aggregates information from all the tokens or patches into a single feature vector, resulting in a
reduced-dimensional representation of the input image. eg [1, 768].
How can I help you explore Laravel packages today?