Viewer refactor with state sync (#212)

* initial commit for viewer refactor

* updating name change to nerfactory

* adding headers

* making the rendering fix which broke from a merge

* things are starting to work. removing old commands now

* removed prints

* cleanup

* updating state works now even for nested dictionaries

* updating state in redux. listening for state changes. trying to draw three.js now

* added drawing functionality. need to fix translation of frustums and image planes

* images and frustums drawn correctly

* fixing lint

* github actions

* back to npm

* fixing eslint

* remove package.json from root

* new favicon

* some viewer cleanup

* notebook

* fixed camera drawings speed to avoid redraw

* trying to get Leva to update

* quick fix

* synced config panel

* adding notebook

* fixing output print error
This commit is contained in:
Ethan Weber authored and GitHub committed 2022-08-02 16:02:07 -05:00
1 parent 966374474d
commit 73fedc7593
67 files changed
+2510 -14057

No files matched your search

+1
View File
@@ -0,0 +1 @@
# Notebooks
-29
View File
@@ -1,29 +0,0 @@
# image stuff
import imageio
import mediapy as media
# plotly stuff
import plotly.graph_objects as go
# ipython stuff
from IPython import get_ipython
def setup_ipynb():
"""
https://stackoverflow.com/questions/15411967/how-can-i-check-if-code-is-executed-in-the-ipython-notebook
https://stackoverflow.com/questions/35595766/matplotlib-line-magic-causes-syntaxerror-in-python-script
This gets reference to the InteractiveShell instance
"""
try:
from IPython import get_ipython
get_ipython().run_line_magic("load_ext", "autoreload")
get_ipython().run_line_magic("autoreload", "2")
get_ipython().run_line_magic("matplotlib", "inline")
return True
except:
return False
setup_ipynb()
File diff suppressed because it is too large. Load diff
-129
View File
@@ -1,129 +0,0 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "3c00934d-0f14-4c1a-a563-94d627b377e5",
"metadata": {},
"source": [
"## Notebook to visualize the viewer functionality\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b15dfdc1-5054-40bc-9631-4c7426eecfd9",
"metadata": {},
"outputs": [],
"source": [
"from notebook_imports import *\n",
"\n",
"import time\n",
"import torch\n",
"from torch.utils.data import DataLoader\n",
"\n",
"from nerfactory.data.dataloader import TrainDataloader\n",
"from nerfactory.data.image_dataset import ImageDataset, PanopticImageDataset\n",
"from nerfactory.data.image_sampler import CacheImageSampler\n",
"from nerfactory.data.pixel_sampler import PixelSampler\n",
"from nerfactory.data.utils import DatasetInputs, get_dataset_inputs_from_dataset_config\n",
"from nerfactory.graphs.modules.ray_generator import RayGenerator\n",
"from nerfactory.graphs.modules.scene_colliders import SceneBoundsCollider, AABBBoxCollider\n",
"from nerfactory.cameras.cameras import get_camera\n",
"from nerfactory.cameras.rays import RayBundle\n",
"from nerfactory.utils.io import get_absolute_path\n",
"from nerfactory.utils.plotly import get_line_segments_from_lines\n",
"from nerfactory.cameras.cameras import get_camera_model\n",
"from nerfactory.utils.misc import get_dict_to_torch, instantiate_from_dict_config\n",
"from nerfactory.engine.trainer import Trainer\n",
"from nerfactory.utils.config import Config, setup_config\n",
"\n",
"from hydra import compose, initialize\n",
"from omegaconf import open_dict\n",
"import pprint\n",
"from tqdm import tqdm\n",
"import random\n",
"\n",
"import numpy as np\n",
"\n",
"import umsgpack\n",
"from nerfactory.viewer.server.utils import get_chunks, get_intrinsics_matrix_and_camera_to_world_h\n",
"\n",
"from nerfactory.viewer.server import viewer_utils\n",
"from nerfactory.viewer.server.visualizer import Viewer\n",
"from nerfactory.viewer.server.utils import get_camera_from_vis"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "26d6da3c-e28a-4c55-9592-d90dccb86051",
"metadata": {},
"outputs": [],
"source": [
"# connect to the viewer\n",
"vis = Viewer(zmq_url=\"tcp://127.0.0.1:6000\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "605e0131-bfbe-4309-b338-c49a46923d8f",
"metadata": {},
"outputs": [],
"source": [
"# draw a red box\n",
"viewer_utils.show_box_test(vis)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1b3ba0e1-ade8-4bda-bcb4-0dd2ca74dda4",
"metadata": {},
"outputs": [],
"source": [
"# move the camera in a spiral path\n",
"camera = get_camera_from_vis(vis)\n",
"camera_path = get_spiral_path(camera, steps=120, radius=0.5)\n",
"seconds = 5\n",
"fps = len(camera_path.cameras) / seconds\n",
"spf = 1 / fps\n",
"for cam in camera_path.cameras:\n",
" viewer_utils.set_camera(vis, cam)\n",
" time.sleep(spf)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5a01cf1c-07d1-47fd-a39b-817298a83760",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"interpreter": {
"hash": "4a749acc7d255f078aee52e0584cc77b3cb5aaed1b3a7407ec4262c1bf6cb526"
},
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.13"
}
},
"nbformat": 4,
"nbformat_minor": 5
}