Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add likelihood experiments to main repo #69

Open
wants to merge 99 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
5fe59e7
likelihood breaking
esli999 Jun 28, 2024
cc70fe6
nishad moving things around
nishadgothoskar Jun 29, 2024
d28367b
update mug test nb
esli999 Jun 30, 2024
9445d90
update mug nb to recreate automated pytest bug
esli999 Jul 1, 2024
183d320
mug data visualize samples
nishadgothoskar Jul 2, 2024
3d8b483
fix model
esli999 Jul 4, 2024
8a0190e
all models WIP
esli999 Jul 9, 2024
f2511e8
image likelihood library
esli999 Jul 13, 2024
5274431
mode volume test
esli999 Jul 13, 2024
4330670
update tests
esli999 Jul 14, 2024
c4cdee2
complete experiments
esli999 Jul 14, 2024
a01c02c
update figures
esli999 Jul 15, 2024
cdf893d
add posterior sample figs
esli999 Jul 15, 2024
71ce938
checkpoint
esli999 Jul 19, 2024
20d01e7
update lowres plot for aidan
esli999 Jul 21, 2024
c992885
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 21, 2024
bdd1ec4
Hierarhical Bayes
nishadgothoskar Jul 21, 2024
edefa2a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 21, 2024
213945f
geenrate video
nishadgothoskar Jul 22, 2024
a973326
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 22, 2024
0c5f1b4
MP4 generation
nishadgothoskar Jul 22, 2024
ffd0092
camera pose tracking
nishadgothoskar Jul 22, 2024
7c9208d
first pass at ruff linter fixes (#68)
sritchie Jul 23, 2024
d9fb151
[pre-commit.ci] pre-commit autoupdate (#73)
pre-commit-ci[bot] Jul 23, 2024
3ecaa2e
Move code to src directory (#74)
sritchie Jul 23, 2024
114e2b6
Port setup.py to modern pyproject.toml (#75)
sritchie Jul 23, 2024
a25a464
Upgrade to GenJAX 0.5.0, fix unsupported escape sequences (#76)
sritchie Jul 23, 2024
e539c74
More ruff fixes (#77)
sritchie Jul 23, 2024
f61b095
Fix bugs in run_tests.sh (#79)
georgematheos Jul 23, 2024
4ceabcf
Fix a bug in the `video_to_tracks` task (#80)
georgematheos Jul 23, 2024
0256164
Turn on ruff linter, fix final 7 bugs (#78)
sritchie Jul 24, 2024
4bb14fc
Make object acquisition demo callable by webapp (#81)
sritchie Jul 25, 2024
93c6088
jitting in demo
nishadgothoskar Jul 25, 2024
5c18562
turn off linting
nishadgothoskar Jul 26, 2024
179edf5
save
nishadgothoskar Jul 26, 2024
002379c
clean up mesh with clustering
nishadgothoskar Jul 26, 2024
bf3709c
turn off linter x2
nishadgothoskar Jul 26, 2024
21ffc1e
save
nishadgothoskar Jul 22, 2024
297081f
optimization
nishadgothoskar Jul 23, 2024
cb33c19
save
nishadgothoskar Jul 23, 2024
f9083bd
save kitti progress
nishadgothoskar Jul 23, 2024
618a9d4
save
nishadgothoskar Jul 23, 2024
c40370d
refactoring
nishadgothoskar Jul 23, 2024
80e3cf6
save
nishadgothoskar Jul 23, 2024
7f4693c
save
nishadgothoskar Jul 24, 2024
a753aba
stop removing the background
nishadgothoskar Jul 24, 2024
cf6324c
save before color exploration
nishadgothoskar Jul 24, 2024
eb73a1a
color exploration in progress
nishadgothoskar Jul 24, 2024
83a820b
save slam mesh
nishadgothoskar Jul 25, 2024
6e3af5a
blurring
nishadgothoskar Jul 25, 2024
d6ca514
slam improvements
nishadgothoskar Jul 25, 2024
d7942f1
figure out bug in using non log kernel instead of log kernel gaussian
nishadgothoskar Jul 25, 2024
214cad3
blur parameter inference working
nishadgothoskar Jul 25, 2024
f9cf441
Re-enable ruff formatting rules (#84)
sritchie Jul 26, 2024
6b6e355
update
nishadgothoskar Jul 26, 2024
5e61fc2
save
nishadgothoskar Jul 26, 2024
806eb7d
gridding working with no outlier branch
nishadgothoskar Jul 26, 2024
020da29
recovering params from infernce
nishadgothoskar Jul 26, 2024
c9b44dd
save before modifying outlier branch
nishadgothoskar Jul 26, 2024
570e794
save after convo with george
nishadgothoskar Jul 26, 2024
b2917db
noise in gridding
nishadgothoskar Jul 28, 2024
e18db7a
WIPa
nishadgothoskar Jul 28, 2024
dea48a0
Save part1 and part2 done
nishadgothoskar Jul 29, 2024
2382025
revert object model acquisition changes
nishadgothoskar Jul 29, 2024
507481f
In `tests/sama4d`, flip the convention from `[y, x]` to `[x, y]` (#88)
georgematheos Jul 29, 2024
8935880
fix failing tests
nishadgothoskar Jul 30, 2024
d7e7ab1
[pre-commit.ci] pre-commit autoupdate (#91)
pre-commit-ci[bot] Jul 31, 2024
c509923
localizaiton worked
nishadgothoskar Jul 30, 2024
6981077
mesh acquisition
nishadgothoskar Jul 31, 2024
472e5d8
slam working
nishadgothoskar Jul 31, 2024
9ac869a
likelihood back to flat
nishadgothoskar Jul 31, 2024
6d7df63
slam params
nishadgothoskar Jul 31, 2024
b27f949
tracking over master chef worked
nishadgothoskar Jul 31, 2024
6f7aa38
slam worked with single mesh
nishadgothoskar Jul 31, 2024
f8b9dec
tracking from frame 20 onwards working
nishadgothoskar Jul 31, 2024
30b76ab
tracking with refreshing mesh
nishadgothoskar Aug 1, 2024
37ee28f
get previous slam notebook working
nishadgothoskar Aug 1, 2024
867cd83
no crashes
nishadgothoskar Aug 1, 2024
566d305
update nb
esli999 Aug 1, 2024
38a8420
Merge branch 'likelihood_experiments' of github.com:probcomp/b3d into…
esli999 Aug 1, 2024
5332a62
likelihood breaking
esli999 Jun 28, 2024
79f5ab6
nishad moving things around
nishadgothoskar Jun 29, 2024
1d7ba3b
update mug test nb
esli999 Jun 30, 2024
f02def6
update mug nb to recreate automated pytest bug
esli999 Jul 1, 2024
387da91
mug data visualize samples
nishadgothoskar Jul 2, 2024
c1fb51f
fix model
esli999 Jul 4, 2024
4d1f597
all models WIP
esli999 Jul 9, 2024
3ec5168
image likelihood library
esli999 Jul 13, 2024
a8c0442
mode volume test
esli999 Jul 13, 2024
b1ee7e8
update tests
esli999 Jul 14, 2024
d0bc56c
complete experiments
esli999 Jul 14, 2024
124fcb9
update figures
esli999 Jul 15, 2024
7209c18
add posterior sample figs
esli999 Jul 15, 2024
476fd5f
checkpoint
esli999 Jul 19, 2024
ed40928
update lowres plot for aidan
esli999 Jul 21, 2024
2acf2b3
update nb
esli999 Aug 1, 2024
6745ef2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 21, 2024
99a2410
check rebase still works
esli999 Aug 1, 2024
ad698fa
update nb
esli999 Aug 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Ruff linter

on:
pull_request:
push:
branches:
- main

jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v4
with:
python-version: 3.11.5

- uses: chartboost/ruff-action@v1
with:
version: 0.5.4
args: check --output-format github
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@ assets/ycbineoat/*
**/**.json
**/**.npy
**/**.txt
!src/b3d/renderer/**/**.txt
assets/kitti/*
**/**.pth
**/**.obj
**/**.r3d
12 changes: 9 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
ci:
skip: [ruff]

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
Expand All @@ -8,8 +11,11 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.2
rev: v0.5.5
hooks:
- id: ruff
types_or: [ python, pyi ]
args: [ --fix ]

- id: ruff-format
args: [ --exclude, kitti.ipynb ]
types_or: [ python, pyi, jupyter ]
types_or: [ python, pyi ]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export XLA_PYTHON_CLIENT_ALLOCATOR="platform"
- Check if you can access the [GenJAX Users
Group](https://groups.google.com/u/1/a/chi-fro.org/g/genjax-users), and if not, run `\invite-genjax <google-account-email>` in any channel in the the probcomp Slack
- [Install the Google Cloud command line tools](https://cloud.google.com/sdk/docs/install).
- Run `gcloud auth application-default login`. (This command needs to be rerun ever time your machine reboots.)
- Run `gcloud auth application-default login`. (This command needs to be rerun every time your machine reboots.)

Next, on the machine, close the `b3d` repo:

Expand Down
2 changes: 0 additions & 2 deletions b3d/chisight/__init__.py

This file was deleted.

25 changes: 0 additions & 25 deletions b3d/chisight/dense/likelihoods/image_likelihood.py

This file was deleted.

3 changes: 0 additions & 3 deletions b3d/renderer/torch/pose.py

This file was deleted.

22 changes: 9 additions & 13 deletions demo.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
#!/usr/bin/env python
import jax.numpy as jnp
import jax
import matplotlib.pyplot as plt
import numpy as np
import os
import trimesh

import b3d
import b3d.bayes3d as bayes3d
from jax.scipy.spatial.transform import Rotation as Rot
from b3d import Pose
import fire
import genjax
import jax
import jax.numpy as jnp
import numpy as np
import rerun as rr
from b3d import Pose
from tqdm import tqdm
import fire


def test_demo():
Expand Down Expand Up @@ -53,11 +51,9 @@ def test_demo():
1.0,
)

num_layers = 2048
renderer = b3d.Renderer(image_width, image_height, fx, fy, cx, cy, near, far)
model = bayes3d.model_multiobject_gl_factory(renderer)
importance_jit = jax.jit(model.importance)
update_jit = jax.jit(model.update)

# Arguments of the generative model.
# These control the inlier / outlier decision boundary for color error and depth error.
Expand Down Expand Up @@ -118,7 +114,7 @@ def test_demo():

# `make_mesh_from_point_cloud_and_resolution` takes a 3D positions, colors, and sizes of the boxes that we want
# to place at each position and create a mesh
vertices, faces, vertex_colors, face_colors = (
vertices, faces, vertex_colors, _face_colors = (
b3d.make_mesh_from_point_cloud_and_resolution(
point_cloud,
colors,
Expand Down Expand Up @@ -167,7 +163,7 @@ def test_demo():
bayes3d.rerun_visualize_trace_t(trace, T_observed_image)

# Outliers are AND of the RGB and Depth outlier masks
inliers, color_inliers, depth_inliers, outliers, undecided, valid_data_mask = (
_inliers, _color_inliers, _depth_inliers, outliers, _undecided, _valid_data_mask = (
bayes3d.get_rgb_depth_inliers_from_trace(trace)
)
outlier_mask = outliers
Expand All @@ -186,7 +182,7 @@ def test_demo():
point_cloud_colors = point_cloud_colors.reshape(-1, 3)[assignment == 0]

# Create new mesh.
vertices, faces, vertex_colors, face_colors = (
vertices, faces, vertex_colors, _face_colors = (
b3d.make_mesh_from_point_cloud_and_resolution(
point_cloud, point_cloud_colors, point_cloud[:, 2] / fx * 2.0
)
Expand Down
43 changes: 18 additions & 25 deletions demos/detector_segmenter.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
import requests
from PIL import Image
import torch
import b3d
import io
import os

from transformers import OwlViTProcessor, OwlViTForObjectDetection
import b3d
import jax
import jax.numpy as jnp
import numpy
import numpy as np
import rerun as rr
import torch
from PIL import Image
from transformers import (
AutoModelForZeroShotObjectDetection,
AutoProcessor,
DetrFeatureExtractor,
DetrForSegmentation,
OwlViTForObjectDetection,
OwlViTProcessor,
)
from transformers.models.detr.feature_extraction_detr import rgb_to_id

processor = OwlViTProcessor.from_pretrained("google/owlvit-base-patch32")
model = OwlViTForObjectDetection.from_pretrained("google/owlvit-base-patch32")
Expand All @@ -17,12 +30,10 @@
)
)

import numpy as np

image = Image.fromarray(np.array(video_input.rgb[0]))
image.save("test.png")

from transformers import AutoProcessor, AutoModelForZeroShotObjectDetection

model_id = "IDEA-Research/grounding-dino-base"

Expand All @@ -45,34 +56,16 @@
)


import rerun as rr

PORT = 8812
rr.init("real")
rr.connect(addr=f"127.0.0.1:{PORT}")

rr.log("image", rr.Image(np.array(image)))

import io
import requests
from PIL import Image
import torch
import numpy
import jax.numpy as jnp
import numpy as np
import jax
import rerun as rr

from transformers import DetrFeatureExtractor, DetrForSegmentation
from transformers.models.detr.feature_extraction_detr import rgb_to_id


rr.init("segmentation")
rr.connect("127.0.0.1:8812")

import os
import b3d

# Load date
# path = os.path.join(b3d.get_root_path(),
# "assets/shared_data_bucket/input_data/shout_on_desk.r3d.video_input.npz")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
# Note: this uses a custom differentiable renderer defined inline in this script.

import jax.numpy as jnp
import jax
import matplotlib.pyplot as plt
import numpy as np
import functools
import os
import trimesh

import b3d
from jax.scipy.spatial.transform import Rotation as Rot
from b3d import Pose
import jax
import jax.numpy as jnp
import numpy as np
import rerun as rr
import functools
import genjax
from b3d import Pose

rr.init("gradients")
rr.connect("127.0.0.1:8812")
Expand Down Expand Up @@ -156,7 +153,7 @@ def render(particle_centers, particle_widths, particle_colors):
vertex_colors = vertex_colors.reshape(-1, 3)
triangle_index_to_particle_index = triangle_index_to_particle_index.reshape(-1)

uvs, _, triangle_id_image, depth_image = renderer.rasterize(
_uvs, _, triangle_id_image, depth_image = renderer.rasterize(
Pose.identity()[None, ...], vertices, faces, jnp.array([[0, len(faces)]])
)

Expand Down Expand Up @@ -221,7 +218,7 @@ def render(particle_centers, particle_widths, particle_colors):


def loss_func(a, b, c, gt_rgb, gt_depth):
rgb, depth, _ = render(a, b, c)
_rgb, depth, _ = render(a, b, c)
return jnp.mean(jnp.abs(depth - gt_depth))


Expand Down
Loading
Loading