{"id":30057035,"url":"https://github.com/liruilong940607/prope","last_synced_at":"2025-08-07T23:44:23.673Z","repository":{"id":304749832,"uuid":"980177551","full_name":"liruilong940607/prope","owner":"liruilong940607","description":"Cameras as Relative Positional Encoding","archived":false,"fork":false,"pushed_at":"2025-07-22T23:55:24.000Z","size":33242,"stargazers_count":376,"open_issues_count":0,"forks_count":3,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-07-23T00:23:18.203Z","etag":null,"topics":["multi-view","positional-encoding","transformer"],"latest_commit_sha":null,"homepage":"http://www.liruilong.cn/prope/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/liruilong940607.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null}},"created_at":"2025-05-08T17:35:07.000Z","updated_at":"2025-07-22T17:36:09.000Z","dependencies_parsed_at":"2025-07-15T04:42:25.503Z","dependency_job_id":"7448e28e-c595-4bae-8258-426e5c0707dc","html_url":"https://github.com/liruilong940607/prope","commit_stats":null,"previous_names":["liruilong940607/prope"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/liruilong940607/prope","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liruilong940607%2Fprope","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liruilong940607%2Fprope/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liruilong940607%2Fprope/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liruilong940607%2Fprope/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/liruilong940607","download_url":"https://codeload.github.com/liruilong940607/prope/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liruilong940607%2Fprope/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269342968,"owners_count":24401077,"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","status":"online","status_checked_at":"2025-08-07T02:00:09.698Z","response_time":73,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["multi-view","positional-encoding","transformer"],"created_at":"2025-08-07T23:44:21.524Z","updated_at":"2025-08-07T23:44:23.638Z","avatar_url":"https://github.com/liruilong940607.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PRoPE\nhttps://www.liruilong.cn/prope/\n\nThis is the official repo for the paper \"Cameras as Relative Positional Encoding\"\n\n\u003cimg width=\"1876\" height=\"596\" alt=\"image\" src=\"https://github.com/user-attachments/assets/9eba5518-b664-4d54-826c-6f35d7c84698\" /\u003e\n\n**TL;DR**: Language models and multi-view transformers must both bind “positional” information to input tokens, in terms of sequence position for LLMs and camera parameters for multi-view transformers. We present a study on camera conditioning that includes absolute positional encodings (e.g, raymaps), relative pose encodings (e.g., GTA), and a new method (PRoPE) uses *relative projective* transformation to capture 3D relationship between image tokens.\n\n## Implementations\n\nThe implementation of PRoPE is extremely simple and efficient. We provide standalone, single-file implementations for both JAX and PyTorch in [`prope/jax.py`](prope/jax.py) and [`prope/torch.py`](prope/torch.py). \n\n## Example of Usages\n\nHere we demo with PyTorch version:\n\n```python\n# Say we have C images, each carries with camera infomation, which would be used for cross-view understanding.\nviewmats: Tensor # (B, C, 4, 4) camera world-to-camera matrix\nKs: Tensor # (B, C, 3, 3) camera intrinsic matrix\n\n# In transformer we typically patchify the images into tokens. Say\n# the image size is (256, 384) and patch size is 16.\nimage_width, image_height = 256, 384\npatches_x, patches_y = image_width / 16, image_height / 16\n\n# And our attention layer has mapped the images from pixels (B, C, 384, 256) to Q/K/V tokens with shape (B, num_heads, seqlen, head_dim), where `seqlen = C * patches_x * patches_y`\nQ, K, V: Tensor = ... # (B, num_heads, seqlen, head_dim)\n\n# Injecting the camera information is simply replacing the native torch attention with our impl:\noutput = torch.nn.functional.scaled_dot_product_attention(Q, K, V)\n# --\u003e\noutput = prope_dot_product_attention(\n    Q, K, V,viewmats=viewmats, Ks=Ks, patches_x=patches_x, patches_y=patches_y, image_width=image_width, image_height=image_height\n)\n```\n\n## Experiments\n\n- Improve LVSM on the task of Novel View Syntheis: [Checkout `nvs` branch](https://github.com/liruilong940607/prope/tree/nvs)\n- Improve UniMatch on the task of Stereo Depth Estimation: To be released\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliruilong940607%2Fprope","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fliruilong940607%2Fprope","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliruilong940607%2Fprope/lists"}