{"id":18401704,"url":"https://github.com/borealisai/efficient-vit-training","last_synced_at":"2025-04-07T07:31:42.600Z","repository":{"id":191646814,"uuid":"563108220","full_name":"BorealisAI/efficient-vit-training","owner":"BorealisAI","description":"PyTorch code of \"Training a Vision Transformer from scratch in less than 24 hours with 1 GPU\" (HiTY workshop at Neurips 2022)","archived":false,"fork":false,"pushed_at":"2023-08-30T14:05:56.000Z","size":337,"stargazers_count":12,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-04-18T03:18:36.940Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BorealisAI.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-11-07T23:20:56.000Z","updated_at":"2024-04-18T02:32:10.000Z","dependencies_parsed_at":"2023-08-30T23:25:10.070Z","dependency_job_id":null,"html_url":"https://github.com/BorealisAI/efficient-vit-training","commit_stats":null,"previous_names":["borealisai/efficient-vit-training"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BorealisAI%2Fefficient-vit-training","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BorealisAI%2Fefficient-vit-training/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BorealisAI%2Fefficient-vit-training/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BorealisAI%2Fefficient-vit-training/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BorealisAI","download_url":"https://codeload.github.com/BorealisAI/efficient-vit-training/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223274456,"owners_count":17118009,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T02:39:41.503Z","updated_at":"2024-11-06T02:39:42.060Z","avatar_url":"https://github.com/BorealisAI.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Efficient VisionTransformer\n\nThis repository contains implementation for the paper [Training a Vision Transformer from scratch in less than 24 hours with 1 GPU](https://arxiv.org/abs/2211.05187) published in [HiTY](https://hity-workshop.github.io/NeurIPS2022/) workshop at Neurips 2022.\n\nThe implementation is a PyTorch evaluation code and training code based on [DeiT](https://github.com/facebookresearch/deit). We also use and edit some code from [LocalViT](https://github.com/ofsoundof/LocalViT), [Timm](https://github.com/huggingface/pytorch-image-models/tree/main/timm) and [torchvision](https://github.com/pytorch/vision/tree/main/torchvision).\n\nIn all experiments we build on DeiT-small model, and try to make the training more efficient time-wise (24 hours) and GPU-wise (1). This includes removing warm-up, an improved [LocalViT model](https://arxiv.org/abs/2104.05707), in addition to our own multi-size training. There's also the possibility to use [LayerScale](https://arxiv.org/pdf/2103.17239.pdf) in the code. \n\nOur Best results are as below:\n\n\u003cimg src=\".github/1gpu_2.png\" width=50% height=50%\u003e\n\u003cimg src=\".github/1gpu.png\" width=50% height=50%\u003e\n\n\nBefore using it, make sure you have the pytorch-image-models package [`timm==0.3.2`](https://github.com/rwightman/pytorch-image-models) by [Ross Wightman](https://github.com/rwightman) installed. \n\n# Usage\n\nFirst, clone the repository locally:\n\nThen, install PyTorch 1.7.0+ and torchvision 0.8.1+ and [pytorch-image-models 0.3.2](https://github.com/rwightman/pytorch-image-models):\n\n```\nconda install -c pytorch pytorch torchvision\npip install timm==0.3.2\n```\n\n## Data preparation\n\nDownload and extract ImageNet train and val images from http://image-net.org/.\nThe directory structure is the standard layout for the torchvision [`datasets.ImageFolder`](https://pytorch.org/docs/stable/torchvision/datasets.html#imagefolder), and the training and validation data is expected to be in the `train/` folder and `val` folder respectively:\n\n```\n/path/to/imagenet/\n  train/\n    class1/\n      img1.jpeg\n    class2/\n      img2.jpeg\n  val/\n    class1/\n      img3.jpeg\n    class/2\n      img4.jpeg\n```\n\n## Training\n\nIn all experiments with 1 GPU we use --batch-size 64 and --lr 1e-3. (If you want to experiment with 4 GPUs, use --batch-size 128 and --lr 2e-4)\nWe stop the training after 1 day.\n\nTo Train the network with the best config on 1 GPU, run varsize_1gpu_best.sh with your own paths. \n\n## Results\n\nTo plot the accuracy per time results, use plot_output.py with your own paths. \n\n## Cite\n\nPlease cite the paper if you use the idea or code.\n\n```latex\n@misc{irandoust2022training,\n      title={{Training a Vision Transformer from scratch in less than 24 hours with 1 GPU}}, \n      author={Saghar Irandoust and Thibaut Durand and Yunduz Rakhmangulova and Wenjie Zi and Hossein Hajimirsadeghi},\n      year={2022},\n      eprint={2211.05187},\n      archivePrefix={arXiv},\n      primaryClass={cs.CV}\n}\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fborealisai%2Fefficient-vit-training","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fborealisai%2Fefficient-vit-training","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fborealisai%2Fefficient-vit-training/lists"}