{"id":18797574,"url":"https://github.com/topazape/vit-pytorch","last_synced_at":"2025-09-02T09:30:58.571Z","repository":{"id":59955615,"uuid":"538872343","full_name":"topazape/ViT-Pytorch","owner":"topazape","description":"Vision Transformer in Pytorch","archived":false,"fork":false,"pushed_at":"2022-11-20T03:27:58.000Z","size":4842,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-24T23:04:22.052Z","etag":null,"topics":["computer-vision","deep-learning","pytorch","transformer-architecture","vision-transformer"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/topazape.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}},"created_at":"2022-09-20T07:56:31.000Z","updated_at":"2024-12-13T08:51:38.000Z","dependencies_parsed_at":"2022-09-25T10:40:05.986Z","dependency_job_id":null,"html_url":"https://github.com/topazape/ViT-Pytorch","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/topazape%2FViT-Pytorch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/topazape%2FViT-Pytorch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/topazape%2FViT-Pytorch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/topazape%2FViT-Pytorch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/topazape","download_url":"https://codeload.github.com/topazape/ViT-Pytorch/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231768726,"owners_count":18423792,"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":["computer-vision","deep-learning","pytorch","transformer-architecture","vision-transformer"],"created_at":"2024-11-07T22:08:47.561Z","updated_at":"2024-12-29T17:52:33.704Z","avatar_url":"https://github.com/topazape.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Vision Transformer (ViT)\nImplementation of Vision Transformer (ViT) in Pytorch. ViT is presented in the paper, [An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale](https://openreview.net/forum?id=YicbFdNTTy).\n![](assets/vit.png)\n\n# Implementation\nThe ViT code for this repo is based on the book [\"Vision Transformer 入門\"](https://gihyo.jp/book/2022/978-4-297-13058-9) written in Japanese. I added some code for dataset preparation and training procedures using [CIFAR10](https://www.cs.toronto.edu/~kriz/cifar.html).\n\n# Usage\n```\npython run.py [-h] [-s SEED] FILE\n\npositional arguments:\n  FILE                  path to config file\n\noptions:\n  -h, --help            show this help message and exit\n  -s SEED, --seed SEED  seed for initializing training\n```\n\n# Example\n```\npython run.py examples/CIFAR10/config.ini\n```\n\n# Config\nHere shows a list of settings and what they mean.\nParameters are based on the ViT experiment [conducted by GMO](https://recruit.gmo.jp/engineer/jisedai/blog/vision_transformer/).\n```ini\n[dataset]\ndir = ./datasets\t; training data save directory\nname = CIFAR10\t\t; dataset name, only CIFAR10 is acceptable\nin_channels = 3\t\t; number of channels\nimage_size = 32\t\t; image size; 32x32\nnum_classes = 10\t; 10 class classification\n\n[dataloader]\nbatch_size = 32\nshuffle = true\n\n[model]\npatch_size = 4\t\t; use 4 x 4 px for patch\nembed_dim = 256\t\t; same meaning of dim=256 of `vit-pytorch`\nnum_blocks = 3\t\t; same meaning of depth=3 of `vit-pytorch`\nheads = 4\t\t\t; number of multihead attention\nhidden_dim = 256\t; same meaning of mlp_dim=256 of `vit-pytorch`\ndropout = 0.1\t\t; dropout ratio\n\n[learning]\nepochs = 20\nlearning_rate = 0.001\n```\n\n# Result\nViT is inherently accurate when pre-trained on large image data sets (like [JFT-300M](https://paperswithcode.com/dataset/jft-300m)), so simply training on CIFAR10, as in this code, does not reduce cross-entropy loss.\n```\n[2022-09-23 11:52:17] :vision_transformer.utils.logger: [INFO] loss: 2.0047439576718755\n[2022-09-23 11:52:38] :vision_transformer.utils.logger: [INFO] loss: 1.8455862294370755\n...\n[2022-09-23 11:58:37] :vision_transformer.utils.logger: [INFO] loss: 1.2203882005268012\n[2022-09-23 11:58:58] :vision_transformer.utils.logger: [INFO] loss: 1.2218489825915986\n```\nThis same has been shown in [GMO experiment](https://recruit.gmo.jp/engineer/jisedai/blog/vision_transformer/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftopazape%2Fvit-pytorch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftopazape%2Fvit-pytorch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftopazape%2Fvit-pytorch/lists"}