{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "pycharm": {
     "is_executing": false
    }
   },
   "outputs": [],
   "source": [
    "from mmdet3d.apis import LidarDet3DInferencer"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# initialize inferencer\n",
    "inferencer = LidarDet3DInferencer('pointpillars_kitti-3class')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "pycharm": {
     "is_executing": false
    }
   },
   "outputs": [],
   "source": [
    "# inference\n",
    "inputs = dict(points='./data/kitti/000008.bin')\n",
    "inferencer(inputs)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# inference and visualize\n",
    "# NOTE: use the `Esc` key to exit Open3D window in Jupyter Notebook Environment\n",
    "inferencer(inputs, show=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# If your operating environment does not have a display device,\n",
    "# (e.g. a remote server), you can save the predictions and visualize\n",
    "# them in local devices.\n",
    "inferencer(inputs, show=False, out_dir='./remote_outputs')\n",
    "\n",
    "# Simulate the migration process\n",
    "%mv ./remote_outputs ./local_outputs\n",
    "\n",
    "# Visualize the predictions from the saved files\n",
    "# NOTE: use the `Esc` key to exit Open3D window in Jupyter Notebook Environment\n",
    "local_inferencer = LidarDet3DInferencer('pointpillars_kitti-3class')\n",
    "inputs = local_inferencer._inputs_to_list(inputs)\n",
    "local_inferencer.visualize_preds_fromfile(inputs, ['local_outputs/preds/000008.json'], show=True)"
   ]
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "a0c343fece975dd89087e8c2194dd4d3db28d7000f1b32ed9ed9d584dd54dbbe"
  },
  "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.9.16"
  },
  "pycharm": {
   "stem_cell": {
    "cell_type": "raw",
    "metadata": {
     "collapsed": false
    },
    "source": []
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
