{ "cells": [ { "cell_type": "code", "execution_count": null, "id": "593f43b1-8665-42e0-bac7-c8b5e073ce6d", "metadata": {}, "outputs": [], "source": [ "!pip install git+http://hf.co/usm3d/tools.git " ] }, { "cell_type": "code", "execution_count": 1, "id": "aa3534be-e92f-4ae7-bd21-e2d4fd49cd3a", "metadata": {}, "outputs": [], "source": [ "import torch\n", "from pytorch3d.renderer import (\n", " look_at_view_transform,\n", " FoVOrthographicCameras, \n", " PointsRasterizationSettings,\n", " PointsRenderer,\n", " PulsarPointsRenderer,\n", " PointsRasterizer,\n", " AlphaCompositor,\n", " NormWeightedCompositor,\n", " PerspectiveCameras\n", ")\n", "from pytorch3d.structures import Pointclouds" ] }, { "cell_type": "code", "execution_count": 2, "id": "503c6bcb-aa46-46c6-8b86-566b0a470b43", "metadata": {}, "outputs": [], "source": [ "import webdataset as wds \n", "import numpy as np\n", "from huggingface_hub import hf_hub_download\n", "from hoho import proc\n", "from tqdm import tqdm\n", "import sys\n", "sys.path.append('..')\n", "from handcrafted_solution import *\n", "import trimesh\n", "import hoho\n", "from hoho import *\n", "from hoho.vis import line\n", "import itertools\n", "import matplotlib.pyplot as plt\n", "import matplotlib.cm\n", "\n", "from handcrafted_solution import *\n", "\n", "def to_K(f, cx, cy):\n", " K = np.eye(3)\n", " K[0,0] = K[1,1] = f\n", " K[0,2] = cx\n", " K[1,2] = cy\n", " return K\n", "\n", "def quaternion_to_rotation_matrix(qvec):\n", " qw, qx, qy, qz = qvec\n", " R = np.array([\n", " [1 - 2*qy**2 - 2*qz**2, 2*qx*qy - 2*qz*qw, 2*qx*qz + 2*qy*qw],\n", " [2*qx*qy + 2*qz*qw, 1 - 2*qx**2 - 2*qz**2, 2*qy*qz - 2*qx*qw],\n", " [2*qx*qz - 2*qy*qw, 2*qy*qz + 2*qx*qw, 1 - 2*qx**2 - 2*qy**2]\n", " ])\n", " return R" ] }, { "cell_type": "code", "execution_count": 3, "id": "1acb8e09-d954-43bb-8d1b-ee5b4ab387ce", "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "9a2704c255624ca397bcf0ca6d11740a", "version_major": 2, "version_minor": 0 }, "text/plain": [ "VBox(children=(HTML(value='