{"id":15600969,"url":"https://github.com/lucidrains/segformer-pytorch","last_synced_at":"2025-04-05T04:08:43.875Z","repository":{"id":41825624,"uuid":"374442567","full_name":"lucidrains/segformer-pytorch","owner":"lucidrains","description":"Implementation of Segformer, Attention + MLP neural network for segmentation, in Pytorch","archived":false,"fork":false,"pushed_at":"2022-12-09T02:37:48.000Z","size":106,"stargazers_count":358,"open_issues_count":11,"forks_count":45,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-03-29T03:03:21.168Z","etag":null,"topics":["artificial-intelligence","attention-mechanism","deep-learning","image-segmentation","multilayer-perceptron","segmentation"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lucidrains.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":"2021-06-06T19:06:49.000Z","updated_at":"2025-03-27T09:19:08.000Z","dependencies_parsed_at":"2022-07-05T15:31:26.130Z","dependency_job_id":null,"html_url":"https://github.com/lucidrains/segformer-pytorch","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucidrains%2Fsegformer-pytorch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucidrains%2Fsegformer-pytorch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucidrains%2Fsegformer-pytorch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucidrains%2Fsegformer-pytorch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lucidrains","download_url":"https://codeload.github.com/lucidrains/segformer-pytorch/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247284942,"owners_count":20913704,"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":["artificial-intelligence","attention-mechanism","deep-learning","image-segmentation","multilayer-perceptron","segmentation"],"created_at":"2024-10-03T02:10:36.573Z","updated_at":"2025-04-05T04:08:43.839Z","avatar_url":"https://github.com/lucidrains.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"./segformer.png\" width=\"500px\"\u003e\u003c/img\u003e\n\n## Segformer - Pytorch\n\nImplementation of \u003ca href=\"https://arxiv.org/abs/2105.15203\"\u003eSegformer\u003c/a\u003e, Attention + MLP neural network for segmentation, in Pytorch.\n\n## Install\n\n```bash\n$ pip install segformer-pytorch\n```\n\n## Usage\n\nFor example, MiT-B0\n\n```python\nimport torch\nfrom segformer_pytorch import Segformer\n\nmodel = Segformer(\n    dims = (32, 64, 160, 256),      # dimensions of each stage\n    heads = (1, 2, 5, 8),           # heads of each stage\n    ff_expansion = (8, 8, 4, 4),    # feedforward expansion factor of each stage\n    reduction_ratio = (8, 4, 2, 1), # reduction ratio of each stage for efficient attention\n    num_layers = 2,                 # num layers of each stage\n    decoder_dim = 256,              # decoder dimension\n    num_classes = 4                 # number of segmentation classes\n)\n\nx = torch.randn(1, 3, 256, 256)\npred = model(x) # (1, 4, 64, 64)  # output is (H/4, W/4) map of the number of segmentation classes\n```\n\nMake sure the keywords are at most a tuple of 4, as this repository is hard-coded to give the MiT 4 stages as done in the paper.\n\n## Citations\n\n```bibtex\n@misc{xie2021segformer,\n    title   = {SegFormer: Simple and Efficient Design for Semantic Segmentation with Transformers}, \n    author  = {Enze Xie and Wenhai Wang and Zhiding Yu and Anima Anandkumar and Jose M. Alvarez and Ping Luo},\n    year    = {2021},\n    eprint  = {2105.15203},\n    archivePrefix = {arXiv},\n    primaryClass = {cs.CV}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucidrains%2Fsegformer-pytorch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flucidrains%2Fsegformer-pytorch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucidrains%2Fsegformer-pytorch/lists"}