{ "cells": [ { "cell_type": "code", "id": "initial_id", "metadata": { "collapsed": true, "ExecuteTime": { "end_time": "2024-06-10T16:29:55.195491Z", "start_time": "2024-06-10T16:29:50.639826Z" } }, "source": [ "from pprint import pprint\n", "\n", "\n", "import matplotlib.pyplot as plt\n", "\n", "import numpy as np\n", "\n", "\n", "import hoho\n", "from hoho import compute_WED\n", "from hoho import vis\n", "from hoho.vis import line\n", "\n", "from scipy.spatial.distance import cdist\n", "import cv2\n", "hoho.LOCAL_DATADIR = hoho.setup(\"../data\")\n", "from handcrafted_solution import predict\n", "from tqdm import tqdm\n", "import trimesh\n", "import scipy.cluster.hierarchy as shc\n", "from sklearn.cluster import DBSCAN\n", "import scipy.interpolate as si\n", "import trimesh" ], "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Using ..\\data as the data directory (we are running locally)\n" ] } ], "execution_count": 1 }, { "metadata": { "ExecuteTime": { "end_time": "2024-06-10T16:30:51.097137Z", "start_time": "2024-06-10T16:30:17.004643Z" } }, "cell_type": "code", "source": [ "split = \"all\"\n", "samples = []\n", "for i, sample in tqdm(enumerate(hoho.get_dataset(decode=None, split=split))):\n", " if i > 10:\n", " break\n", " samples.append((hoho.decode(sample), predict(sample, visualize=False,\n", " point_radius=30,\n", " max_angle=5,\n", " extend=30,\n", " merge_th=80.0,\n", " min_missing_distance=1000.0,\n", " scale_estimation_coefficient=2.54,\n", " clustering_eps=150,\n", " interpolation_radius=10000,\n", " point_radius_scale=1,\n", " # dist_coeff=0,\n", " pointcloud_depth_coeff=1,\n", " )))\n", "\n" ], "id": "a67fef6cb7b3df56", "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "11it [00:34, 3.09s/it]\n" ] } ], "execution_count": 2 }, { "metadata": { "ExecuteTime": { "end_time": "2024-06-10T16:30:51.102549Z", "start_time": "2024-06-10T16:30:51.098141Z" } }, "cell_type": "code", "source": [ "item_idx = 3\n", "decoded_dataset_item = samples[item_idx][0]\n", "predicted_wf = samples[item_idx][1]\n", "key, pred_vertices, pred_edges = predicted_wf\n", "\n", "predicted_wf = {\n", " '__key__': key,\n", " 'wf_vertices': pred_vertices.tolist(),\n", " 'wf_edges': pred_edges,\n", " 'edge_semantics': [0] * len(pred_edges)\n", "}" ], "id": "845770c32abd1f9", "outputs": [], "execution_count": 3 }, { "metadata": { "ExecuteTime": { "end_time": "2024-06-10T16:30:51.179048Z", "start_time": "2024-06-10T16:30:51.103555Z" } }, "cell_type": "code", "source": [ "\n", "scene = trimesh.scene.scene.Scene()\n", "\n", "# [scene.add_geometry(i) for i in hoho.vis.show_wf(decoded_dataset_item, 2)]\n", "[scene.add_geometry(i) for i in hoho.vis.show_wf(predicted_wf, 2)]\n", "scene.show()" ], "id": "cd82e8c7a6e88cf6", "outputs": [ { "data": { "text/plain": [ "" ], "text/html": [ "
" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "execution_count": 4 }, { "metadata": { "ExecuteTime": { "end_time": "2024-06-10T16:30:51.288217Z", "start_time": "2024-06-10T16:30:51.180059Z" } }, "cell_type": "code", "source": [ "scene = trimesh.scene.scene.Scene()\n", "# trimesh.points.plot_points([decoded_dataset_item[\"points3d\"][2414].xyz])\n", "pointcloud = trimesh.points.PointCloud(\n", " vertices=[point3D.xyz for point_id, point3D in decoded_dataset_item[\"points3d\"].items()],\n", " colors=[point3D.rgb for point_id, point3D in decoded_dataset_item[\"points3d\"].items()])\n", "scene.add_geometry(pointcloud)\n", "[scene.add_geometry(i) for i in hoho.vis.show_wf(decoded_dataset_item, 2)]\n", "scene.show()" ], "id": "164cca4d7cbb45fa", "outputs": [ { "data": { "text/plain": [ "" ], "text/html": [ "
" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "execution_count": 5 }, { "metadata": { "ExecuteTime": { "end_time": "2024-06-10T16:30:51.392372Z", "start_time": "2024-06-10T16:30:51.290226Z" } }, "cell_type": "code", "source": [ "scene = trimesh.scene.scene.Scene()\n", "# trimesh.points.plot_points([decoded_dataset_item[\"points3d\"][2414].xyz])\n", "pointcloud = trimesh.points.PointCloud(\n", " vertices=[point3D.xyz for point_id, point3D in decoded_dataset_item[\"points3d\"].items()],\n", " colors=[point3D.rgb for point_id, point3D in decoded_dataset_item[\"points3d\"].items()])\n", "scene.add_geometry(pointcloud)\n", "[scene.add_geometry(i) for i in hoho.vis.show_wf(predicted_wf, 2)]\n", "scene.show()" ], "id": "b0cdddba21c344e9", "outputs": [ { "data": { "text/plain": [ "" ], "text/html": [ "
" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "execution_count": 6 } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.6" } }, "nbformat": 4, "nbformat_minor": 5 }