unitorch.cli.models.vit¤
ViTProcessor¤
Tip
core/process/vit
is the section for configuration of ViTProcessor.
Bases: ViTProcessor
Vision Transformer (ViT) Processor for handling image processing tasks.
Initialize ViTProcessor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vision_config_path |
str
|
The path to the vision config file. |
required |
Source code in src/unitorch/cli/models/vit/processing.py
26 27 28 29 30 31 32 33 34 35 36 37 38 |
|
from_core_configure
classmethod
¤
from_core_configure(config, **kwargs)
Create an instance of ViTProcessor from a core configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config |
The core configuration. |
required | |
**kwargs |
Additional keyword arguments. |
{}
|
Returns:
Name | Type | Description |
---|---|---|
dict |
The processed arguments for initializing the processor. |
Source code in src/unitorch/cli/models/vit/processing.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
|
ViTForImageClassification¤
Tip
core/model/classification/vit
is the section for configuration of ViTForImageClassification.
Bases: ViTForImageClassification
Vision Transformer (ViT) for Image Classification model.
Initialize ViTForImageClassification.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config_path |
str
|
The path to the model's configuration file. |
required |
num_classes |
Optional[int]
|
The number of classes for image classification. Defaults to 1. |
1
|
Source code in src/unitorch/cli/models/vit/modeling.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
|
forward ¤
forward(pixel_values: Tensor)
Forward pass of the ViTForImageClassification model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pixel_values |
Tensor
|
The input pixel values of the image. |
required |
Returns:
Name | Type | Description |
---|---|---|
ClassificationOutputs |
The output logits of the model. |
Source code in src/unitorch/cli/models/vit/modeling.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
|
from_core_configure
classmethod
¤
from_core_configure(config, **kwargs)
Create an instance of ViTForImageClassification from a core configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config |
The core configuration. |
required | |
**kwargs |
Additional keyword arguments. |
{}
|
Returns:
Name | Type | Description |
---|---|---|
ViTForImageClassification |
The initialized ViTForImageClassification instance. |
Source code in src/unitorch/cli/models/vit/modeling.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
|