pablovela5620 commited on
Commit
81452d7
·
1 Parent(s): f9ee816

first commit

Browse files
Files changed (4) hide show
  1. app.py +34 -5
  2. gradio_app.py +32 -0
  3. pixi.lock +0 -0
  4. pyproject.toml +159 -0
app.py CHANGED
@@ -1,7 +1,36 @@
1
- import gradio as gr
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import subprocess
2
+ from pathlib import Path
3
 
4
+ PIXI_PATH = Path("/home/user/.pixi/bin/pixi")
5
+ PIXI_VERSION = "0.45.0"
6
 
7
+
8
+ def check_and_install_pixi() -> None:
9
+ try:
10
+ subprocess.check_call(f"{PIXI_PATH} --version", shell=True)
11
+ except subprocess.CalledProcessError:
12
+ print("pixi not found. Installing pixi...")
13
+ # Install pixi using the provided installation script
14
+ subprocess.check_call(
15
+ f"PIXI_VERSION=v{PIXI_VERSION} curl -fsSL https://pixi.sh/install.sh | bash",
16
+ shell=True,
17
+ )
18
+ subprocess.check_call(f"{PIXI_PATH} self-update --version {PIXI_VERSION}", shell=True)
19
+ subprocess.check_call(f"{PIXI_PATH} --version", shell=True)
20
+
21
+
22
+ def run_command(command: str) -> None:
23
+ try:
24
+ subprocess.check_call(command, shell=True)
25
+ except subprocess.CalledProcessError as e:
26
+ print(f"run command {command}. Error: {e}")
27
+
28
+
29
+ if __name__ == "__main__":
30
+ check_and_install_pixi()
31
+ # install lsof
32
+ run_command(command=f"{PIXI_PATH} global install lsof")
33
+ # kill anything running on port 7860
34
+ run_command(command=f"{PIXI_PATH.parent}/lsof -t -i:7860 | xargs -r kill")
35
+ # run spaces app
36
+ run_command(command=f"{PIXI_PATH} run -e spaces app")
gradio_app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ # from annotation_example.gradio_ui.sv_sam import single_view_block
4
+
5
+ title = """# Segment Anything and Depth Anything"""
6
+ description1 = """
7
+ <a title="Website" href="https://rerun.io/" target="_blank" rel="noopener noreferrer" style="display: inline-block;">
8
+ <img src="https://img.shields.io/badge/Rerun-0.23.0-blue.svg?logo=data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGcgY2xpcC1wYXRoPSJ1cmwoI2NsaXAwXzQ0MV8xMTAzOCkiPgo8cmVjdCB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHJ4PSI4IiBmaWxsPSJibGFjayIvPgo8cGF0aCBkPSJNMy41OTcwMSA1Ljg5NTM0TDkuNTQyOTEgMi41MjM1OUw4Ljg3ODg2IDIuMTQ3MDVMMi45MzMgNS41MTg3NUwyLjkzMjk1IDExLjI5TDMuNTk2NDIgMTEuNjY2MkwzLjU5NzAxIDUuODk1MzRaTTUuMDExMjkgNi42OTc1NEw5LjU0NTc1IDQuMTI2MDlMOS41NDU4NCA0Ljk3NzA3TDUuNzYxNDMgNy4xMjI5OVYxMi44OTM4SDcuMDg5MzZMNi40MjU1MSAxMi41MTczVjExLjY2Nkw4LjU5MDY4IDEyLjg5MzhIOS45MTc5NUw2LjQyNTQxIDEwLjkxMzNWMTAuMDYyMUwxMS40MTkyIDEyLjg5MzhIMTIuNzQ2M0wxMC41ODQ5IDExLjY2ODJMMTMuMDM4MyAxMC4yNzY3VjQuNTA1NTlMMTIuMzc0OCA0LjEyOTQ0TDEyLjM3NDMgOS45MDAyOEw5LjkyMDkyIDExLjI5MTVMOS4xNzA0IDEwLjg2NTlMMTEuNjI0IDkuNDc0NTRWMy43MDM2OUwxMC45NjAyIDMuMzI3MjRMMTAuOTYwMSA5LjA5ODA2TDguNTA2MyAxMC40ODk0TDcuNzU2MDEgMTAuMDY0TDEwLjIwOTggOC42NzI1MlYyLjk5NjU2TDQuMzQ3MjMgNi4zMjEwOUw0LjM0NzE3IDEyLjA5Mkw1LjAxMDk0IDEyLjQ2ODNMNS4wMTEyOSA2LjY5NzU0Wk05LjU0NTc5IDUuNzMzNDFMOS41NDU4NCA4LjI5MjA2TDcuMDg4ODYgOS42ODU2NEw2LjQyNTQxIDkuMzA5NDJWNy41MDM0QzYuNzkwMzIgNy4yOTY0OSA5LjU0NTg4IDUuNzI3MTQgOS41NDU3OSA1LjczMzQxWiIgZmlsbD0id2hpdGUiLz4KPC9nPgo8ZGVmcz4KPGNsaXBQYXRoIGlkPSJjbGlwMF80NDFfMTEwMzgiPgo8cmVjdCB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIGZpbGw9IndoaXRlIi8+CjwvY2xpcFBhdGg+CjwvZGVmcz4KPC9zdmc+Cg==">
9
+ </a>
10
+ <a title="Website" href="https://ai.meta.com/sam2/" target="_blank" rel="noopener noreferrer" style="display: inline-block;">
11
+ <img src="https://www.obukhov.ai/img/badges/badge-website.svg">
12
+ <a title="Paper" href="https://ai.meta.com/research/publications/sam-2-segment-anything-in-images-and-videos/" target="_blank" rel="noopener noreferrer" style="display: inline-block;">
13
+ <img src="https://www.obukhov.ai/img/badges/badge-pdf.svg">
14
+ </a>
15
+ <a title="Github" href="https://github.com/rerun-io/annotation-example.git" target="_blank" rel="noopener noreferrer" style="display: inline-block;">
16
+ <img src="https://img.shields.io/github/stars/rerun-io/annotation-example?label=GitHub%20%E2%98%85&logo=github&color=C8C" alt="badge-github-stars">
17
+ </a>
18
+ <a title="Social" href="https://x.com/pablovelagomez1" target="_blank" rel="noopener noreferrer" style="display: inline-block;">
19
+ <img src="https://www.obukhov.ai/img/badges/badge-social.svg" alt="social">
20
+ </a>
21
+ """
22
+ description2 = "Using a combination of models to track an object in 3D"
23
+
24
+ with gr.Blocks() as demo:
25
+ gr.Markdown(title)
26
+ gr.Markdown(description1)
27
+ gr.Markdown(description2)
28
+ # with gr.Tab("Monocular"):
29
+ # single_view_block.render()
30
+
31
+ if __name__ == "__main__":
32
+ demo.queue(max_size=2).launch(ssr_mode=False)
pixi.lock ADDED
The diff for this file is too large to render. See raw diff
 
