pip install vtransformer- Configure config yaml file to work with model
- Module has 2 methods:
- run - use for training and testing model
- __call__ - use to classify images and utilize model Example of the code:
import VisionTransformer as ViT
import hydra
from pathlib import Path
@hydra.main(config_path="path_to_your_config", config_name="name_of_your_config")
def main(cfg):
abspath = str(Path(__file__).parent.resolve()) + "/" # Get absolute path, if your config works with relative paths
model = ViT.Program(cfg, abspath) # Create object of class Program to work with transformer
model.run() # Run config, that you wrote to train and test model
arr = ["path1", "path2", "path3"]
print(model(arr, False)) # Utilize model
if __name__ == "__main__":
main()Thanks for the idea and pretrained models to:
- A huge credit to my teacher, Alexandr Korchemnyj
- Idea is based on an article An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
- I have used pretrained model from SWAG, check the license