{"id":15601038,"url":"https://github.com/lucidrains/ittr-pytorch","last_synced_at":"2025-04-30T17:21:11.922Z","repository":{"id":62571937,"uuid":"476829170","full_name":"lucidrains/ITTR-pytorch","owner":"lucidrains","description":"Implementation of the Hybrid Perception Block and Dual-Pruned Self-Attention block from the ITTR paper for Image to Image Translation using Transformers","archived":false,"fork":false,"pushed_at":"2022-04-02T02:14:02.000Z","size":149,"stargazers_count":35,"open_issues_count":3,"forks_count":8,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-28T13:07:46.997Z","etag":null,"topics":["artificial-intelligence","attention-mechanism","deep-learning","image-to-image-translation"],"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":"2022-04-01T18:28:24.000Z","updated_at":"2025-01-05T08:59:15.000Z","dependencies_parsed_at":"2022-11-04T07:38:46.555Z","dependency_job_id":null,"html_url":"https://github.com/lucidrains/ITTR-pytorch","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucidrains%2FITTR-pytorch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucidrains%2FITTR-pytorch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucidrains%2FITTR-pytorch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucidrains%2FITTR-pytorch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lucidrains","download_url":"https://codeload.github.com/lucidrains/ITTR-pytorch/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251749112,"owners_count":21637456,"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-to-image-translation"],"created_at":"2024-10-03T02:12:47.494Z","updated_at":"2025-04-30T17:21:11.887Z","avatar_url":"https://github.com/lucidrains.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"./ittr.png\" width=\"500px\"\u003e\u003c/img\u003e\n\n## ITTR - Pytorch\n\nImplementation of the Hybrid Perception Block (`HPB`) and Dual-Pruned Self-Attention (`DPSA`) block from the \u003ca href=\"https://arxiv.org/abs/2203.16015\"\u003eITTR paper\u003c/a\u003e for Image to Image Translation using Transformers.\n\n## Install\n\n```bash\n$ pip install ITTR-pytorch\n```\n\n## Usage\n\nThey had 9 blocks of Hybrid Perception Block (HPB) in the paper\n\n```python\nimport torch\nfrom ITTR_pytorch import HPB\n\nblock = HPB(\n    dim = 512,              # dimension\n    dim_head = 32,          # dimension per attention head\n    heads = 8,              # number of attention heads\n    attn_height_top_k = 16, # number of top indices to select along height, for the attention pruning\n    attn_width_top_k = 16,  # number of top indices to select along width, for the attention pruning\n    attn_dropout = 0.,      # attn dropout\n    ff_mult = 4,            # expansion factor of feedforward\n    ff_dropout = 0.         # feedforward dropout\n)\n\nfmap = torch.randn(1, 512, 32, 32)\n\nout = block(fmap) # (1, 512, 32, 32)\n```\n\nYou can also use the dual-pruned self-attention as so\n\n```python\nimport torch\nfrom ITTR_pytorch import DPSA\n\nattn = DPSA(\n    dim = 512,         # dimension\n    dim_head = 32,     # dimension per attention head\n    heads = 8,         # number of attention heads\n    height_top_k = 48, # number of top indices to select along height, for the attention pruning\n    width_top_k = 48,  # number of top indices to select along width, for the attention pruning\n    dropout = 0.       # attn dropout\n)\n\nfmap = torch.randn(1, 512, 32, 32)\n\nout = attn(fmap) # (1, 512, 32, 32)\n```\n\n## Citations\n\n```bibtex\n@inproceedings{Zheng2022ITTRUI,\n  title   = {ITTR: Unpaired Image-to-Image Translation with Transformers},\n  author  = {Wanfeng Zheng and Qiang Li and Guoxin Zhang and Pengfei Wan and Zhongyuan Wang},\n  year    = {2022}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucidrains%2Fittr-pytorch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flucidrains%2Fittr-pytorch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucidrains%2Fittr-pytorch/lists"}