{"id":13570092,"url":"https://github.com/lucidrains/x-unet","last_synced_at":"2025-04-04T22:05:06.815Z","repository":{"id":38266099,"uuid":"473261321","full_name":"lucidrains/x-unet","owner":"lucidrains","description":"Implementation of a U-net complete with efficient attention as well as the latest research findings","archived":false,"fork":false,"pushed_at":"2024-05-03T17:21:55.000Z","size":136,"stargazers_count":275,"open_issues_count":4,"forks_count":20,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-03-28T21:02:03.452Z","etag":null,"topics":["artificial-intelligence","deep-learning","image-generation","segmentation","u-net"],"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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-23T16:02:42.000Z","updated_at":"2025-03-12T10:16:36.000Z","dependencies_parsed_at":"2024-01-14T03:48:51.239Z","dependency_job_id":"398ebd4e-24fb-4ac8-aa52-13f83f1ec458","html_url":"https://github.com/lucidrains/x-unet","commit_stats":{"total_commits":41,"total_committers":2,"mean_commits":20.5,"dds":"0.024390243902439046","last_synced_commit":"09431e2d82a2360039475c1d8ae43f411ac20b45"},"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucidrains%2Fx-unet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucidrains%2Fx-unet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucidrains%2Fx-unet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucidrains%2Fx-unet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lucidrains","download_url":"https://codeload.github.com/lucidrains/x-unet/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247256110,"owners_count":20909240,"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","deep-learning","image-generation","segmentation","u-net"],"created_at":"2024-08-01T14:00:48.147Z","updated_at":"2025-04-04T22:05:06.793Z","avatar_url":"https://github.com/lucidrains.png","language":"Python","funding_links":[],"categories":["Uncategorized"],"sub_categories":["Uncategorized"],"readme":"\u003cimg src=\"./unet.png\" width=\"450px\"\u003e\u003c/img\u003e\n\n## x-unet\n\nImplementation of a U-net complete with efficient attention as well as the latest research findings\n\n## Install\n\n```bash\n$ pip install x-unet\n```\n\n## Usage\n\n```python\nimport torch\nfrom x_unet import XUnet\n\nunet = XUnet(\n    dim = 64,\n    channels = 3,\n    dim_mults = (1, 2, 4, 8),\n    nested_unet_depths = (7, 4, 2, 1),     # nested unet depths, from unet-squared paper\n    consolidate_upsample_fmaps = True,     # whether to consolidate outputs from all upsample blocks, used in unet-squared paper\n)\n\nimg = torch.randn(1, 3, 256, 256)\nout = unet(img) # (1, 3, 256, 256)\n```\n\nFor 3d (video or CT / MRI scans)\n\n```python\nimport torch\nfrom x_unet import XUnet\n\nunet = XUnet(\n    dim = 64,\n    frame_kernel_size = 3,                 # set this to greater than 1\n    channels = 3,\n    dim_mults = (1, 2, 4, 8),\n    nested_unet_depths = (5, 4, 2, 1),     # nested unet depths, from unet-squared paper\n    consolidate_upsample_fmaps = True,     # whether to consolidate outputs from all upsample blocks, used in unet-squared paper\n    weight_standardize = True\n)\n\nvideo = torch.randn(1, 3, 10, 128, 128)    # (batch, channels, frames, height, width)\nout = unet(video) # (1, 3, 10, 128, 128)\n```\n\n## Todo\n\n- [ ] memory efficiency for 3d - reversible blocks, checkpointing, memory efficient unet\n- [ ] offer option for axial convolutions (placing frame convolutions at end of the resnet chain)\n\n## Citations\n\n```bibtex\n@article{Ronneberger2015UNetCN,\n    title   = {U-Net: Convolutional Networks for Biomedical Image Segmentation},\n    author  = {Olaf Ronneberger and Philipp Fischer and Thomas Brox},\n    journal = {ArXiv},\n    year    = {2015},\n    volume  = {abs/1505.04597}\n}\n```\n\n```bibtex\n@article{Qin2020U2NetGD,\n    title   = {U2-Net: Going Deeper with Nested U-Structure for Salient Object Detection},\n    author  = {Xuebin Qin and Zichen Vincent Zhang and Chenyang Huang and Masood Dehghan and Osmar R Zaiane and Martin J{\\\"a}gersand},\n    journal = {ArXiv},\n    year    = {2020},\n    volume  = {abs/2005.09007}\n}\n```\n\n```bibtex\n@inproceedings{Henry2020QueryKeyNF,\n    title   = {Query-Key Normalization for Transformers},\n    author  = {Alex Henry and Prudhvi Raj Dachapally and Shubham Vivek Pawar and Yuxuan Chen},\n    booktitle = {FINDINGS},\n    year    = {2020}\n}\n```\n\n```bibtex\n@article{Qiao2019WeightS,\n    title   = {Weight Standardization},\n    author  = {Siyuan Qiao and Huiyu Wang and Chenxi Liu and Wei Shen and Alan Loddon Yuille},\n    journal = {ArXiv},\n    year    = {2019},\n    volume  = {abs/1903.10520}\n}\n```\n\n```bibtex\n@article{Shleifer2021NormFormerIT,\n    title   = {NormFormer: Improved Transformer Pretraining with Extra Normalization},\n    author  = {Sam Shleifer and Jason Weston and Myle Ott},\n    journal = {ArXiv},\n    year    = {2021},\n    volume  = {abs/2110.09456}\n}\n```\n\n```bibtex\n@article{Sunkara2022NoMS,\n    title   = {No More Strided Convolutions or Pooling: A New CNN Building Block for Low-Resolution Images and Small Objects},\n    author  = {Raja Sunkara and Tie Luo},\n    journal = {ArXiv},\n    year    = {2022},\n    volume  = {abs/2208.03641}\n}\n```\n\n```bibtex\n@inproceedings{Woo2023ConvNeXtVC,\n    title   = {ConvNeXt V2: Co-designing and Scaling ConvNets with Masked Autoencoders},\n    author  = {Sanghyun Woo and Shoubhik Debnath and Ronghang Hu and Xinlei Chen and Zhuang Liu and In-So Kweon and Saining Xie},\n    year    = {2023}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucidrains%2Fx-unet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flucidrains%2Fx-unet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucidrains%2Fx-unet/lists"}