pyproject.toml ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [project]
2
+ name = "annotation-example"
3
+ version = "0.1.0"
4
+ description = "Add a short description here"
5
+ authors = [{ name = "Pablo Vela", email = "[email protected]" }]
6
+ requires-python = ">= 3.10"
7
+ dependencies = [
8
+ "mmcv-lite>=2.2.0,<2.3",
9
+ "build>=1.2.1,<2",
10
+ "hf-transfer>=0.1.8,<0.2",
11
+ ]
12
+
13
+ [build-system]
14
+ requires = ["setuptools"]
15
+ build-backend = "setuptools.build_meta"
16
+
17
+ [tool.setuptools.packages.find]
18
+ include = ["annotation_example*"]
19
+
20
+ [tool.pixi.project]
21
+ channels = ["conda-forge"]
22
+ platforms = ["linux-64"]
23
+
24
+
25
+ [tool.pixi.activation]
26
+ scripts = [".pixi.sh"]
27
+
28
+ [tool.pixi.pypi-options]
29
+ extra-index-urls = ["https://download.pytorch.org/whl/nightly/cu128"]
30
+ no-build-isolation = ["xformers"]
31
+ index-strategy = "unsafe-best-match"
32
+
33
+
34
+ [tool.pixi.tasks]
35
+ _install-wheel = "uv pip install ./$WHL_PATH --force-reinstall"
36
+ _build-wheel = "python -m build"
37
+ upload-hf = { cmd = "python tools/upload_to_hf.py", depends-on = [
38
+ "_build-wheel",
39
+ ] }
40
+
41
+ [tool.pixi.tasks.app]
42
+ cmd = """
43
+ python tools/gradio_app_singleview.py
44
+ """
45
+ description = "Runs Gradio frontend"
46
+ depends-on = ["_download-hocap-sample"]
47
+
48
+ [tool.pixi.tasks.multiview-app]
49
+ cmd = """
50
+ python tools/gradio_app_multiview.py
51
+ """
52
+ description = "Runs Gradio frontend"
53
+ depends-on = ["_download-hocap-sample"]
54
+
55
+ [tool.pixi.tasks.dev-app]
56
+ cmd = """
57
+ gradio tools/gradio_app.py
58
+ """
59
+ description = "Runs Gradio frontend for hotreload"
60
+
61
+ [tool.pixi.tasks._download-hocap-sample]
62
+ cmd = """
63
+ test -e data/hocap/sample.zip \
64
+ && test -e data/hocap/sample \
65
+ || (
66
+ mkdir -p data/hocap/ \
67
+ && huggingface-cli download pablovela5620/hocap-sample \
68
+ sample.zip --repo-type dataset \
69
+ --local-dir data/hocap/ \
70
+ && unzip -o data/hocap/sample.zip -d data/hocap/
71
+ )
72
+ """
73
+ outputs = ["data/hocap/sample.zip", "data/hocap/sample"]
74
+ description = "Downloads and extracts an example polycam dataset from huggingface, this may take a while"
75
+
76
+ [tool.pixi.tasks._download-assembly101-sample]
77
+ cmd = """
78
+ test -e data/assembly101-sample \
79
+ || (huggingface-cli download pablovela5620/Assembly101-Sample \
80
+ --repo-type dataset \
81
+ --include "assembly101-sample/**" \
82
+ --local-dir data/)
83
+ """
84
+ outputs = ["data/assembly101-sample"]
85
+ description = "Downloads an example assembly101 dataset from huggingface"
86
+
87
+ [tool.pixi.feature.spaces.tasks.app]
88
+ cmd = """
89
+ python gradio_app.py
90
+ """
91
+ description = "Runs Gradio frontend for depth comparison"
92
+ # depends-on = ["_install-wheel"]
93
+
94
+ [tool.pixi.pypi-dependencies]
95
+ annotation_example = { path = ".", editable = true }
96
+ sam-2 = { git = "https://github.com/facebookresearch/segment-anything-2.git", rev = "2b90b9f5ceec907a1c18123530e92e794ad901a4" }
97
+ torch = { version = ">=2.5.1", index = "https://download.pytorch.org/whl/nightly/cu128" }
98
+ torchvision = { version = ">=0.20.1", index = "https://download.pytorch.org/whl/nightly/cu128" }
99
+ torchcodec = { version = ">=0.2.1", index = "https://download.pytorch.org/whl/nightly/cu128" }
100
+ # cu128 version of xformers not yet available, needs to be built from source
101
+ # xformers = { version = ">=0.0.28.post3", index = "https://download.pytorch.org/whl/nightly/cu128" }
102
+ xformers = { git = "https://github.com/facebookresearch/xformers.git", rev = "main" }
103
+ vggt = { git = "https://github.com/facebookresearch/vggt.git", rev = "f8bf73ac25d5089cca2d6540a185697087fa2255" }
104
+ monopriors = { git = "https://github.com/pablovela5620/monoprior.git", rev = "90fe03ab3a4ee1b8df542d5b8638bf034d933757" }
105
+ # gradio-rerun = { url = "https://huggingface.co/datasets/pablovela5620/gradio-rr-0.23/resolve/main/gradio_rerun-0.0.8-py3-none-any.whl" }
106
+ gradio-rerun = { path = "/home/pablo/0Dev/work/rerun-projects/annotation-example/dist/gradio_rerun-0.0.8-py3-none-any.whl" }
107
+ rerun-sdk = { url = "https://github.com/rerun-io/rerun/releases/download/prerelease/rerun_sdk-0.23.0a3+dev-cp38-abi3-manylinux_2_31_x86_64.whl" }
108
+ simplecv = { git = "https://github.com/pablovela5620/simplecv.git", rev = "e39f6d87126d8348e40fd2b46c30ced5d76cad76" }
109
+
110
+
111
+ [tool.pixi.dependencies]
112
+ python = "3.11.*"
113
+ uv = ">=0.3.4,<0.4"
114
+ einops = ">=0.8.0,<0.9"
115
+ py-opencv = ">=4.11.0,<5"
116
+ transformers = ">=4.50.0,<5"
117
+ setuptools = ">=75.8.2,<76"
118
+ numpy = "<2"
119
+ ffmpeg = ">=7.1.1,<8"
120
+ pyserde = ">=0.23.0,<0.24"
121
+ jaxtyping = ">=0.2.36,<0.3"
122
+ open3d = ">=0.19.0,<0.20"
123
+ easydict = ">=1.13,<2"
124
+ ninja = ">=1.12.1,<2"
125
+ cuda = "12.8.*"
126
+ cuda-nvcc = "12.8.*"
127
+ cudnn = ">=9.8.0.87,<10"
128
+
129
+ [tool.pixi.feature.spaces.pypi-dependencies]
130
+ spaces = "==0.34.2"
131
+
132
+
133
+ [tool.pixi.environments]
134
+ spaces = { features = ["spaces"], solve-group = "default" }
135
+
136
+
137
+ [tool.ruff]
138
+ line-length = 150
139
+ select = [
140
+ # pycodestyle
141
+ "E",
142
+ # Pyflakes
143
+ "F",
144
+ # pyupgrade
145
+ "UP",
146
+ # flake8-bugbear
147
+ "B",
148
+ # flake8-simplify
149
+ "SIM",
150
+ # isort
151
+ "I",
152
+ ]
153
+
154
+ ignore = [
155
+ "E501", # Line too long.
156
+ "F722", # Forward annotation false positive from jaxtyping. Should be caught by pyright.
157
+ "F821", # Forward annotation false positive from jaxtyping. Should be caught by pyright.
158
+ "SIM117", # Use a single `with` statement with multiple contexts instead of nested `with` statements
159
+ ]